mirror of
https://github.com/minio/minio.git
synced 2025-01-25 21:53:16 -05:00
handle dns.ErrBucketConflict as BucketAlreadyExists (#12013)
This commit is contained in:
parent
2899cc92b4
commit
835d2cb9a3
@ -2004,6 +2004,8 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
|
|||||||
apiErr = ErrKeyTooLongError
|
apiErr = ErrKeyTooLongError
|
||||||
case dns.ErrInvalidBucketName:
|
case dns.ErrInvalidBucketName:
|
||||||
apiErr = ErrInvalidBucketName
|
apiErr = ErrInvalidBucketName
|
||||||
|
case dns.ErrBucketConflict:
|
||||||
|
apiErr = ErrBucketAlreadyExists
|
||||||
default:
|
default:
|
||||||
var ie, iw int
|
var ie, iw int
|
||||||
// This work-around is to handle the issue golang/go#30648
|
// This work-around is to handle the issue golang/go#30648
|
||||||
|
@ -100,6 +100,10 @@ func (c *OperatorDNS) Put(bucket string) error {
|
|||||||
xhttp.DrainBody(resp.Body)
|
xhttp.DrainBody(resp.Body)
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
errorString := errorStringBuilder.String()
|
errorString := errorStringBuilder.String()
|
||||||
|
switch resp.StatusCode {
|
||||||
|
case http.StatusConflict:
|
||||||
|
return ErrBucketConflict(Error{bucket, errors.New(errorString)})
|
||||||
|
}
|
||||||
return newError(bucket, fmt.Errorf("service create for bucket %s, failed with status %s, error %s", bucket, resp.Status, errorString))
|
return newError(bucket, fmt.Errorf("service create for bucket %s, failed with status %s, error %s", bucket, resp.Status, errorString))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -26,12 +26,20 @@ type Error struct {
|
|||||||
type ErrInvalidBucketName Error
|
type ErrInvalidBucketName Error
|
||||||
|
|
||||||
func (e ErrInvalidBucketName) Error() string {
|
func (e ErrInvalidBucketName) Error() string {
|
||||||
return "invalid bucket name error: " + e.Err.Error()
|
return e.Bucket + " invalid bucket name error: " + e.Err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e Error) Error() string {
|
func (e Error) Error() string {
|
||||||
return "dns related error: " + e.Err.Error()
|
return "dns related error: " + e.Err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrBucketConflict for buckets that already exist
|
||||||
|
type ErrBucketConflict Error
|
||||||
|
|
||||||
|
func (e ErrBucketConflict) Error() string {
|
||||||
|
return e.Bucket + " bucket conflict error: " + e.Err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
// Store dns record store
|
// Store dns record store
|
||||||
type Store interface {
|
type Store interface {
|
||||||
Put(bucket string) error
|
Put(bucket string) error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user