noobaa / noobaa-core

High-performance S3 application gateway to any backend - file / s3-compatible / multi-clouds / caching / replication ...
https://www.noobaa.io
Apache License 2.0
269 stars 78 forks source link

NSFS | S3 | Versioning: PutBucketLifecycleConfiguration on version-enabled bucket fails with ParamValidationError #8376

Open hseipp opened 2 weeks ago

hseipp commented 2 weeks ago

Environment info

Actual behavior

The following test code fails at put_bucket_lifecycle_configuration():

    def test_s3cever13():
        client = get_client()
        bucket_name = get_new_bucket(client=client)

        # The following operation uses another client instance -> following operations will fail
    #    check_configure_versioning_retry(bucket_name, "Enabled", "Enabled")
        _ces_safe_check_configure_versioning_retry(client, bucket_name, "Enabled", "Enabled")

        key = "test"
        num_versions = 3
        create_multiple_versions(client, bucket_name, key, num_versions)

        rules= [{'Expiration': {'Days': 1},
              'ID': 'rule1',
              'Filter': { 'Prefix': 'content-0' },
              'Status':'Enabled'}]
        lifecycle = json.dumps({'Rules': rules})
        print(lifecycle)
>       client.put_bucket_lifecycle_configuration(Bucket=bucket_name, LifecycleConfiguration=lifecycle)
...
E               botocore.exceptions.ParamValidationError: Parameter validation failed:
E               Invalid type for parameter LifecycleConfiguration, value: {"Rules": [{"Expiration": {"Days": 1}, "ID": "rule1", "Filter": {"Prefix": "content-0"}, "Status": "Enabled"}]}, type: <class 'str'>, valid types: <class 'dict'>

Expected behavior

The test case should pass, the policy should be accepted and get_bucket_lifecycle_configuration() should return the above policy.

Steps to reproduce

Execute the above listed test code - added to Ceph s3-tests.

More information - Screenshots / Logs / Other output

Policy printed with the print(lifecycle) command above:

{"Rules": [{"Expiration": {"Days": 1}, "ID": "rule1", "Filter": {"Prefix": "content-0"}, "Status": "Enabled"}]}

Nobaa log with debuglevel set to all attached noobaa_20240917_1.log.gz

dannyzaken commented 2 days ago

Hi @hseipp. I didn't run the test itself, but setting this configuration works for me. Also, I didn't see any reference to s3_put_bucket_lifecycle in the provided logs. In any case, I made some changes in #8424. can you please check after this fix?