Skip to content

Commit

Permalink
Merge pull request #21906 from baude/issue21874
Browse files Browse the repository at this point in the history
Use stop timeout of zero for system reset
  • Loading branch information
openshift-merge-bot[bot] authored Mar 1, 2024
2 parents 032cd5b + 0898b33 commit 959c97b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions libpod/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ func (r *Runtime) Reset(ctx context.Context) error {
return define.ErrRuntimeStopped
}

var timeout *uint
var timeout uint = 0
pods, err := r.GetAllPods()
if err != nil {
return err
}
for _, p := range pods {
if ctrs, err := r.RemovePod(ctx, p, true, true, timeout); err != nil {
if ctrs, err := r.RemovePod(ctx, p, true, true, &timeout); err != nil {
if errors.Is(err, define.ErrNoSuchPod) {
continue
}
Expand All @@ -133,7 +133,7 @@ func (r *Runtime) Reset(ctx context.Context) error {
}

for _, c := range ctrs {
if ctrs, _, err := r.RemoveContainerAndDependencies(ctx, c, true, true, timeout); err != nil {
if ctrs, _, err := r.RemoveContainerAndDependencies(ctx, c, true, true, &timeout); err != nil {
for ctr, err := range ctrs {
logrus.Errorf("Error removing container %s: %v", ctr, err)
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func (r *Runtime) Reset(ctx context.Context) error {
return err
}
for _, v := range volumes {
if err := r.RemoveVolume(ctx, v, true, timeout); err != nil {
if err := r.RemoveVolume(ctx, v, true, &timeout); err != nil {
if errors.Is(err, define.ErrNoSuchVolume) {
continue
}
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/system_reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ var _ = Describe("podman system reset", Serial, func() {
ctrName := "testctr"
port1 := GetPort()
port2 := GetPort()
session := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"})
session := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "sleep", "inf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())

// run system reset on a container that is running
// set a timeout of 9 seconds, which tests that reset is using the timeout
// of zero and forceable killing containers with no wait.
// #21874
reset := podmanTest.Podman([]string{"system", "reset", "--force"})
reset.WaitWithDefaultTimeout()
reset.WaitWithTimeout(9)
Expect(reset).Should(ExitCleanly())

session2 := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"})
Expand Down

0 comments on commit 959c97b

Please sign in to comment.