Skip to content

Commit 959c97b

Browse files
Merge pull request #21906 from baude/issue21874
Use stop timeout of zero for system reset
2 parents 032cd5b + 0898b33 commit 959c97b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

libpod/reset.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ func (r *Runtime) Reset(ctx context.Context) error {
108108
return define.ErrRuntimeStopped
109109
}
110110

111-
var timeout *uint
111+
var timeout uint = 0
112112
pods, err := r.GetAllPods()
113113
if err != nil {
114114
return err
115115
}
116116
for _, p := range pods {
117-
if ctrs, err := r.RemovePod(ctx, p, true, true, timeout); err != nil {
117+
if ctrs, err := r.RemovePod(ctx, p, true, true, &timeout); err != nil {
118118
if errors.Is(err, define.ErrNoSuchPod) {
119119
continue
120120
}
@@ -133,7 +133,7 @@ func (r *Runtime) Reset(ctx context.Context) error {
133133
}
134134

135135
for _, c := range ctrs {
136-
if ctrs, _, err := r.RemoveContainerAndDependencies(ctx, c, true, true, timeout); err != nil {
136+
if ctrs, _, err := r.RemoveContainerAndDependencies(ctx, c, true, true, &timeout); err != nil {
137137
for ctr, err := range ctrs {
138138
logrus.Errorf("Error removing container %s: %v", ctr, err)
139139
}
@@ -163,7 +163,7 @@ func (r *Runtime) Reset(ctx context.Context) error {
163163
return err
164164
}
165165
for _, v := range volumes {
166-
if err := r.RemoveVolume(ctx, v, true, timeout); err != nil {
166+
if err := r.RemoveVolume(ctx, v, true, &timeout); err != nil {
167167
if errors.Is(err, define.ErrNoSuchVolume) {
168168
continue
169169
}

test/e2e/system_reset_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,16 @@ var _ = Describe("podman system reset", Serial, func() {
9292
ctrName := "testctr"
9393
port1 := GetPort()
9494
port2 := GetPort()
95-
session := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"})
95+
session := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "sleep", "inf"})
9696
session.WaitWithDefaultTimeout()
9797
Expect(session).Should(ExitCleanly())
9898

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

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

0 commit comments

Comments
 (0)