-
Notifications
You must be signed in to change notification settings - Fork 561
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
Fix: inspect multiple networks stops at first inspect fail #1870
Conversation
d1f3a24
to
6c43b42
Compare
cmd/nerdctl/network_inspect.go
Outdated
|
||
walker := netwalker.NetworkWalker{ | ||
Client: e, | ||
OnFound: func(ctx context.Context, found netwalker.Found) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we need to check if found.MatchCount == 1
and return error if not. Otherwise a prefix (e.g., nerdctl network inspect a
) corresponding to multiple ids will print all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ce40a8b
to
4bd3de9
Compare
cmd/nerdctl/network_inspect.go
Outdated
if err != nil { | ||
return err | ||
} | ||
return formatter.FormatSlice(format, cmd.OutOrStdout(), result) | ||
for _, e := range errs { | ||
logrus.Errorln(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logrus.WithError(err).Errorf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logrus.WithError(err).Errorf
PTAL
cmd/nerdctl/network_inspect.go
Outdated
} | ||
|
||
// compatible with docker | ||
// ExitCodeError is to allow the program to exit with status code 1 without outputting an error message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not logrus print log anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would not logrus print log anyway?
sorry, i can't get your point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! I think this comment does not make sense; since you will probably log an error when it occurs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment removed
bdf3e25
to
b0f5ee5
Compare
4fd4a21
to
aab0d95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some nits, otherwise LGTM, thanks
cmd/nerdctl/network_inspect.go
Outdated
n, err := walker.Walk(cmd.Context(), name) | ||
if err != nil { | ||
errs = append(errs, err) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this continue
is not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/nerdctl/network_inspect.go
Outdated
for _, err := range errs { | ||
logrus.Error(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this can be moved into the if len(errs) > 0
since they're all code only related to errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
6dcfbf2
to
4901595
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
87aa240
to
38e69b2
Compare
8541625
to
9791701
Compare
56415e5
to
f836460
Compare
5503928
to
5a19d30
Compare
Signed-off-by: yaozhenxiu <946666800@qq.com>
5a19d30
to
ea9ac34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
n: aliased to sudo nerdctl
~ n network ls NETWORK ID NAME FILE k8s-pod-network /etc/cni/net.d/10-calico.conflist 44262d4ba0d3 58de8b120c68 /etc/cni/net.d/nerdctl-58de8b120c68.conflist 17f29b073143 bridge /etc/cni/net.d/nerdctl-bridge.conflist f9d6cec6deab deleteme /etc/cni/net.d/nerdctl-deleteme.conflist 58de8b120c68 nerdctl_default /etc/cni/net.d/nerdctl-nerdctl_default.conflist 84584c571686 xiu_default /etc/cni/net.d/nerdctl-xiu_default.conflist host none
1、Add the option to inspect a network by id
before:
~ n network inspect f9d6cec6deab FATA[0000] no such network: f9d6cec6deab
after:
2、Fix: inspect multiple networks stops at first inspect fail
before:
after:
Signed-off-by: yaozhenxiu 946666800@qq.com