-
Notifications
You must be signed in to change notification settings - Fork 553
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
mc heal
and mc mirror
should respond with exit code (0) incase of errors
#2543
Conversation
mc heal
should respond with os.exit(0) incase of errorsmc heal
should respond with error code (0) incase of errors
mc heal
should respond with error code (0) incase of errorsmc heal
should respond with exit code (0) incase of 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.
LGTM
@Praveenrajmani Is this still WIP? |
Yes . i thought of fixing the |
302db84
to
635666a
Compare
Codecov Report
@@ Coverage Diff @@
## master #2543 +/- ##
=======================================
Coverage 10.63% 10.63%
=======================================
Files 106 106
Lines 10703 10703
=======================================
Hits 1138 1138
Misses 9415 9415
Partials 150 150
Continue to review full report at Codecov.
|
mc heal
should respond with exit code (0) incase of errorsmc heal
and mc mirror
should respond with exit code (0) incase of errors
Done and ready for review |
e69e385
to
624a074
Compare
cmd/mirror-main.go
Outdated
@@ -587,6 +591,9 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc | |||
} | |||
} | |||
if err != nil { | |||
if err.ToGoError().Error() == ErrBucketDoNotExist.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.
@Praveenrajmani if you see little below, the code already returns err.Trace()
for errors that we don't ignore.
What's happening is that the code is always running case overwriteNotAllowedErr
even for bucket is not found error.
The reason is that overwriteNotAllowedErr
satisfies error interface that's why that switch case is always executed.
So to avoid this behavior, you can apply the following diff:
diff --git a/cmd/typed-errors.go b/cmd/typed-errors.go
index fd1590e8..50665be4 100644
--- a/cmd/typed-errors.go
+++ b/cmd/typed-errors.go
@@ -96,11 +96,13 @@ var errInvalidTarget = func(URL string) *probe.Error {
return probe.NewError(invalidTargetErr(errors.New(msg))).Untrace()
}
-type overwriteNotAllowedErr error
+type overwriteNotAllowedErr struct {
+ error
+}
var errOverWriteNotAllowed = func(URL string) *probe.Error {
msg := "Overwrite not allowed for `" + URL + "`. Use `--overwrite` to override this behavior."
- return probe.NewError(overwriteNotAllowedErr(errors.New(msg)))
+ return probe.NewError(overwriteNotAllowedErr{errors.New(msg)})
}
type sourceIsDirErr error
So instead of adding this code, you can modify overwriteNotAllowedErr from interface to structure:
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.
Yes overwriteNotAllowedErr
in switch case acts as default since it is an interface that returns an error
, So the idea was to string check.
This seems better though , will change it
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.
One small change needed
cmd/mirror-main.go
Outdated
@@ -587,6 +591,9 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc | |||
} | |||
} | |||
if err != nil { | |||
if err.ToGoError().Error() == ErrBucketDoNotExist.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.
This is not correct style expected style is to avoid string matching instead rely on types.
switch err.ToGoError().(type) {
case BucketDoesNotExist:
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.
Yes will change it to a struct with a error as Anis suggested
respond with os.exit(0) incase of errors Fixes minio#2534 minio#2474
624a074
to
3c0f142
Compare
Changes addressed .. Ready for re-review |
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.
LGTM
mc heal will now respond with proper error on
client.Heal
Will also add the fix formc mirror
(#2474)Tested By
./mc admin heal --debug -r none; echo $?
./mc mirror --quiet foo play/testbucket; echo $?
Fixes #2534
Fixes #2474