mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
improve error message when remote target missing (#10412)
This commit is contained in:
parent
fbd1c5f51a
commit
0037951b6e
@ -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…
Reference in New Issue
Block a user