mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
podman stop --cidfile missing --ignore
Podman should ignore failures to find a cidfile when stoping the container if the user specified --ignore Fixes: https://github.com/containers/podman/issues/19546 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -2,6 +2,7 @@ package containers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@ -110,6 +111,9 @@ func stop(cmd *cobra.Command, args []string) error {
|
||||
for _, cidFile := range stopCidFiles {
|
||||
content, err := os.ReadFile(cidFile)
|
||||
if err != nil {
|
||||
if stopOptions.Ignore && errors.Is(err, os.ErrNotExist) {
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("reading CIDFile: %w", err)
|
||||
}
|
||||
id := strings.Split(string(content), "\n")[0]
|
||||
|
@ -20,6 +20,8 @@ Remove all containers. Can be used in conjunction with **-f** as well.
|
||||
|
||||
@@option cidfile.read
|
||||
|
||||
Command does not fail when *file* is missing and user specified --ignore.
|
||||
|
||||
#### **--depend**
|
||||
|
||||
Remove selected container and recursively remove all containers that depend on it.
|
||||
|
@ -23,6 +23,8 @@ Stop all running containers. This does not include paused containers.
|
||||
|
||||
@@option cidfile.read
|
||||
|
||||
Command does not fail when *file* is missing and user specified --ignore.
|
||||
|
||||
#### **--filter**, **-f**=*filter*
|
||||
|
||||
Filter what containers are going to be stopped.
|
||||
|
@ -85,6 +85,13 @@ load helpers
|
||||
|
||||
run_podman stop --ignore $name
|
||||
is "$output" "" "podman stop nonexistent container, with --ignore"
|
||||
|
||||
nosuchfile=$PODMAN_TMPDIR/no-such-file
|
||||
run_podman 125 stop --cidfile=$nosuchfile
|
||||
is "$output" "Error: reading CIDFile: open $nosuchfile: no such file or directory" "podman stop with missing cidfile, without --ignore"
|
||||
|
||||
run_podman stop --cidfile=$nosuchfile --ignore
|
||||
is "$output" "" "podman stop with missing cidfile, with --ignore"
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user