Skip to content

add pods to webhook event and log pods on node #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cmd/node-termination-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ func drainOrCordonIfNecessary(interruptionEventStore *interruptioneventstore.Sto
} else {
cordonAndDrainNode(node, nodeName, metrics, recorder, nthConfig.EnableSQSTerminationDraining)
}
podNameList, err := node.FetchPodNameList(nodeName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this will slightly change the behavior - previously if the node didn't exist then this code wouldn't execute, but now that you've moved this block out of the else block from line 349, this can get ran when the node is gone.

Perhaps we should return errors from the cordonNode and cordonAndDrainNode funcs and then check against them here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to show the list of of pods during drain? My understanding was that these pods are being drained anyway so why care. I guess maybe they just want to maintain list of pods getting drained, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I don't really see a reason not to. Only users that want it have to put it into their webhook template.

drainEvent.Pods = podNameList
if err != nil {
log.Err(err).Msgf("Unable to fetch running pods for node '%s' ", nodeName)
}
err = node.LogPods(podNameList, nodeName)
if err != nil {
log.Err(err).Msg("There was a problem while trying to log all pod names on the node")
}

interruptionEventStore.MarkAllAsProcessed(nodeName)
if nthConfig.WebhookURL != "" {
Expand Down Expand Up @@ -348,15 +357,6 @@ func cordonNode(node node.Node, nodeName string, drainEvent *monitor.Interruptio
}
} else {
log.Info().Str("node_name", nodeName).Msg("Node successfully cordoned")
podNameList, err := node.FetchPodNameList(nodeName)
drainEvent.Pods = podNameList
if err != nil {
log.Err(err).Msgf("Unable to fetch running pods for node '%s' ", nodeName)
}
err = node.LogPods(podNameList, nodeName)
if err != nil {
log.Err(err).Msg("There was a problem while trying to log all pod names on the node")
}
metrics.NodeActionsInc("cordon", nodeName, err)
recorder.Emit(nodeName, observability.Normal, observability.CordonReason, observability.CordonMsg)
}
Expand Down