-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
signal.go
Outdated
delay, err := strconv.Atoi(delayStr) | ||
if err != nil { | ||
log.Warn("well: set default cancellation delay seconds", map[string]interface{}{ | ||
"env": delayStr, |
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.
should err
be added?
log.FnError: err
signal.go
Outdated
@@ -28,6 +34,23 @@ func handleSignal(env *Environment) { | |||
log.Warn("well: got signal", map[string]interface{}{ | |||
"signal": s.String(), | |||
}) | |||
delayStr := os.Getenv(cancellationDelaySecondsEnv) | |||
delay, err := strconv.Atoi(delayStr) |
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.
This should be done only when if len(delayStr) > 0
.
@tapih Please elaborate the message body of this pull request. |
signal.go
Outdated
|
||
func getDelaySecondsFromEnv() int { | ||
delayStr := os.Getenv(cancellationDelaySecondsEnv) | ||
if len(delayStr) <= 0 { |
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.
len
never returns < 0
, so this should be ==
.
signal.go
Outdated
log.Warn("well: round up negative cancellation delay seconds to 0s", map[string]interface{}{ | ||
"env": delayStr, | ||
"delay": 0, | ||
log.FnError: err, |
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.
At this point, err
is nil
, so do not add it.
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.
LGTM
To shutdown a Kubernetes Pod gracefully, the container process needs to continue accepting connections until the Pod gets removed from the service Endpoints by
kube-controller-manager
.This is typically done by
/bin/sleep
inpreStop
hook, but doing so is tedious and requires/bin/sleep
in the root filesystem.This PR removes the necessity of
preStop
hook and/bin/sleep
with the following changes: