improve error message when remote target missing (#10412)

master
poornas 4 years ago committed by GitHub
parent fbd1c5f51a
commit 0037951b6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      cmd/api-errors.go
  2. 11
      cmd/bucket-targets.go
  3. 7
      cmd/object-api-errors.go

@ -109,6 +109,7 @@ const (
ErrReplicationDestinationNotFoundError ErrReplicationDestinationNotFoundError
ErrReplicationDestinationMissingLock ErrReplicationDestinationMissingLock
ErrReplicationTargetNotFoundError ErrReplicationTargetNotFoundError
ErrReplicationRemoteConnectionError
ErrBucketRemoteIdenticalToSource ErrBucketRemoteIdenticalToSource
ErrBucketRemoteAlreadyExists ErrBucketRemoteAlreadyExists
ErrBucketRemoteArnTypeInvalid ErrBucketRemoteArnTypeInvalid
@ -823,6 +824,11 @@ var errorCodes = errorCodeMap{
Description: "The replication target does not exist", Description: "The replication target does not exist",
HTTPStatusCode: http.StatusNotFound, HTTPStatusCode: http.StatusNotFound,
}, },
ErrReplicationRemoteConnectionError: {
Code: "XminioAdminReplicationRemoteConnectionError",
Description: "Remote service endpoint or target bucket not available",
HTTPStatusCode: http.StatusNotFound,
},
ErrBucketRemoteIdenticalToSource: { ErrBucketRemoteIdenticalToSource: {
Code: "XminioAdminRemoteIdenticalToSource", Code: "XminioAdminRemoteIdenticalToSource",
Description: "The remote target cannot be identical to source", Description: "The remote target cannot be identical to source",
@ -1906,6 +1912,8 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
apiErr = ErrReplicationDestinationMissingLock apiErr = ErrReplicationDestinationMissingLock
case BucketRemoteTargetNotFound: case BucketRemoteTargetNotFound:
apiErr = ErrReplicationTargetNotFoundError apiErr = ErrReplicationTargetNotFoundError
case BucketRemoteConnectionErr:
apiErr = ErrReplicationRemoteConnectionError
case BucketRemoteAlreadyExists: case BucketRemoteAlreadyExists:
apiErr = ErrBucketRemoteAlreadyExists apiErr = ErrBucketRemoteAlreadyExists
case BucketRemoteArnTypeInvalid: case BucketRemoteArnTypeInvalid:

@ -21,6 +21,7 @@ import (
"net/http" "net/http"
"sync" "sync"
minio "github.com/minio/minio-go/v7"
miniogo "github.com/minio/minio-go/v7" miniogo "github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials" "github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio/pkg/bucket/versioning" "github.com/minio/minio/pkg/bucket/versioning"
@ -91,13 +92,13 @@ func (sys *BucketTargetSys) SetTarget(ctx context.Context, bucket string, tgt *m
} }
vcfg, err := clnt.GetBucketVersioning(ctx, tgt.TargetBucket) vcfg, err := clnt.GetBucketVersioning(ctx, tgt.TargetBucket)
if err != nil { if err != nil {
if isErrBucketNotFound(err) { if minio.ToErrorResponse(err).Code == "NoSuchBucket" {
return BucketRemoteTargetNotFound{Bucket: tgt.TargetBucket} return BucketRemoteTargetNotFound{Bucket: tgt.TargetBucket}
} }
if vcfg.Status != string(versioning.Enabled) { return BucketRemoteConnectionErr{Bucket: tgt.TargetBucket}
return BucketReplicationTargetNotVersioned{Bucket: tgt.TargetBucket} }
} if vcfg.Status != string(versioning.Enabled) {
return err return BucketReplicationTargetNotVersioned{Bucket: tgt.TargetBucket}
} }
} }

@ -376,6 +376,13 @@ func (e BucketRemoteTargetNotFound) Error() string {
return "Remote target not found: " + e.Bucket return "Remote target not found: " + e.Bucket
} }
// BucketRemoteConnectionErr remote target connection failure.
type BucketRemoteConnectionErr GenericError
func (e BucketRemoteConnectionErr) Error() string {
return "Remote service endpoint or target bucket not available: " + e.Bucket
}
// BucketRemoteAlreadyExists remote already exists for this target type. // BucketRemoteAlreadyExists remote already exists for this target type.
type BucketRemoteAlreadyExists GenericError type BucketRemoteAlreadyExists GenericError

Loading…
Cancel
Save