|
17 | 17 | package v2 |
18 | 18 |
|
19 | 19 | import ( |
| 20 | + "bytes" |
20 | 21 | "context" |
21 | 22 | "strings" |
22 | 23 |
|
23 | 24 | eventstypes "github.com/containerd/containerd/api/events" |
24 | 25 | "github.com/containerd/containerd/events/exchange" |
| 26 | + "github.com/containerd/containerd/log" |
25 | 27 | "github.com/containerd/containerd/runtime" |
26 | 28 | client "github.com/containerd/containerd/runtime/v2/shim" |
27 | 29 | "github.com/containerd/containerd/runtime/v2/task" |
@@ -73,16 +75,26 @@ func (b *binary) Start(ctx context.Context) (*shim, error) { |
73 | 75 | } |
74 | 76 |
|
75 | 77 | func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) { |
| 78 | + log.G(ctx).Info("cleaning up dead shim") |
76 | 79 | cmd, err := client.Command(ctx, b.runtime, b.containerdAddress, b.bundle.Path, "-id", b.bundle.ID, "delete") |
77 | 80 | if err != nil { |
78 | 81 | return nil, err |
79 | 82 | } |
80 | | - out, err := cmd.CombinedOutput() |
81 | | - if err != nil { |
82 | | - return nil, errors.Wrapf(err, "%s", out) |
| 83 | + var ( |
| 84 | + out = bytes.NewBuffer(nil) |
| 85 | + errb = bytes.NewBuffer(nil) |
| 86 | + ) |
| 87 | + cmd.Stdout = out |
| 88 | + cmd.Stderr = errb |
| 89 | + if err := cmd.Run(); err != nil { |
| 90 | + return nil, errors.Wrapf(err, "%s", errb.String()) |
| 91 | + } |
| 92 | + s := errb.String() |
| 93 | + if s != "" { |
| 94 | + log.G(ctx).Warnf("cleanup warnings %s", s) |
83 | 95 | } |
84 | 96 | var response task.DeleteResponse |
85 | | - if err := response.Unmarshal(out); err != nil { |
| 97 | + if err := response.Unmarshal(out.Bytes()); err != nil { |
86 | 98 | return nil, err |
87 | 99 | } |
88 | 100 | if err := b.bundle.Delete(); err != nil { |
|
0 commit comments