[#31] Add force bucket delete flag
Some checks failed
/ DCO (pull_request) Successful in 1m11s
/ Builds (1.21) (pull_request) Successful in 2m12s
/ Builds (1.22) (pull_request) Successful in 1m24s
/ Lint (pull_request) Failing after 2m2s
/ Tests (1.21) (pull_request) Failing after 2m18s
/ Tests (1.22) (pull_request) Failing after 1m34s
/ Vulncheck (pull_request) Failing after 10m31s
Some checks failed
/ DCO (pull_request) Successful in 1m11s
/ Builds (1.21) (pull_request) Successful in 2m12s
/ Builds (1.22) (pull_request) Successful in 1m24s
/ Lint (pull_request) Failing after 2m2s
/ Tests (1.21) (pull_request) Failing after 2m18s
/ Tests (1.22) (pull_request) Failing after 1m34s
/ Vulncheck (pull_request) Failing after 10m31s
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
parent
a031777a1b
commit
18cc091545
5 changed files with 73 additions and 3 deletions
|
@ -277,6 +277,7 @@ const (
|
||||||
ErrEvaluatorBindingDoesNotExist
|
ErrEvaluatorBindingDoesNotExist
|
||||||
ErrMissingHeaders
|
ErrMissingHeaders
|
||||||
ErrInvalidColumnIndex
|
ErrInvalidColumnIndex
|
||||||
|
ErrMissingForceBucketDeleteHeader
|
||||||
|
|
||||||
ErrPostPolicyConditionInvalidFormat
|
ErrPostPolicyConditionInvalidFormat
|
||||||
|
|
||||||
|
@ -1709,6 +1710,12 @@ var errorCodes = errorCodeMap{
|
||||||
Description: "Some headers in the query are missing from the file. Check the file and try again.",
|
Description: "Some headers in the query are missing from the file. Check the file and try again.",
|
||||||
HTTPStatusCode: http.StatusBadRequest,
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
},
|
},
|
||||||
|
ErrMissingForceBucketDeleteHeader: {
|
||||||
|
ErrCode: ErrMissingForceBucketDeleteHeader,
|
||||||
|
Code: "ErrMissingForceBucketDeleteHeader",
|
||||||
|
Description: "Missing X-Amz-Force-Bucket-Delete header.",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
ErrInvalidColumnIndex: {
|
ErrInvalidColumnIndex: {
|
||||||
ErrCode: ErrInvalidColumnIndex,
|
ErrCode: ErrInvalidColumnIndex,
|
||||||
Code: "InvalidColumnIndex",
|
Code: "InvalidColumnIndex",
|
||||||
|
|
|
@ -237,10 +237,21 @@ func (h *handler) DeleteBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
sessionToken = boxData.Gate.SessionTokenForDelete()
|
sessionToken = boxData.Gate.SessionTokenForDelete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skipObjCheck := false
|
||||||
|
if value, ok := r.Header[api.AmzForceBucketDelete]; !ok {
|
||||||
|
h.logAndSendError(w, "missing X-Amz-Force-Delete-Bucket", reqInfo, errors.GetAPIError(errors.ErrMissingForceBucketDeleteHeader))
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
s := value[0]
|
||||||
|
if s == "true" {
|
||||||
|
skipObjCheck = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = h.obj.DeleteBucket(r.Context(), &layer.DeleteBucketParams{
|
if err = h.obj.DeleteBucket(r.Context(), &layer.DeleteBucketParams{
|
||||||
BktInfo: bktInfo,
|
BktInfo: bktInfo,
|
||||||
SessionToken: sessionToken,
|
SessionToken: sessionToken,
|
||||||
}); err != nil {
|
}, skipObjCheck); err != nil {
|
||||||
h.logAndSendError(w, "couldn't delete bucket", reqInfo, err)
|
h.logAndSendError(w, "couldn't delete bucket", reqInfo, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ const (
|
||||||
AmzMaxParts = "X-Amz-Max-Parts"
|
AmzMaxParts = "X-Amz-Max-Parts"
|
||||||
AmzPartNumberMarker = "X-Amz-Part-Number-Marker"
|
AmzPartNumberMarker = "X-Amz-Part-Number-Marker"
|
||||||
AmzStorageClass = "X-Amz-Storage-Class"
|
AmzStorageClass = "X-Amz-Storage-Class"
|
||||||
|
AmzForceBucketDelete = "X-Amz-Force-Delete-Bucket"
|
||||||
|
|
||||||
AmzServerSideEncryptionCustomerAlgorithm = "x-amz-server-side-encryption-customer-algorithm"
|
AmzServerSideEncryptionCustomerAlgorithm = "x-amz-server-side-encryption-customer-algorithm"
|
||||||
AmzServerSideEncryptionCustomerKey = "x-amz-server-side-encryption-customer-key"
|
AmzServerSideEncryptionCustomerKey = "x-amz-server-side-encryption-customer-key"
|
||||||
|
|
|
@ -793,7 +793,7 @@ func (n *Layer) ResolveBucket(ctx context.Context, name string) (cid.ID, error)
|
||||||
return cnrID, nil
|
return cnrID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error {
|
func (n *Layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams, skipCheck bool) error {
|
||||||
res, _, err := n.getAllObjectsVersions(ctx, commonVersionsListingParams{
|
res, _, err := n.getAllObjectsVersions(ctx, commonVersionsListingParams{
|
||||||
BktInfo: p.BktInfo,
|
BktInfo: p.BktInfo,
|
||||||
MaxKeys: 1,
|
MaxKeys: 1,
|
||||||
|
@ -802,7 +802,7 @@ func (n *Layer) DeleteBucket(ctx context.Context, p *DeleteBucketParams) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(res) != 0 {
|
if len(res) != 0 && !skipCheck {
|
||||||
return errors.GetAPIError(errors.ErrBucketNotEmpty)
|
return errors.GetAPIError(errors.ErrBucketNotEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
51
docs/extensions.md
Normal file
51
docs/extensions.md
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# S3 API Extension
|
||||||
|
|
||||||
|
## Bucket operations management
|
||||||
|
|
||||||
|
### Action to delete bucket (DeleteBucket)
|
||||||
|
|
||||||
|
Deletes bucket with all objects in it.
|
||||||
|
|
||||||
|
#### Request Parameters
|
||||||
|
|
||||||
|
- **Bucket**
|
||||||
|
|
||||||
|
Specifies the bucket being deleted.
|
||||||
|
|
||||||
|
|
||||||
|
#### Errors
|
||||||
|
|
||||||
|
- **NoSuchEntity**
|
||||||
|
|
||||||
|
The request was rejected because it referenced a resource entity that does not exist.
|
||||||
|
|
||||||
|
HTTP Status Code: 404
|
||||||
|
|
||||||
|
- **ServiceFailure**
|
||||||
|
|
||||||
|
The request processing has failed because of an unknown error, exception or failure.
|
||||||
|
|
||||||
|
HTTP Status Code: 500
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
Sample Request
|
||||||
|
|
||||||
|
```text
|
||||||
|
DELETE / HTTP/1.1
|
||||||
|
Host: data.s3.<Region>.frostfs-s3-gw.com
|
||||||
|
Date: Wed, 01 Mar 2024 12:00:00 GMT
|
||||||
|
Authorization: authorization string
|
||||||
|
```
|
||||||
|
|
||||||
|
Sample Response
|
||||||
|
|
||||||
|
```text
|
||||||
|
HTTP/1.1 204 No Content
|
||||||
|
x-amz-id-2: JuKZqmXuiwFeDQxhD7M8KtsKobSzWA1QEjLbTMTagkKdBX2z7Il/jGhDeJ3j6s80
|
||||||
|
x-amz-request-id: 32FE2CEB32F5EE25
|
||||||
|
Date: Wed, 01 Mar 2006 12:00:00 GMT
|
||||||
|
Connection: close
|
||||||
|
Server: AmazonS3
|
||||||
|
```
|
Loading…
Reference in a new issue