Merge pull request #21906 from baude/issue21874

Use stop timeout of zero for system reset
This commit is contained in:
openshift-merge-bot[bot] 2024-03-01 18:12:56 +00:00 committed by GitHub
commit 959c97b035
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -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
}
@ -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)
}
@ -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
}

View File

@ -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"})