fix: backend not reachable should be more descriptive (#13634)

This commit is contained in:
Harshavardhana 2021-11-10 22:33:17 -08:00 committed by GitHub
parent 5acc8c0134
commit 68c5ad83fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 5 deletions

View File

@ -1362,8 +1362,8 @@ var errorCodes = errorCodeMap{
},
ErrBackendDown: {
Code: "XMinioBackendDown",
Description: "Object storage backend is unreachable",
HTTPStatusCode: http.StatusServiceUnavailable,
Description: "Remote backend is unreachable",
HTTPStatusCode: http.StatusBadRequest,
},
ErrIncorrectContinuationToken: {
Code: "InvalidArgument",
@ -2129,6 +2129,11 @@ func toAPIError(ctx context.Context, err error) APIError {
}
}
if apiErr.Code == "XMinioBackendDown" {
apiErr.Description = fmt.Sprintf("%s (%v)", apiErr.Description, err)
return apiErr
}
if apiErr.Code == "InternalError" {
// If we see an internal error try to interpret
// any underlying errors if possible depending on

View File

@ -287,7 +287,7 @@ func ErrorRespToObjectError(err error, params ...string) error {
}
if xnet.IsNetworkOrHostDown(err, false) {
return BackendDown{}
return BackendDown{Err: err.Error()}
}
minioErr, ok := err.(minio.ErrorResponse)

View File

@ -645,10 +645,12 @@ func (e UnsupportedMetadata) Error() string {
}
// BackendDown is returned for network errors or if the gateway's backend is down.
type BackendDown struct{}
type BackendDown struct {
Err string
}
func (e BackendDown) Error() string {
return "Backend down"
return e.Err
}
// isErrBucketNotFound - Check if error type is BucketNotFound.

View File

@ -50,6 +50,10 @@ func checkWarmBackend(ctx context.Context, w WarmBackend) error {
var empty bytes.Reader
rv, err := w.Put(ctx, probeObject, &empty, 0)
if err != nil {
switch err.(type) {
case BackendDown:
return err
}
return tierPermErr{
Op: tierPut,
Err: err,
@ -58,6 +62,10 @@ func checkWarmBackend(ctx context.Context, w WarmBackend) error {
_, err = w.Get(ctx, probeObject, rv, WarmBackendGetOpts{})
if err != nil {
switch err.(type) {
case BackendDown:
return err
}
switch {
case isErrBucketNotFound(err):
return errTierBucketNotFound
@ -72,6 +80,10 @@ func checkWarmBackend(ctx context.Context, w WarmBackend) error {
}
if err = w.Remove(ctx, probeObject, rv); err != nil {
switch err.(type) {
case BackendDown:
return err
}
return tierPermErr{
Op: tierDelete,
Err: err,