[#584] Return BucketAlreadyExists when global domain taken
A situation may occur when the global domain is already occupied when creating the container. The error comes from the nns smart contract. This error actually means that the bucket has already been created. Signed-off-by: Roman Loginov <r.loginov@yadro.com>
This commit is contained in:
parent
3f599f6bc2
commit
c1f3110dcc
3 changed files with 12 additions and 0 deletions
|
@ -1822,6 +1822,10 @@ func TransformToS3Error(err error) error {
|
|||
return GetAPIError(ErrGatewayTimeout)
|
||||
}
|
||||
|
||||
if errors.Is(err, frostfs.ErrGlobalDomainIsAlreadyTaken) {
|
||||
return GetAPIError(ErrBucketAlreadyExists)
|
||||
}
|
||||
|
||||
return GetAPIError(ErrInternalError)
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,9 @@ var (
|
|||
|
||||
// ErrGatewayTimeout is returned from FrostFS in case of timeout, deadline exceeded etc.
|
||||
ErrGatewayTimeout = errors.New("gateway timeout")
|
||||
|
||||
// ErrGlobalDomainIsAlreadyTaken is returned from FrostFS in case of global domain is already taken.
|
||||
ErrGlobalDomainIsAlreadyTaken = errors.New("global domain is already taken")
|
||||
)
|
||||
|
||||
// FrostFS represents virtual connection to FrostFS network.
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/layer/frostfs"
|
||||
|
@ -477,6 +478,10 @@ func handleObjectError(msg string, err error) error {
|
|||
return fmt.Errorf("%s: %w: %s", msg, frostfs.ErrGatewayTimeout, err.Error())
|
||||
}
|
||||
|
||||
if strings.Contains(err.Error(), "global domain is already taken") {
|
||||
return fmt.Errorf("%s: %w: %s", msg, frostfs.ErrGlobalDomainIsAlreadyTaken, err.Error())
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue