This repository has been archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Begin draining a node when it enters Terminating
state
#5
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ type HookHandler struct { | |
|
||
// Loop starts an infinite handler loop | ||
func (h *HookHandler) Loop(nodeName string) { | ||
var drained bool | ||
glog.Infof("Running node drainer on node '%s' on instance '%s' in region '%s' and profile '%s'", | ||
nodeName, h.AutoScaling.Options.InstanceID, h.AutoScaling.Options.Region, h.AutoScaling.Options.Profile) | ||
for { | ||
|
@@ -29,17 +30,25 @@ func (h *HookHandler) Loop(nodeName string) { | |
continue | ||
} | ||
glog.Infof("Status of instance '%v' is '%v', autoscaling group is '%v'", h.AutoScaling.Options.InstanceID, *status, *autoScalingGroupName) | ||
if !h.AutoScaling.IsTerminating(status) { | ||
if !h.AutoScaling.IsTerminating(status) && !h.AutoScaling.IsTerminatingWait(status) { | ||
continue | ||
} | ||
|
||
err = h.Drainer.Drain(nodeName) | ||
if err != nil { | ||
glog.Warningf("Not all pods on this host can be evicted, will try again: %s", err) | ||
if !drained { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so if I understand correctly, there was a misleading message in logs, that was not always true, and now we fix that, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, after moving the draining to happen as soon as it sees the "Termination" state, it will probably loop several times before it hits the "Termination:Wait" state, and this is to just avoid it trying to cordon and drain again if it's already done so successfully. |
||
err = h.Drainer.Drain(nodeName) | ||
if err != nil { | ||
glog.Warningf("Not all pods on this host can be evicted, will try again: %s", err) | ||
continue | ||
} | ||
drained = true | ||
glog.Info("All evictable pods are gone, waiting to enter Terminating:Wait state") | ||
} | ||
|
||
if !h.AutoScaling.IsTerminatingWait(status) { | ||
continue | ||
} | ||
glog.Infof("All evictable pods are gone, notifying AutoScalingGroup that instance '%v' can be shutdown", h.AutoScaling.Options.InstanceID) | ||
|
||
glog.Infof("Notifying AutoScalingGroup that instance '%v' can be shutdown", h.AutoScaling.Options.InstanceID) | ||
lifecycleHookName, err := h.AutoScaling.GetLifecycleHookName(autoScalingGroupName) | ||
if err != nil { | ||
glog.Warningf("Can not get lifecycle hook, will try again: %s", err) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the fact that you've used both to make sure it triggers if the docs and impl from AWS diverge.