Merge pull request #21906 from baude/issue21874
Use stop timeout of zero for system reset
This commit is contained in:
commit
959c97b035
|
|
@ -108,13 +108,13 @@ func (r *Runtime) Reset(ctx context.Context) error {
|
||||||
return define.ErrRuntimeStopped
|
return define.ErrRuntimeStopped
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeout *uint
|
var timeout uint = 0
|
||||||
pods, err := r.GetAllPods()
|
pods, err := r.GetAllPods()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, p := range pods {
|
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) {
|
if errors.Is(err, define.ErrNoSuchPod) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -133,7 +133,7 @@ func (r *Runtime) Reset(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range ctrs {
|
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 {
|
for ctr, err := range ctrs {
|
||||||
logrus.Errorf("Error removing container %s: %v", ctr, err)
|
logrus.Errorf("Error removing container %s: %v", ctr, err)
|
||||||
}
|
}
|
||||||
|
|
@ -163,7 +163,7 @@ func (r *Runtime) Reset(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, v := range volumes {
|
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) {
|
if errors.Is(err, define.ErrNoSuchVolume) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,12 +92,16 @@ var _ = Describe("podman system reset", Serial, func() {
|
||||||
ctrName := "testctr"
|
ctrName := "testctr"
|
||||||
port1 := GetPort()
|
port1 := GetPort()
|
||||||
port2 := 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()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
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 := podmanTest.Podman([]string{"system", "reset", "--force"})
|
||||||
reset.WaitWithDefaultTimeout()
|
reset.WaitWithTimeout(9)
|
||||||
Expect(reset).Should(ExitCleanly())
|
Expect(reset).Should(ExitCleanly())
|
||||||
|
|
||||||
session2 := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"})
|
session2 := podmanTest.Podman([]string{"run", "--name", ctrName, "-p", fmt.Sprintf("%d:%d", port1, port2), "-d", ALPINE, "top"})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue