diff --git a/go.mod b/go.mod index b6d005b..b64645a 100644 --- a/go.mod +++ b/go.mod @@ -94,3 +94,5 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) + +replace github.com/aws-controllers-k8s/runtime => github.com/michaelhtm/ack-runtime v0.49.1-0.20251128201219-8434e12b588b diff --git a/go.sum b/go.sum index 1f02bd2..3faf265 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/aws-controllers-k8s/runtime v0.54.1 h1:0mbCJELz3t7jbG4abNecF0yeRd8YeFZQPr7nnzr8DC8= -github.com/aws-controllers-k8s/runtime v0.54.1/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY= github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go-v2 v1.34.0 h1:9iyL+cjifckRGEVpRKZP3eIxVlL06Qk1Tk13vreaVQU= @@ -117,6 +115,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/michaelhtm/ack-runtime v0.49.1-0.20251128201219-8434e12b588b h1:xQzVSQ7ueMQzvuzkGalZeRTydGgpyGebRmBjHQVkXfE= +github.com/michaelhtm/ack-runtime v0.49.1-0.20251128201219-8434e12b588b/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/test/e2e/resources/bucket_adopt_no_fields.yaml b/test/e2e/resources/bucket_adopt_no_fields.yaml new file mode 100644 index 0000000..40442db --- /dev/null +++ b/test/e2e/resources/bucket_adopt_no_fields.yaml @@ -0,0 +1,7 @@ +apiVersion: s3.services.k8s.aws/v1alpha1 +kind: Bucket +metadata: + name: $RANDOM_BUCKET_NAME + annotations: + services.k8s.aws/adoption-policy: $ADOPTION_POLICY + services.k8s.aws/deletion-policy: retain diff --git a/test/e2e/tests/test_bucket_adoption_policy.py b/test/e2e/tests/test_bucket_adoption_policy.py index df0e8d7..e8e749c 100644 --- a/test/e2e/tests/test_bucket_adoption_policy.py +++ b/test/e2e/tests/test_bucket_adoption_policy.py @@ -27,7 +27,7 @@ from e2e.replacement_values import REPLACEMENT_VALUES CREATE_WAIT_AFTER_SECONDS = 10 -MODIFY_WAIT_AFTER_SECONDS = 20 +MODIFY_WAIT_AFTER_SECONDS = 10 DELETE_WAIT_AFTER_SECONDS = 10 ACK_SYSTEM_TAG_PREFIX = "services.k8s.aws/" AWS_SYSTEM_TAG_PREFIX = "aws:" @@ -150,6 +150,20 @@ def test_adopt_policy( assert latest is not None versioning = latest.Versioning() assert versioning.status == status + + @pytest.mark.resource_data({'adoption-policy': AdoptionPolicy.ADOPT, 'filename': 'bucket_adopt_no_fields', 'resource-name': 'adopt'}) + def test_adopt_policy_missing_fields( + self, s3_client, bucket_adoption_policy, s3_resource + ): + (ref, cr) = bucket_adoption_policy + + k8s.wait_on_condition(ref, "ACK.Terminal", "True", wait_periods=5) + + condition = k8s.get_resource_condition(ref, "ACK.Terminal") + assert condition is not None + + expected_msg = "adoption-fields is not defined" + assert expected_msg in condition['reason'] @pytest.mark.resource_data({'adoption-policy': AdoptionPolicy.ADOPT_OR_CREATE, 'filename': 'bucket_adopt_or_create', 'resource-name': 'adopt-or-create'}) def test_adopt_or_create_policy( @@ -162,7 +176,9 @@ def test_adopt_or_create_policy( assert 'spec' in cr assert 'name' in cr['spec'] bucket_name = cr['spec']['name'] - + + # Wait for tags to appear on describe + time.sleep(MODIFY_WAIT_AFTER_SECONDS) latest = get_bucket(s3_resource, bucket_name) assert latest is not None tagging = latest.Tagging()