From 694d5600e81257ad058a182b7c8985037bc4a2ee Mon Sep 17 00:00:00 2001 From: Kellen Fox Date: Mon, 15 Aug 2022 10:55:54 -0700 Subject: [PATCH 1/3] Add a log line to help track node eligibility Often when debugging issues with our nomad cluster we find that it can be difficult to correlate manual and automated actions against the cluster state as nodes are brought into and out of production. --- nomad/node_endpoint.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nomad/node_endpoint.go b/nomad/node_endpoint.go index 39b870186009..b9eaf4f669bd 100644 --- a/nomad/node_endpoint.go +++ b/nomad/node_endpoint.go @@ -661,6 +661,7 @@ func (n *Node) UpdateDrain(args *structs.NodeUpdateDrainRequest, // If the node is transitioning to be eligible, create Node evaluations // because there may be a System job registered that should be evaluated. if node.SchedulingEligibility == structs.NodeSchedulingIneligible && args.MarkEligible && args.DrainStrategy == nil { + n.logger.With("node_id", node.ID).Info("Node transitioning to eligible state") evalIDs, evalIndex, err := n.createNodeEvals(node, index) if err != nil { n.logger.Error("eval creation failed", "error", err) @@ -736,8 +737,10 @@ func (n *Node) UpdateEligibility(args *structs.NodeUpdateEligibilityRequest, if node.SchedulingEligibility == args.Eligibility { return nil // Nothing to do } else if args.Eligibility == structs.NodeSchedulingEligible { + n.logger.With("node_id", node.ID).Info("Node transitioning to eligible state") args.NodeEvent.SetMessage(NodeEligibilityEventEligible) } else { + n.logger.With("node_id", node.ID).Info("Node transitioning to ineligible state") args.NodeEvent.SetMessage(NodeEligibilityEventIneligible) } From 7223cce5941502097064be828f6a63ea2b9535c1 Mon Sep 17 00:00:00 2001 From: Kellen Fox Date: Tue, 16 Aug 2022 09:24:19 -0700 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: James Rasell --- nomad/node_endpoint.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nomad/node_endpoint.go b/nomad/node_endpoint.go index b9eaf4f669bd..c13ec70cc565 100644 --- a/nomad/node_endpoint.go +++ b/nomad/node_endpoint.go @@ -661,7 +661,7 @@ func (n *Node) UpdateDrain(args *structs.NodeUpdateDrainRequest, // If the node is transitioning to be eligible, create Node evaluations // because there may be a System job registered that should be evaluated. if node.SchedulingEligibility == structs.NodeSchedulingIneligible && args.MarkEligible && args.DrainStrategy == nil { - n.logger.With("node_id", node.ID).Info("Node transitioning to eligible state") + n.logger.Info("node transitioning to eligible state", "node_id", node.ID) evalIDs, evalIndex, err := n.createNodeEvals(node, index) if err != nil { n.logger.Error("eval creation failed", "error", err) @@ -737,10 +737,10 @@ func (n *Node) UpdateEligibility(args *structs.NodeUpdateEligibilityRequest, if node.SchedulingEligibility == args.Eligibility { return nil // Nothing to do } else if args.Eligibility == structs.NodeSchedulingEligible { - n.logger.With("node_id", node.ID).Info("Node transitioning to eligible state") + n.logger.Info("node transitioning to eligible state", "node_id", node.ID) args.NodeEvent.SetMessage(NodeEligibilityEventEligible) } else { - n.logger.With("node_id", node.ID).Info("Node transitioning to ineligible state") + n.logger.Info("node transitioning to ineligible state", "node_id", node.ID) args.NodeEvent.SetMessage(NodeEligibilityEventIneligible) } From 7d46b73e7a9c5e9f8792a10b292528c342aa4d15 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Tue, 6 Sep 2022 12:03:54 +0100 Subject: [PATCH 3/3] changelog: add entry for #14125 --- .changelog/14125.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/14125.txt diff --git a/.changelog/14125.txt b/.changelog/14125.txt new file mode 100644 index 000000000000..04da59dfb4db --- /dev/null +++ b/.changelog/14125.txt @@ -0,0 +1,3 @@ +```release-note:improvement +server: Log when a node's eligibility changes +```