-
Notifications
You must be signed in to change notification settings - Fork 980
fix: separate signals for passive, active, and forced shutdown #12358
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
Changes from 1 commit
8d160ae
210a143
4c6a1d2
afc2dc0
3c9254a
67db53c
bf60566
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
`SIGTERM`: Passive shutdown stopping provisioner daemons from accepting new jobs but waiting for existing jobs to successfully complete. `SIGINT` (old existing behavior): Notify provisioner daemons to cancel in-flight jobs, wait 5s for jobs to be exited, then force quit. `SIGKILL`: Untouched from before, will force-quit.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,24 @@ import ( | |
"syscall" | ||
) | ||
|
||
// StopSignals are used to gracefully exit. | ||
// An example is exiting provisioner daemons but not canceling | ||
// jobs, allowing a successful and clean exit. | ||
var StopSignals = []os.Signal{ | ||
syscall.SIGTERM, | ||
} | ||
|
||
// InterruptSignals are used to less gracefully exit. | ||
// An example is canceling a job, waiting for a timeout, | ||
// and then exiting. | ||
var InterruptSignals = []os.Signal{ | ||
// SIGINT | ||
os.Interrupt, | ||
syscall.SIGTERM, | ||
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. This is a breaking change in all CLI commands that handle signals. They used to handle |
||
syscall.SIGHUP, | ||
} | ||
|
||
// KillSignals will force exit. | ||
var KillSignals = []os.Signal{ | ||
kylecarbs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// SIGKILL | ||
os.Kill, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ func (r *RootCmd) provisionerDaemonStart() *clibase.Cmd { | |
cliui.Errorf(inv.Stderr, "Unexpected error, shutting down server: %s\n", exitErr) | ||
} | ||
|
||
err = srv.Shutdown(ctx) | ||
err = srv.Shutdown(ctx, false) | ||
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. Here we're changing the default behavior for interrupt, and since we split interrupt and stop, we're also not handling 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. Fixed |
||
if err != nil { | ||
return xerrors.Errorf("shutdown: %w", 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.
I feel both methods are graceful, so perhaps a rename here is appropriate?
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 think that's reasonable.