fix(container): check context before select in Stop to fix flaky test
Stop() now checks ctx.Err() before entering the select block. When a pre-cancelled context is passed, the select could non-deterministically choose <-done over <-ctx.Done() if the process had already exited, causing TestLinuxKitManager_Stop_Good_ContextCancelled to fail on CI. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
08aca2958b
commit
a1cd19aa02
1 changed files with 6 additions and 0 deletions
|
|
@ -258,6 +258,12 @@ func (m *LinuxKitManager) Stop(ctx context.Context, id string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Honour already-cancelled contexts before waiting
|
||||
if err := ctx.Err(); err != nil {
|
||||
_ = process.Signal(syscall.SIGKILL)
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait for graceful shutdown with timeout
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue