-
Notifications
You must be signed in to change notification settings - Fork 0
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
COSI-55: improve graceful shutdown in main.go #84
COSI-55: improve graceful shutdown in main.go #84
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
@@ Coverage Diff @@
## main #84 +/- ##
=======================================
Coverage 93.67% 93.67%
=======================================
Files 10 10
Lines 680 680
=======================================
Hits 637 637
Misses 37 37
Partials 6 6 |
cmd/scality-cosi-driver/main.go
Outdated
case <-ctx.Done(): | ||
klog.InfoS("Scality COSI driver shutdown initiated successfully, context canceled") | ||
case sig = <-sigs: | ||
klog.ErrorS(nil, "Initiating graceful shutdown, repeat signal to force shutdown", "type", sig) |
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.
klog.ErrorS(nil, "Initiating graceful shutdown, repeat signal to force shutdown", "type", sig) | |
klog.ErrorS(nil, "Forcing shutdown due to repeated signal", "type", sig) |
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.
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.
🤔 The same line of log is printed twice here. I agree with the first one which is when one signal is sent Initiating graceful shutdown, repeat signal to force shutdown
. The second one should say that we received a second signal and that we will exit forcefully. What do you think?
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.
👍
Also I would change Force
to Forcing
in both messages.
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.
Yep, good point!
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.
After thinking more, I took your suggestions and made the change. I want to keep the log messages in past tense where possible.
Let me know if anyone is not good with this.
This is the change I made:
klog.InfoS("Graceful shutdown initiated; repeat signal to force immediate shutdown")
select {
case sig = <-sigs:
klog.ErrorS(nil, "Second signal received—forcing shutdown", "type", sig)
os.Exit(1)
case <-time.After(30 * time.Second):
klog.ErrorS(nil, "Forcing shutdown due to timeout", "timeout", 30*time.Second)
os.Exit(1)
}
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
cmd/scality-cosi-driver/main.go
Outdated
case <-ctx.Done(): | ||
klog.InfoS("Scality COSI driver shutdown initiated successfully, context canceled") | ||
case sig = <-sigs: | ||
klog.ErrorS(nil, "Initiating graceful shutdown, repeat signal to force shutdown", "type", sig) |
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.
👍
Also I would change Force
to Forcing
in both messages.
Enhanced signal handling for SIGINT/SIGTERM to allow for a graceful shutdown process. Added timeout-based force exit to prevent indefinite waiting during shutdown scenarios.
de1933e
to
49ea6c2
Compare
Enhanced signal handling for SIGINT/SIGTERM to allow for a graceful shutdown process. Added timeout-based force exit to prevent indefinite waiting during shutdown scenarios.
note to reviewers: Unit test suite is needed for main package, for now relying on e2e tests.