Skip to content

Commit 792da16

Browse files
authored
Ensure all node removal and taint log messages contain nodegroup fields (#223)
1 parent 88e055c commit 792da16

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/controller/scale_down.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (c *Controller) TryRemoveTaintedNodes(opts scaleOpts) (int, error) {
7272
if now.Sub(*taintedTime) > opts.nodeGroup.Opts.SoftDeleteGracePeriodDuration() {
7373
if k8s.NodeEmpty(candidate, opts.nodeGroup.NodeInfoMap) || now.Sub(*taintedTime) > opts.nodeGroup.Opts.HardDeleteGracePeriodDuration() {
7474
drymode := c.dryMode(opts.nodeGroup)
75-
log.WithField("drymode", drymode).Infof("Node %v, %v ready to be deleted", candidate.Name, candidate.Spec.ProviderID)
75+
log.WithField("drymode", drymode).WithField("nodegroup", opts.nodeGroup.Opts.Name).Infof("Node %v, %v ready to be deleted", candidate.Name, candidate.Spec.ProviderID)
7676
if !drymode {
7777
toBeDeleted = append(toBeDeleted, candidate)
7878
}
@@ -128,7 +128,7 @@ func (c *Controller) TryRemoveTaintedNodes(opts scaleOpts) (int, error) {
128128
log.WithError(err).Errorf("failed to delete nodes from kubernetes")
129129
return 0, err
130130
}
131-
log.Infof("Sent delete request to %v nodes", len(toBeDeleted))
131+
log.WithField("nodegroup", opts.nodeGroup.Opts.Name).Infof("Sent delete request to %v nodes", len(toBeDeleted))
132132
metrics.NodeGroupPodsEvicted.WithLabelValues(opts.nodeGroup.Opts.Name).Add(float64(podsRemaining))
133133
}
134134

@@ -162,7 +162,7 @@ func (c *Controller) scaleDownTaint(opts scaleOpts) (int, error) {
162162
// Perform the tainting loop with the fail safe around it
163163
tainted := c.taintOldestN(opts.untaintedNodes, opts.nodeGroup, nodesToRemove)
164164

165-
log.Infof("Tainted a total of %v nodes", len(tainted))
165+
log.WithField("nodegroup", nodegroupName).Infof("Tainted a total of %v nodes", len(tainted))
166166
return len(tainted), nil
167167
}
168168

@@ -184,7 +184,7 @@ func (c *Controller) taintOldestN(nodes []*v1.Node, nodeGroup *NodeGroupState, n
184184

185185
// only actually taint in dry mode
186186
if !c.dryMode(nodeGroup) {
187-
log.WithField("drymode", "off").Infof("Tainting node %v", bundle.node.Name)
187+
log.WithField("drymode", "off").WithField("nodegroup", nodeGroup.Opts.Name).Infof("Tainting node %v", bundle.node.Name)
188188

189189
// Taint the node
190190
updatedNode, err := k8s.AddToBeRemovedTaint(bundle.node, c.Client, nodeGroup.Opts.TaintEffect)
@@ -197,7 +197,7 @@ func (c *Controller) taintOldestN(nodes []*v1.Node, nodeGroup *NodeGroupState, n
197197
} else {
198198
nodeGroup.taintTracker = append(nodeGroup.taintTracker, bundle.node.Name)
199199
taintedIndices = append(taintedIndices, bundle.index)
200-
log.WithField("drymode", "on").Infof("Tainting node %v", bundle.node.Name)
200+
log.WithField("drymode", "on").WithField("nodegroup", nodeGroup.Opts.Name).Infof("Tainting node %v", bundle.node.Name)
201201
}
202202
}
203203

0 commit comments

Comments
 (0)