mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
fix: backend not reachable should be more descriptive (#13634)
This commit is contained in:
parent
5acc8c0134
commit
68c5ad83fb
@ -1362,8 +1362,8 @@ var errorCodes = errorCodeMap{
|
|||||||
},
|
},
|
||||||
ErrBackendDown: {
|
ErrBackendDown: {
|
||||||
Code: "XMinioBackendDown",
|
Code: "XMinioBackendDown",
|
||||||
Description: "Object storage backend is unreachable",
|
Description: "Remote backend is unreachable",
|
||||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
},
|
},
|
||||||
ErrIncorrectContinuationToken: {
|
ErrIncorrectContinuationToken: {
|
||||||
Code: "InvalidArgument",
|
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 apiErr.Code == "InternalError" {
|
||||||
// If we see an internal error try to interpret
|
// If we see an internal error try to interpret
|
||||||
// any underlying errors if possible depending on
|
// any underlying errors if possible depending on
|
||||||
|
@ -287,7 +287,7 @@ func ErrorRespToObjectError(err error, params ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if xnet.IsNetworkOrHostDown(err, false) {
|
if xnet.IsNetworkOrHostDown(err, false) {
|
||||||
return BackendDown{}
|
return BackendDown{Err: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
minioErr, ok := err.(minio.ErrorResponse)
|
minioErr, ok := err.(minio.ErrorResponse)
|
||||||
|
@ -645,10 +645,12 @@ func (e UnsupportedMetadata) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BackendDown is returned for network errors or if the gateway's backend is down.
|
// 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 {
|
func (e BackendDown) Error() string {
|
||||||
return "Backend down"
|
return e.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
// isErrBucketNotFound - Check if error type is BucketNotFound.
|
// isErrBucketNotFound - Check if error type is BucketNotFound.
|
||||||
|
@ -50,6 +50,10 @@ func checkWarmBackend(ctx context.Context, w WarmBackend) error {
|
|||||||
var empty bytes.Reader
|
var empty bytes.Reader
|
||||||
rv, err := w.Put(ctx, probeObject, &empty, 0)
|
rv, err := w.Put(ctx, probeObject, &empty, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
switch err.(type) {
|
||||||
|
case BackendDown:
|
||||||
|
return err
|
||||||
|
}
|
||||||
return tierPermErr{
|
return tierPermErr{
|
||||||
Op: tierPut,
|
Op: tierPut,
|
||||||
Err: err,
|
Err: err,
|
||||||
@ -58,6 +62,10 @@ func checkWarmBackend(ctx context.Context, w WarmBackend) error {
|
|||||||
|
|
||||||
_, err = w.Get(ctx, probeObject, rv, WarmBackendGetOpts{})
|
_, err = w.Get(ctx, probeObject, rv, WarmBackendGetOpts{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
switch err.(type) {
|
||||||
|
case BackendDown:
|
||||||
|
return err
|
||||||
|
}
|
||||||
switch {
|
switch {
|
||||||
case isErrBucketNotFound(err):
|
case isErrBucketNotFound(err):
|
||||||
return errTierBucketNotFound
|
return errTierBucketNotFound
|
||||||
@ -72,6 +80,10 @@ func checkWarmBackend(ctx context.Context, w WarmBackend) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = w.Remove(ctx, probeObject, rv); err != nil {
|
if err = w.Remove(ctx, probeObject, rv); err != nil {
|
||||||
|
switch err.(type) {
|
||||||
|
case BackendDown:
|
||||||
|
return err
|
||||||
|
}
|
||||||
return tierPermErr{
|
return tierPermErr{
|
||||||
Op: tierDelete,
|
Op: tierDelete,
|
||||||
Err: err,
|
Err: err,
|
||||||
|
Loading…
Reference in New Issue
Block a user