S3: Restored archived objects must be retrievable (#6043)

This commit is contained in:
Viren Nadkarni 2023-03-10 03:30:17 +05:30 committed by GitHub
parent 84174e129d
commit 2c9c7a7a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1319,6 +1319,9 @@ class S3Response(BaseResponse):
response_headers["x-amz-version-id"] = key.version_id response_headers["x-amz-version-id"] = key.version_id
if key.storage_class in ARCHIVE_STORAGE_CLASSES: if key.storage_class in ARCHIVE_STORAGE_CLASSES:
if 'ongoing-request="false"' not in key.response_dict.get(
"x-amz-restore", ""
):
raise InvalidObjectState(storage_class=key.storage_class) raise InvalidObjectState(storage_class=key.storage_class)
if if_unmodified_since: if if_unmodified_since:
if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since) if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)

View File

@ -231,8 +231,18 @@ def test_s3_copy_object_for_deep_archive_storage_class_restored():
Bucket="Bucket", Key="First_Object", Body="Body", StorageClass="DEEP_ARCHIVE" Bucket="Bucket", Key="First_Object", Body="Body", StorageClass="DEEP_ARCHIVE"
) )
with pytest.raises(ClientError) as exc:
s3.get_object(Bucket="Bucket", Key="First_Object")
err = exc.value.response["Error"]
err["Code"].should.equal("InvalidObjectState")
err["Message"].should.equal(
"The operation is not valid for the object's storage class"
)
err["StorageClass"].should.equal("DEEP_ARCHIVE")
s3.create_bucket(Bucket="Bucket2") s3.create_bucket(Bucket="Bucket2")
s3.restore_object(Bucket="Bucket", Key="First_Object", RestoreRequest={"Days": 123}) s3.restore_object(Bucket="Bucket", Key="First_Object", RestoreRequest={"Days": 123})
s3.get_object(Bucket="Bucket", Key="First_Object")
s3.copy_object( s3.copy_object(
CopySource={"Bucket": "Bucket", "Key": "First_Object"}, CopySource={"Bucket": "Bucket", "Key": "First_Object"},