angeloc / s3-pit-restore

The new home for the s3-pit-restore tool!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected No versions matching criteria, exiting ...

alex-ginj opened this issue · comments

Hello,

Description

When restoring from one bucket to another, the script terminates when there is no "Versions" key found in the returned page response, therefore not all objects are parsed. See here:

    for page in page_iterator:
        if not "Versions" in page:
            print("No versions matching criteria, exiting ...", file=sys.stderr)
            sys.exit(1)

Findings

It appears that system-defined metadata prefixed with META/ don't have Versions key, therefore after first occurrence of a metadata object the script terminates.

Debugging logs:

"2021-01-29 12:48:29+00:00" j3JYMecjFXTUPwplWAbok50eenEnyOKE 95871 STANDARD 9fff-ff26d7643d203b550019ca2c2b468a96371b7b6d3261a8f656d5b4165aec
No versions matching criteria, exiting ...:
{'ResponseMetadata': {'RequestId': '*#HJGOGHSEGJ)SE', 'HostId': 'aasdasfegdsuhgsiughwei+ppIc7najtrVm7rgew+siduhgruwgoasdfgr=', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amz-id-2': 'adf38grhe8oosf83ohg83jdsog+aouht2973aoifoq+9823hrusdfhusighwoadfa=', 'x-amz-request-id': '2903jtgoisd0923jfgj', 'date': 'Wed, 08 Dec 2021 13:18:36 GMT', 'content-type': 'application/xml', 'transfer-encoding': 'chunked', 'server': 'AmazonS3'}, 'RetryAttempts': 0}, 'IsTruncated': True, 'KeyMarker': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adfb599b1c-908a-4099-8b0e-f76a085388e81614621839103.refs', 'VersionIdMarker': 'Nkq0cltacQKCj.BVqXxxO0jSbH_FRY.1', 'NextKeyMarker': 'META/blob-642b6e0b-e2b6-48c0-b813-fa1fc6b1c450791a1974-9a16-450f-a721-722b7133099d1617901500524.refs', 'NextVersionIdMarker': '8PkM3_XQ66Z0aKtsRCx76oV4ZvpbF4.J', 'DeleteMarkers': [{'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adfb6332c2-157e-4220-a5f0-faa9a451ca9c1621011821559.refs', 'VersionId': 'uL1jQNJnIHTFMmEsaGb.vK04G_BBZgUZ', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 7, 28, 2, 6, 44, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adfcb01084-d675-46e2-8f7b-8af7e72ede911614708239101.refs', 'VersionId': 'qwQ9mQQuASj5URJCE1rV1aXGpyepez4d', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 4, 15, 2, 3, 14, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adfd772a88-39e7-4ad0-8eb8-8ca55c4fbc3b1615313017232.refs', 'VersionId': 'lc16qRhgb0Y3d0GxPMWdIRZub4oPLFBQ', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 4, 15, 2, 3, 14, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adfef13c46-994a-43c2-a0a5-70e5e0ab1af51616177023004.refs', 'VersionId': 'LgfI4YiKFSHabFyfCeu7dbiPq5_EF5xG', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 4, 15, 2, 3, 14, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adff3a47fc-eff4-4d73-97cb-c87b1ee9fa721623690209551.refs', 'VersionId': 'JaNl3NHeWU6cpNRl8M3xYYwL5xhFW3P2', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 7, 28, 2, 6, 44, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adffb10d89-ebb2-452a-a5d8-c7b2fb1fa7281626195834667.refs', 'VersionId': 'q3bC3T8fzuy1VJqpf.Vt3tDJy0fJjCWe', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 7, 28, 2, 6, 45, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-14a66a39-6b4a-441c-a7a2-f4578149f2adffecc54d-7efe-490c-b177-e9fe801223e51626887084452.refs', 'VersionId': 'hlPplVp8P9sVKUQsU3wpKdlq3D1Ho0LS', 'IsLatest': True, 'LastModified': datetime.datetime(2021, 7, 28, 2, 6, 45, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-44171f0d-3914-4e91-89d1-e626a6a4c97f00d505c5-0da5-4c20-9837-f68b0da3998a1583263322042.refs', 'VersionId': 'fryHGZwi7e25JdhUHdOsu92OtjSN7hz4', 'IsLatest': True, 'LastModified': datetime.datetime(2020, 3, 4, 2, 0, 3, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-44171f0d-3914-4e91-89d1-e626a6a4c97f00d505c5-0da5-4c20-9837-f68b0da3998a1583306522024.refs', 'VersionId': 'HIQ1pbyHHIUXSFULXwWkAvZL0qJFPJ21', 'IsLatest': True, 'LastModified': datetime.datetime(2020, 3, 5, 2, 0, 35, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-44171f0d-3914-4e91-89d1-e626a6a4c97f084a906d-bf84-4e97-ba2c-c1f7da5b52f21590191463794.refs', 'VersionId': 'wnCNcISNgqEA2MxsOrfvx_x.OHVpMOOO', 'IsLatest': True, 'LastModified': datetime.datetime(2020, 5, 23, 2, 0, 3, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-44171f0d-3914-4e91-89d1-e626a6a4c97f084a906d-bf84-4e97-ba2c-c1f7da5b52f21590234663791.refs', 'VersionId': 'DcbAcNLgCgyU_QJ9NSwZa3lgCW3ebNF3', 'IsLatest': True, 'LastModified': datetime.datetime(2020, 5, 24, 2, 0, 4, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}, 'Key': 'META/blob-44171f0d-3914-4e91-89d1-e626a6a4c97f084a906d-bf84-4e97-ba2c-c1f7da5b52f21590277863791.refs', 'VersionId': 'CVShkB9mof22YtmiDLnOTVY87hXJS6dm', 'IsLatest': True, 'LastModified': datetime.datetime(2020, 5, 24, 2, 0, 4, tzinfo=tzutc())}, {'Owner': {'ID': '4c0b4ac898185165ae8d411f9504f560757bc2c12975bc4362beab1ef7ff48ef9348yovmq8y4tvn73284ny57ov8ua984yv57n8hu6o8au4pmvy5nouamtvvh5'}

Expectations

Generate a warning that metadata object is not versioned and therefore it will be skipped.
Implement an additional option that will help to filter some prefixes (e.g. META/)
Other ideas

Execution Details

s3-pit-restore version: The one created with python3 setup.py install
How I run it: s3-pit-restore --dry-run --verbose -b <source_bucket> B <destination_bucket> -t "02-20-2021 14:15:00 +1"

I don't know about META but the same thing happens when you enable versioning on a bucket after you put some objects in. Until you write to those objects again, there will not be a Versions key in the response for those objects.

My solution was to delete everything in the bucket and store all objects again, but I think if this was to be supported by s3-pit-restore the proper fix would be to do get_object_attributes on the objects that do not have a Versions key.

Same issue here, we enabled the versioning after the bucket was created and get the same error. Ideally the tool should tolerate this.