diff --git a/sdk/helper/consts/error.go b/sdk/helper/consts/error.go index d4e60e54e3..1a9175c639 100644 --- a/sdk/helper/consts/error.go +++ b/sdk/helper/consts/error.go @@ -7,6 +7,10 @@ var ( // No operation is expected to succeed before unsealing ErrSealed = errors.New("Vault is sealed") + // ErrAPILocked is returned if an operation is performed when the API is + // locked for the request namespace. + ErrAPILocked = errors.New("API access to this namespace has been locked by an administrator") + // ErrStandby is returned if an operation is performed on a standby Vault. // No operation is expected to succeed until active. ErrStandby = errors.New("Vault is in standby mode") diff --git a/sdk/logical/error.go b/sdk/logical/error.go index 36c5a60355..02f68dd918 100644 --- a/sdk/logical/error.go +++ b/sdk/logical/error.go @@ -51,10 +51,6 @@ var ( // Error indicating that the requested path used to serve a purpose in older // versions, but the functionality has now been removed ErrPathFunctionalityRemoved = errors.New("functionality on this path has been removed") - - // ErrorLocked indicates that the requested path is locked. Functionality - // will not be restored until it is unlocked. - ErrLocked = errors.New("API access to this namespace has been locked by an administrator") ) type HTTPCodedError interface { diff --git a/sdk/logical/response_util.go b/sdk/logical/response_util.go index 61fa67e5e7..353ef569a4 100644 --- a/sdk/logical/response_util.go +++ b/sdk/logical/response_util.go @@ -120,8 +120,6 @@ func RespondErrorCommon(req *Request, resp *Response, err error) (int, error) { statusCode = http.StatusPreconditionFailed case errwrap.Contains(err, ErrPathFunctionalityRemoved.Error()): statusCode = http.StatusNotFound - case errwrap.Contains(err, ErrLocked.Error()): - statusCode = http.StatusLocked } } @@ -148,6 +146,10 @@ func AdjustErrorStatusCode(status *int, err error) { *status = http.StatusServiceUnavailable } + if errwrap.Contains(err, consts.ErrAPILocked.Error()) { + *status = http.StatusServiceUnavailable + } + // Adjust status code on if errwrap.Contains(err, "http: request body too large") { *status = http.StatusRequestEntityTooLarge