diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index e48a940e8..ef6a51754 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -531,6 +531,7 @@ func (s *StateStore) UpsertNode(index uint64, node *structs.Node) error { node.Drain = exist.Drain // Retain the drain mode node.SchedulingEligibility = exist.SchedulingEligibility // Retain the eligibility + node.DrainStrategy = exist.DrainStrategy // Retain the drain strategy } else { // Because this is the first time the node is being registered, we should // also create a node registration event @@ -598,8 +599,7 @@ func (s *StateStore) UpdateNodeStatus(index uint64, nodeID, status string) error // Copy the existing node existingNode := existing.(*structs.Node) - copyNode := new(structs.Node) - *copyNode = *existingNode + copyNode := existingNode.Copy() // Update the status in the copy copyNode.Status = status @@ -639,11 +639,7 @@ func (s *StateStore) UpdateNodeDrain(index uint64, nodeID string, drain *structs // Update the drain in the copy copyNode.Drain = drain != nil // COMPAT: Remove in Nomad 0.9 copyNode.DrainStrategy = drain - if drain == nil { - // When stopping a drain unset the strategy but leave the node - // ineligible for scheduling - copyNode.DrainStrategy = nil - } else { + if drain != nil { copyNode.SchedulingEligibility = structs.NodeSchedulingIneligible }