Skip to content

Commit 262a1b9

Browse files
committed
ps: continue on ErrNotFound
To deflake TestRunExitCode ``` === CONT TestRunExitCode run_test.go:113: assertion failed: 0 (int) != 1 (res.ExitCode int): time="2022-01-12T19:35:26+09:00" level=fatal msg="container \"c6476c53c0a2e092c68fb5a7faf1724eee4cb10d227 d7c6507c7766b65eaa4aa\" in namespace \"nerdctl-test\": not found" ``` Signed-off-by: Akihiro Suda <[email protected]>
1 parent ed8270f commit 262a1b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/nerdctl/ps.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ import (
3030
"time"
3131

3232
"github.com/containerd/containerd"
33+
"github.com/containerd/containerd/errdefs"
3334
"github.com/containerd/nerdctl/pkg/formatter"
3435
"github.com/containerd/nerdctl/pkg/labels"
3536
"github.com/containerd/nerdctl/pkg/labels/k8slabels"
37+
"github.com/sirupsen/logrus"
3638

3739
"github.com/spf13/cobra"
3840
)
@@ -158,11 +160,19 @@ func printContainers(ctx context.Context, cmd *cobra.Command, containers []conta
158160
for _, c := range containers {
159161
info, err := c.Info(ctx, containerd.WithoutRefreshedMetadata)
160162
if err != nil {
163+
if errdefs.IsNotFound(err) {
164+
logrus.Warn(err)
165+
continue
166+
}
161167
return err
162168
}
163169

164170
spec, err := c.Spec(ctx)
165171
if err != nil {
172+
if errdefs.IsNotFound(err) {
173+
logrus.Warn(err)
174+
continue
175+
}
166176
return err
167177
}
168178

0 commit comments

Comments
 (0)