mirror of
https://github.com/minio/minio.git
synced 2024-12-23 21:55:53 -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: {
|
||||
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
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user