Skip to content
Closed
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions api/next.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4008,6 +4008,13 @@ file {
type: TYPE_BOOL
json_name: "all"
}
field {
name: "raw_signal"
number: 5
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "rawSignal"
}
}
message_type {
name: "ExecProcessRequest"
Expand Down
221 changes: 134 additions & 87 deletions api/services/tasks/v1/tasks.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/services/tasks/v1/tasks.proto
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ message KillRequest {
string exec_id = 2;
uint32 signal = 3;
bool all = 4;
string raw_signal = 5;
}

message ExecProcessRequest {
Expand Down
3 changes: 1 addition & 2 deletions cmd/containerd-stress/exec_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"strings"
"syscall"
"time"

"github.com/containerd/containerd"
Expand Down Expand Up @@ -75,7 +74,7 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
for {
select {
case <-tctx.Done():
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
logrus.WithError(err).Error("kill exec container's task")
}
<-statusC
Expand Down
2 changes: 1 addition & 1 deletion cmd/ctr/commands/signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal {
continue
}
logrus.Debug("forwarding signal ", s)
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal(s.String())); err != nil {
if errdefs.IsNotFound(err) {
logrus.WithError(err).Debugf("Not forwarding signal %s", s)
return
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ To do this we will simply call `Kill` on the task after waiting a couple of seco
```go
time.Sleep(3 * time.Second)

if err := task.Kill(ctx, syscall.SIGTERM); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGTERM")); err != nil {
return err
}

Expand Down Expand Up @@ -368,7 +368,7 @@ func redisExample() error {
time.Sleep(3 * time.Second)

// kill the process and get the exit status
if err := task.Kill(ctx, syscall.SIGTERM); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGTERM")); err != nil {
return err
}

Expand Down
14 changes: 7 additions & 7 deletions integration/client/container_checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"path/filepath"
"strings"
"sync"
"syscall"
"testing"

"github.com/containerd/containerd"
. "github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/oci"
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestCheckpointRestore(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}
<-statusC
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestCheckpointRestoreNewContainer(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}
<-statusC
Expand Down Expand Up @@ -407,7 +407,7 @@ func TestCheckpointLeaveRunning(t *testing.T) {
t.Fatalf("expected status %q but received %q", Running, status)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -466,7 +466,7 @@ func TestCheckpointRestoreWithImagePath(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}
<-statusC
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestCheckpointRestoreWithImagePath(t *testing.T) {
}

// we wrote the same thing after attach
if err := ntask.Kill(ctx, syscall.SIGKILL); err != nil {
if err := ntask.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}
<-statusC
Expand Down Expand Up @@ -607,7 +607,7 @@ func TestCheckpointOnPauseStatus(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down
21 changes: 11 additions & 10 deletions integration/client/container_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

"github.com/containerd/cgroups"
cgroupsv2 "github.com/containerd/cgroups/v2"
"github.com/containerd/containerd"
. "github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/containers"
Expand Down Expand Up @@ -152,7 +153,7 @@ func TestTaskUpdate(t *testing.T) {
t.Errorf("expected memory limit to be set to %d but received %d", limit, stat.Memory.Usage.Limit)
}
}
if err := task.Kill(ctx, unix.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -231,7 +232,7 @@ func TestShimInCgroup(t *testing.T) {
t.Errorf("created cgroup should have at least one process inside: %d", len(processes))
}
}
if err := task.Kill(ctx, unix.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -282,7 +283,7 @@ func TestShimDoesNotLeakPipes(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -386,7 +387,7 @@ func TestDaemonReconnectsToShimIOPipesOnRestart(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -873,7 +874,7 @@ func TestContainerAttachProcess(t *testing.T) {

wg.Wait()

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Error(err)
}

Expand Down Expand Up @@ -951,7 +952,7 @@ func TestContainerLoadUnexistingProcess(t *testing.T) {
t.Fatalf("an error of type NotFound should have been returned when loading a process that does not exist, got %#v instead ", err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Error(err)
}

Expand Down Expand Up @@ -1076,7 +1077,7 @@ func TestContainerKillAll(t *testing.T) {
t.Fatal(err)
}

if err := task.Kill(ctx, syscall.SIGKILL, WithKillAll); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL"), WithKillAll); err != nil {
t.Error(err)
}

Expand Down Expand Up @@ -1154,7 +1155,7 @@ func TestDaemonRestartWithRunningShim(t *testing.T) {
t.Error(err)
}

if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1510,7 +1511,7 @@ func TestBindLowPortNonOpt(t *testing.T) {
}
go func() {
time.Sleep(2 * time.Second)
task.Kill(ctx, unix.SIGTERM)
task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGTERM"))
}()
status := <-statusC
code, _, err := status.Result()
Expand Down Expand Up @@ -1623,7 +1624,7 @@ func TestShimOOMScore(t *testing.T) {
}
}

if err := task.Kill(ctx, unix.SIGKILL); err != nil {
if err := task.Kill(ctx, 0, containerd.WithKillRawSignal("SIGKILL")); err != nil {
t.Fatal(err)
}

Expand Down
Loading