mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #23581 from Luap99/remote-ignore
remote: fix invalid --cidfile + --ignore
This commit is contained in:
@ -405,6 +405,9 @@ func Stop(ctx context.Context, nameOrID string, options *StopOptions) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
if options.GetIgnore() && response.StatusCode == http.StatusNotFound {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return response.Process(nil)
|
return response.Process(nil)
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,13 @@ func getContainersAndInputByContext(contextWithConnection context.Context, all,
|
|||||||
if all && len(namesOrIDs) > 0 {
|
if all && len(namesOrIDs) > 0 {
|
||||||
return nil, nil, errors.New("cannot look up containers and all")
|
return nil, nil, errors.New("cannot look up containers and all")
|
||||||
}
|
}
|
||||||
|
// short cut if not all, not filters and no names are given. This can happen with
|
||||||
|
// --ignore and --cidfile, https://github.com/containers/podman/issues/23554.
|
||||||
|
// In this case we have to do nothting and not even have to do a request
|
||||||
|
if !all && len(filters) == 0 && len(namesOrIDs) == 0 {
|
||||||
|
return nil, nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
options := new(containers.ListOptions).WithAll(true).WithSync(true).WithFilters(filters)
|
options := new(containers.ListOptions).WithAll(true).WithSync(true).WithFilters(filters)
|
||||||
allContainers, err := containers.List(contextWithConnection, options)
|
allContainers, err := containers.List(contextWithConnection, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -110,8 +110,15 @@ load helpers
|
|||||||
run_podman 125 stop --cidfile=$nosuchfile
|
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"
|
is "$output" "Error: reading CIDFile: open $nosuchfile: no such file or directory" "podman stop with missing cidfile, without --ignore"
|
||||||
|
|
||||||
|
# create a container to reproduce (#23554)
|
||||||
|
run_podman run -d $IMAGE sleep inf
|
||||||
|
cid="$output"
|
||||||
|
|
||||||
|
# Important for (#23554) that there is no output here
|
||||||
run_podman stop --cidfile=$nosuchfile --ignore
|
run_podman stop --cidfile=$nosuchfile --ignore
|
||||||
is "$output" "" "podman stop with missing cidfile, with --ignore"
|
is "$output" "" "podman stop with missing cidfile, with --ignore (empty output)"
|
||||||
|
|
||||||
|
run_podman rm -f -t0 $cid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user