Add support for signals.

This commit is contained in:
Shishir Mahajan 2020-05-12 18:01:54 -07:00
parent eeddc63f8b
commit a633f332b2
No known key found for this signature in database
GPG Key ID: D41782E7688DEC4A
2 changed files with 6 additions and 6 deletions

View File

@ -479,9 +479,9 @@ func (d *Driver) SignalTask(taskID string, signal string) error {
return drivers.ErrTaskNotFound
}
// The given signal must be forwarded to the target taskID. If this plugin
// doesn't support receiving signals (capability SendSignals is set to
// false) you can just return nil.
// The given signal will be forwarded to the target taskID.
// Please checkout https://github.com/hashicorp/consul-template/blob/master/signals/signals_unix.go
// for a list of supported signals.
sig := os.Interrupt
if s, ok := signals.SignalLookup[signal]; ok {
sig = s
@ -489,7 +489,7 @@ func (d *Driver) SignalTask(taskID string, signal string) error {
d.logger.Warn("unknown signal to send to task, using SIGINT instead", "signal", signal, "task_id", handle.taskConfig.ID)
}
return handle.signal(sig)
return handle.signal(d.ctxContainerd, sig)
}
// ExecTask returns the result of executing the given command inside a task.

View File

@ -81,6 +81,6 @@ func (h *taskHandle) stats(ctx context.Context, interval time.Duration) (<-chan
return nil, nil
}
func (h *taskHandle) signal(sig os.Signal) error {
return nil
func (h *taskHandle) signal(ctxContainerd context.Context, sig os.Signal) error {
return h.task.Kill(ctxContainerd, sig.(syscall.Signal))
}