mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
runc list: fix error reporting for non-existent root
The idea of commit d1fca8e was right (report errors for non-existent
root, unless using the default root dir) but the logic was inverted.
Fix the logic.
Test case for default root requires non-existent /root/runc, which is
not always possible.
Reported-by: RedMakeUp <girafeeblue@gmail.com>
Co-authored-by: RedMakeUp <girafeeblue@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -119,7 +119,7 @@ func getContainers(cmd *cli.Command) ([]containerState, error) {
|
||||
root := cmd.String("root")
|
||||
list, err := os.ReadDir(root)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) && cmd.IsSet("root") {
|
||||
if errors.Is(err, os.ErrNotExist) && !cmd.IsSet("root") {
|
||||
// Ignore non-existing default root directory
|
||||
// (no containers created yet).
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user