Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/27316.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
qemu: fixes graceful_shutdown to wait kill_timeout before signalling process
```
22 changes: 20 additions & 2 deletions drivers/qemu/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,26 @@ func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) e

// Attempt a graceful shutdown only if it was configured in the job
if handle.monitorPath != "" {
if err := sendQemuShutdown(d.logger, handle.monitorPath, handle.pid); err != nil {
d.logger.Debug("error sending graceful shutdown ", "pid", handle.pid, "error", err)
err := sendQemuShutdown(d.logger, handle.monitorPath, handle.pid)
if err == nil {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()
out:
for {
select {
case <-ctx.Done():
d.logger.Error("graceful shutdown", "pid", handle.pid, "timeout after", timeout)
break out
case <-ticker.C:
if handle.procState != drivers.TaskStateRunning {
break out
}
}
}
} else {
d.logger.Debug("error sending graceful shutdown", "pid", handle.pid, "error", err)
}
} else {
d.logger.Debug("monitor socket is empty, forcing shutdown")
Expand Down