Skip to content

Commit

Permalink
Merge pull request #23457 from Luap99/play-kube-cleanup
Browse files Browse the repository at this point in the history
fix network cleanup flake in play kube
  • Loading branch information
mheon authored Jul 31, 2024
2 parents ebc7deb + 4c3531a commit 96eb637
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions libpod/pod_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,21 @@ func (p *Pod) stopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m
// Can't batch these without forcing Stop() to hold the
// lock for the full duration of the timeout.
// We probably don't want to do that.
var err error
if timeout > -1 {
if err := c.StopWithTimeout(uint(timeout)); err != nil {
return err
}
err = c.StopWithTimeout(uint(timeout))
} else {
if err := c.Stop(); err != nil {
return err
}
err = c.Stop()
}
if err != nil && !errors.Is(err, define.ErrCtrStateInvalid) && !errors.Is(err, define.ErrCtrStopped) {
return err
}

if cleanup {
return c.Cleanup(ctx)
err := c.Cleanup(ctx)
if err != nil && !errors.Is(err, define.ErrCtrStateInvalid) && !errors.Is(err, define.ErrCtrStopped) {
return err
}
}

return nil
Expand All @@ -196,9 +199,6 @@ func (p *Pod) stopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m
// Get returned error for every container we worked on
for id, channel := range ctrErrChan {
if err := <-channel; err != nil {
if errors.Is(err, define.ErrCtrStateInvalid) || errors.Is(err, define.ErrCtrStopped) {
continue
}
ctrErrors[id] = err
}
}
Expand Down

0 comments on commit 96eb637

Please sign in to comment.