Skip to content

Commit

Permalink
nomad state store must be modified through raft, rm local state change
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbailey committed Feb 3, 2020
1 parent f788316 commit 895e563
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
20 changes: 9 additions & 11 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,6 @@ func (s *StateStore) updateDeploymentWithAlloc(index uint64, alloc, existing *st
alloc.DeploymentStatus.ModifyIndex = index
}


// Create a copy of the deployment object
deploymentCopy := deployment.Copy()
deploymentCopy.ModifyIndex = index
Expand All @@ -3580,18 +3579,17 @@ func (s *StateStore) updateDeploymentWithAlloc(index uint64, alloc, existing *st
state.UnhealthyAllocs += unhealthy

// Ensure PlacedCanaries accurately reflects the alloc canary status
if alloc.DeploymentStatus != nil {
if alloc.DeploymentStatus.Canary {
found := false
for _, canary := range state.PlacedCanaries {
if alloc.ID == canary {
found = true
}
}
if !found {
state.PlacedCanaries = append(state.PlacedCanaries, alloc.ID)
if alloc.DeploymentStatus != nil && alloc.DeploymentStatus.Canary {
found := false
for _, canary := range state.PlacedCanaries {
if alloc.ID == canary {
found = true
break
}
}
if !found {
state.PlacedCanaries = append(state.PlacedCanaries, alloc.ID)
}
}

// Update the progress deadline
Expand Down
4 changes: 0 additions & 4 deletions scheduler/generic_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,6 @@ func (s *GenericScheduler) computePlacements(destructive, place []placementResul
// If we are placing a canary and we found a match, add the canary
// to the deployment state object and mark it as a canary.
if missing.Canary() && s.deployment != nil {
if state, ok := s.deployment.TaskGroups[tg.Name]; ok {
state.PlacedCanaries = append(state.PlacedCanaries, alloc.ID)
}

alloc.DeploymentStatus = &structs.AllocDeploymentStatus{
Canary: true,
}
Expand Down

0 comments on commit 895e563

Please sign in to comment.