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: Deleting multiple networks stops at first delete fail #1618
Conversation
@fahedouch see #1592 |
cmd/nerdctl/network_rm.go
Outdated
} else if n == 0 { | ||
return fmt.Errorf("no such network %s", name) | ||
fmt.Fprintf(cmd.OutOrStdout(), "Error: No such network: %s\n", name) |
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.
please use logrus.Error(err)
or logrus.WithError(err).Errorf("failed to ... %s", var)
to set the Error level for these logs
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
Please squash commits |
Done |
cmd/nerdctl/network_rm.go
Outdated
@@ -93,14 +94,17 @@ func networkRmAction(cmd *cobra.Command, args []string) error { | |||
|
|||
for _, name := range args { | |||
if name == "host" || name == "none" { | |||
return fmt.Errorf("pseudo network %q cannot be removed", name) | |||
logrus.Errorf("pseudo network %q cannot be removed\n", name) |
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.
\n
is useless ( it is not interpreted)
cc @yzxiu
|
ae16016
to
7248cda
Compare
@fahedouch PTAL |
|
||
// compatible with docker | ||
if status != 0 { | ||
return ExitCodeError{ |
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.
return errors.New(..)
is enough
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.
ExitCodeError
is to allow the program to exit with status code 1 without outputting an error message.
if return errors.New(..)
, will output redundant error lines, like
ERRO[0000] network "deleteme" is in use by container ["182ea93ddc15b187419a05cb10a4b8d3cdace1fc2b8592a10b345396ce91edc7"]
FATA[0000]
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.
There is no error message needs to be output here(err
is always nil
), but the program needs to exit with status 1, so use ExitCodeError
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.
ok got the point, can we change status
by code
( more explicit I guess) and error :nil
is useless
return ExitCodeError{ | |
return ExitCodeError{ | |
exitCode: code, | |
} |
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.
ok got the point, can we change
status
bycode
( more explicit I guess) anderror :nil
is useless
Done
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.
ExitCodeError
is to allow the program to exit with status code 1 without outputting an error message.if return
errors.New(..)
, will output redundant error lines, likeERRO[0000] network "deleteme" is in use by container ["182ea93ddc15b187419a05cb10a4b8d3cdace1fc2b8592a10b345396ce91edc7"] FATA[0000]
Could you add that in the code comment?
Or just print warnings for errs[0]...errs[n-2] and return errs[n-1]?
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.
ExitCodeError
is to allow the program to exit with status code 1 without outputting an error message.
Add that in the code comment, like this?
// compatible with docker
// ExitCodeError is to allow the program to exit with status code 1 without outputting an error message.
if code != 0 {
return ExitCodeError{
exitCode: code,
}
}
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.
ExitCodeError
is to allow the program to exit with status code 1 without outputting an error message.
if returnerrors.New(..)
, will output redundant error lines, likeERRO[0000] network "deleteme" is in use by container ["182ea93ddc15b187419a05cb10a4b8d3cdace1fc2b8592a10b345396ce91edc7"] FATA[0000]Could you add that in the code comment? Or just print warnings for errs[0]...errs[n-2] and return errs[n-1]?
return err
will result in two different outputs, like ERRO[0000]...
and FATA[0000]...
I think using ExitCodeError
here is a better choice
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.
Add that in the code comment, like this?
Yes
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.
Add that in the code comment, like this?
Yes
Done
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
Signed-off-by: yaozhenxiu <946666800@qq.com>
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
fixing #1587
Signed-off-by: yaozhenxiu 946666800@qq.com