Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit(1) when killing a stopped/unknown container #45

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package main
import (
"context"
"fmt"
"os"
"strings"
"syscall"

Expand Down Expand Up @@ -74,7 +75,7 @@ func killAction(clicontext *cli.Context) error {
if err := killContainer(ctx, clicontext, client, shortID, ID, signal); err != nil {
if errdefs.IsNotFound(err) {
fmt.Fprintf(clicontext.App.ErrWriter, "Error response from daemon: Cannot kill container: %s: No such container: %s\n", shortID, shortID)
return nil
os.Exit(1)
}
return err
}
Expand Down Expand Up @@ -104,7 +105,7 @@ func killContainer(ctx context.Context, clicontext *cli.Context, client *contain
switch status.Status {
case containerd.Created, containerd.Stopped:
fmt.Fprintf(clicontext.App.ErrWriter, "Error response from daemon: Cannot kill container: %s: Container %s is not running\n", shortID, shortID)
return nil
os.Exit(1)
case containerd.Paused, containerd.Pausing:
paused = true
default:
Expand Down