diff --git a/delete.go b/delete.go index d2e73a72a..52ca2390d 100644 --- a/delete.go +++ b/delete.go @@ -45,6 +45,7 @@ status of "ubuntu01" as "stopped" the following will delete resources held for }, }, Action: func(context *cli.Context) error { + hasError := false if !context.Args().Present() { return fmt.Errorf("runc: \"delete\" requires a minimum of 1 argument") } @@ -65,11 +66,13 @@ status of "ubuntu01" as "stopped" the following will delete resources held for } fmt.Fprintf(os.Stderr, "container %s is not exist\n", id) } + hasError = true continue } s, err := container.Status() if err != nil { fmt.Fprintf(os.Stderr, "status for %s: %v\n", id, err) + hasError = true continue } switch s { @@ -79,18 +82,25 @@ status of "ubuntu01" as "stopped" the following will delete resources held for err := killContainer(container) if err != nil { fmt.Fprintf(os.Stderr, "kill container %s: %v\n", id, err) + hasError = true } default: if context.Bool("force") { err := killContainer(container) if err != nil { fmt.Fprintf(os.Stderr, "kill container %s: %v\n", id, err) + hasError = true } } else { fmt.Fprintf(os.Stderr, "cannot delete container %s that is not stopped: %s\n", id, s) + hasError = true } } } + + if hasError { + return fmt.Errorf("one or more of the container deletions failed") + } return nil }, }