From 1db47ad14c10637f9608df8f137306111177e9dc Mon Sep 17 00:00:00 2001 From: Gustavo Diaz Date: Thu, 25 Sep 2025 05:24:26 +0000 Subject: [PATCH] Ready condition migration for dynamodb controller --- apis/v1alpha1/ack-generate-metadata.yaml | 8 ++--- .../dynamodb.services.k8s.aws_backups.yaml | 2 +- ...ynamodb.services.k8s.aws_globaltables.yaml | 2 +- .../dynamodb.services.k8s.aws_tables.yaml | 2 +- go.mod | 2 ++ go.sum | 4 +-- .../dynamodb.services.k8s.aws_backups.yaml | 2 +- ...ynamodb.services.k8s.aws_globaltables.yaml | 2 +- .../dynamodb.services.k8s.aws_tables.yaml | 2 +- .../services.k8s.aws_adoptedresources.yaml | 2 +- helm/crds/services.k8s.aws_fieldexports.yaml | 2 +- pkg/resource/table/references.go | 14 +++++---- test/e2e/condition.py | 30 +++++++++---------- test/e2e/requirements.txt | 2 +- test/e2e/tests/test_backup.py | 2 +- test/e2e/tests/test_global_table.py | 2 +- test/e2e/tests/test_table.py | 6 ++-- test/e2e/tests/test_table_replicas.py | 15 ++-------- 18 files changed, 48 insertions(+), 53 deletions(-) diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 69f4ae6..20a66cb 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,8 +1,8 @@ ack_generate_info: - build_date: "2025-09-19T17:14:03Z" - build_hash: 6b4211163dcc34776b01da9a18217bac0f4103fd - go_version: go1.24.6 - version: v0.52.0 + build_date: "2025-09-25T05:23:28Z" + build_hash: 9c388d9668ea19d0b1b65566d492c4f67c6e64c8 + go_version: go1.24.7 + version: 9c388d9 api_directory_checksum: bcdceff2d7ddf7c98141572260ef2e6cee8bf23f api_version: v1alpha1 aws_sdk_go_version: v1.32.6 diff --git a/config/crd/bases/dynamodb.services.k8s.aws_backups.yaml b/config/crd/bases/dynamodb.services.k8s.aws_backups.yaml index ba3c07b..b561c2f 100644 --- a/config/crd/bases/dynamodb.services.k8s.aws_backups.yaml +++ b/config/crd/bases/dynamodb.services.k8s.aws_backups.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: backups.dynamodb.services.k8s.aws spec: group: dynamodb.services.k8s.aws diff --git a/config/crd/bases/dynamodb.services.k8s.aws_globaltables.yaml b/config/crd/bases/dynamodb.services.k8s.aws_globaltables.yaml index 9a65ccc..b8e9834 100644 --- a/config/crd/bases/dynamodb.services.k8s.aws_globaltables.yaml +++ b/config/crd/bases/dynamodb.services.k8s.aws_globaltables.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: globaltables.dynamodb.services.k8s.aws spec: group: dynamodb.services.k8s.aws diff --git a/config/crd/bases/dynamodb.services.k8s.aws_tables.yaml b/config/crd/bases/dynamodb.services.k8s.aws_tables.yaml index 5cb696d..053dfea 100644 --- a/config/crd/bases/dynamodb.services.k8s.aws_tables.yaml +++ b/config/crd/bases/dynamodb.services.k8s.aws_tables.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: tables.dynamodb.services.k8s.aws spec: group: dynamodb.services.k8s.aws diff --git a/go.mod b/go.mod index c41001d..c6e51ae 100644 --- a/go.mod +++ b/go.mod @@ -92,3 +92,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/gustavodiaz7722/ack-runtime v0.57.0 diff --git a/go.sum b/go.sum index 9422e84..250c3d3 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/aws-controllers-k8s/kms-controller v1.0.21 h1:ar8gCdl/l7qbXzr48YN5tNq4vJbB5UqnRH7pAIkP3tI= github.com/aws-controllers-k8s/kms-controller v1.0.21/go.mod h1:tHFXV8lkrzautPPvQtPUJABPlJ9MXPRj8GB1UublGHQ= -github.com/aws-controllers-k8s/runtime v0.52.0 h1:Q5UIAn6SSBr60t/DiU/zr6NLBlUuK2AG3yy2ma/9gDU= -github.com/aws-controllers-k8s/runtime v0.52.0/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.36.0 h1:b1wM5CcE65Ujwn565qcwgtOTT1aT4ADOHHgglKjG7fk= @@ -88,6 +86,8 @@ github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgY github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gustavodiaz7722/ack-runtime v0.57.0 h1:85zJyvdPpzOTaWE0icljJcMRf0qlP0oWdOT05hMZ6Z0= +github.com/gustavodiaz7722/ack-runtime v0.57.0/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc= github.com/itchyny/gojq v0.12.6 h1:VjaFn59Em2wTxDNGcrRkDK9ZHMNa8IksOgL13sLL4d0= github.com/itchyny/gojq v0.12.6/go.mod h1:ZHrkfu7A+RbZLy5J1/JKpS4poEqrzItSTGDItqsfP0A= github.com/itchyny/timefmt-go v0.1.3 h1:7M3LGVDsqcd0VZH2U+x393obrzZisp7C0uEe921iRkU= diff --git a/helm/crds/dynamodb.services.k8s.aws_backups.yaml b/helm/crds/dynamodb.services.k8s.aws_backups.yaml index ba3c07b..b561c2f 100644 --- a/helm/crds/dynamodb.services.k8s.aws_backups.yaml +++ b/helm/crds/dynamodb.services.k8s.aws_backups.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: backups.dynamodb.services.k8s.aws spec: group: dynamodb.services.k8s.aws diff --git a/helm/crds/dynamodb.services.k8s.aws_globaltables.yaml b/helm/crds/dynamodb.services.k8s.aws_globaltables.yaml index 9a65ccc..b8e9834 100644 --- a/helm/crds/dynamodb.services.k8s.aws_globaltables.yaml +++ b/helm/crds/dynamodb.services.k8s.aws_globaltables.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: globaltables.dynamodb.services.k8s.aws spec: group: dynamodb.services.k8s.aws diff --git a/helm/crds/dynamodb.services.k8s.aws_tables.yaml b/helm/crds/dynamodb.services.k8s.aws_tables.yaml index 951d6b8..f79c6d8 100644 --- a/helm/crds/dynamodb.services.k8s.aws_tables.yaml +++ b/helm/crds/dynamodb.services.k8s.aws_tables.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: tables.dynamodb.services.k8s.aws spec: group: dynamodb.services.k8s.aws diff --git a/helm/crds/services.k8s.aws_adoptedresources.yaml b/helm/crds/services.k8s.aws_adoptedresources.yaml index b7be322..d6cdd10 100644 --- a/helm/crds/services.k8s.aws_adoptedresources.yaml +++ b/helm/crds/services.k8s.aws_adoptedresources.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: adoptedresources.services.k8s.aws spec: group: services.k8s.aws diff --git a/helm/crds/services.k8s.aws_fieldexports.yaml b/helm/crds/services.k8s.aws_fieldexports.yaml index 49b4f38..6e2c61e 100644 --- a/helm/crds/services.k8s.aws_fieldexports.yaml +++ b/helm/crds/services.k8s.aws_fieldexports.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.2 + controller-gen.kubebuilder.io/version: v0.19.0 name: fieldexports.services.k8s.aws spec: group: services.k8s.aws diff --git a/pkg/resource/table/references.go b/pkg/resource/table/references.go index 5a21ffe..3f857d8 100644 --- a/pkg/resource/table/references.go +++ b/pkg/resource/table/references.go @@ -25,6 +25,7 @@ import ( kmsapitypes "github.com/aws-controllers-k8s/kms-controller/apis/v1alpha1" ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1" + ackcondition "github.com/aws-controllers-k8s/runtime/pkg/condition" ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors" acktypes "github.com/aws-controllers-k8s/runtime/pkg/types" @@ -139,8 +140,9 @@ func getReferencedResourceState_Key( } var refResourceTerminal bool for _, cond := range obj.Status.Conditions { - if cond.Type == ackv1alpha1.ConditionTypeTerminal && - cond.Status == corev1.ConditionTrue { + if cond.Type == ackv1alpha1.ConditionTypeReady && + cond.Status == corev1.ConditionFalse && + *cond.Reason == ackcondition.TerminalReason { return ackerr.ResourceReferenceTerminalFor( "Key", namespace, name) @@ -151,14 +153,14 @@ func getReferencedResourceState_Key( "Key", namespace, name) } - var refResourceSynced bool + var refResourceReady bool for _, cond := range obj.Status.Conditions { - if cond.Type == ackv1alpha1.ConditionTypeResourceSynced && + if cond.Type == ackv1alpha1.ConditionTypeReady && cond.Status == corev1.ConditionTrue { - refResourceSynced = true + refResourceReady = true } } - if !refResourceSynced { + if !refResourceReady { return ackerr.ResourceReferenceNotSyncedFor( "Key", namespace, name) diff --git a/test/e2e/condition.py b/test/e2e/condition.py index cc306fa..13bfc2b 100644 --- a/test/e2e/condition.py +++ b/test/e2e/condition.py @@ -18,7 +18,7 @@ from acktest.k8s import resource CONDITION_TYPE_ADOPTED = "ACK.Adopted" -CONDITION_TYPE_RESOURCE_SYNCED = "ACK.ResourceSynced" +CONDITION_TYPE_READY = "Ready" CONDITION_TYPE_TERMINAL = "ACK.Terminal" CONDITION_TYPE_RECOVERABLE = "ACK.Recoverable" CONDITION_TYPE_ADVISORY = "ACK.Advisory" @@ -28,11 +28,11 @@ def assert_type_status( ref: resource.CustomResourceReference, - cond_type_match: str = CONDITION_TYPE_RESOURCE_SYNCED, + cond_type_match: str = CONDITION_TYPE_READY, cond_status_match: bool = True, ): """Asserts that the supplied resource has a condition of type - ACK.ResourceSynced and that the Status of this condition is True. + Ready and that the Status of this condition is True. Usage: from acktest.k8s import resource @@ -46,7 +46,7 @@ def assert_type_status( resource.wait_resource_consumed_by_controller(ref) condition.assert_type_status( ref, - condition.CONDITION_TYPE_RESOURCE_SYNCED, + condition.CONDITION_TYPE_READY, False) Raises: @@ -71,7 +71,7 @@ def assert_synced_status( cond_status_match: bool, ): """Asserts that the supplied resource has a condition of type - ACK.ResourceSynced and that the Status of this condition is True. + Ready and that the Status of this condition is True. Usage: from acktest.k8s import resource @@ -86,15 +86,15 @@ def assert_synced_status( condition.assert_synced_status(ref, False) Raises: - pytest.fail when ACK.ResourceSynced condition is not found or is not in + pytest.fail when Ready condition is not found or is not in a True status. """ - assert_type_status(ref, CONDITION_TYPE_RESOURCE_SYNCED, cond_status_match) + assert_type_status(ref, CONDITION_TYPE_READY, cond_status_match) -def assert_synced(ref: resource.CustomResourceReference): +def assert_ready(ref: resource.CustomResourceReference): """Asserts that the supplied resource has a condition of type - ACK.ResourceSynced and that the Status of this condition is True. + Ready and that the Status of this condition is True. Usage: from acktest.k8s import resource @@ -106,18 +106,18 @@ def assert_synced(ref: resource.CustomResourceReference): ) resource.create_custom_resource(ref, resource_data) resource.wait_resource_consumed_by_controller(ref) - condition.assert_synced(ref) + condition.assert_ready(ref) Raises: - pytest.fail when ACK.ResourceSynced condition is not found or is not in + pytest.fail when Ready condition is not found or is not in a True status. """ return assert_synced_status(ref, True) -def assert_not_synced(ref: resource.CustomResourceReference): +def assert_not_ready(ref: resource.CustomResourceReference): """Asserts that the supplied resource has a condition of type - ACK.ResourceSynced and that the Status of this condition is False. + Ready and that the Status of this condition is False. Usage: from acktest.k8s import resource @@ -129,10 +129,10 @@ def assert_not_synced(ref: resource.CustomResourceReference): ) resource.create_custom_resource(ref, resource_data) resource.wait_resource_consumed_by_controller(ref) - condition.assert_not_synced(ref) + condition.assert_not_ready(ref) Raises: - pytest.fail when ACK.ResourceSynced condition is not found or is not in + pytest.fail when Ready condition is not found or is not in a False status. """ return assert_synced_status(ref, False) diff --git a/test/e2e/requirements.txt b/test/e2e/requirements.txt index 8d94056..6e2ab16 100644 --- a/test/e2e/requirements.txt +++ b/test/e2e/requirements.txt @@ -1 +1 @@ -acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@38ce32256cc2552ab54e190cc8a8618e93af9e0c +acktest @ git+https://github.com/gustavodiaz7722/ack-test-infra.git@4a5c296da0fe386eadf95c242591ae4724cd0428 diff --git a/test/e2e/tests/test_backup.py b/test/e2e/tests/test_backup.py index a88bbab..bfebb9f 100644 --- a/test/e2e/tests/test_backup.py +++ b/test/e2e/tests/test_backup.py @@ -125,7 +125,7 @@ def test_smoke(self, dynamodb_client, dynamodb_table): 20, 5, ) - condition.assert_synced(ref) + condition.assert_ready(ref) backupArn = k8s.get_resource_arn(cr) # Check DynamoDB Backup exists diff --git a/test/e2e/tests/test_global_table.py b/test/e2e/tests/test_global_table.py index 41ccbc9..b49cbd4 100644 --- a/test/e2e/tests/test_global_table.py +++ b/test/e2e/tests/test_global_table.py @@ -132,7 +132,7 @@ def test_smoke(self, dynamodb_client, dynamodb_table): 10, 5, ) - condition.assert_synced(ref) + condition.assert_ready(ref) # Check DynamoDB Global Table exists exists = self.global_table_exists(dynamodb_client, global_table_name) diff --git a/test/e2e/tests/test_table.py b/test/e2e/tests/test_table.py index cad55f6..f904711 100644 --- a/test/e2e/tests/test_table.py +++ b/test/e2e/tests/test_table.py @@ -175,7 +175,7 @@ def test_create_delete(self, table_lsi): (ref, res) = table_lsi table_name = res["spec"]["tableName"] - condition.assert_synced(ref) + condition.assert_ready(ref) # Check DynamoDB Table exists assert self.table_exists(table_name) @@ -476,7 +476,7 @@ def test_update_insights(self, table_insights): (ref, res) = table_insights table_name = res["spec"]["tableName"] - assert k8s.wait_on_condition(ref, "ACK.ResourceSynced", "True", wait_periods=5) + assert k8s.wait_on_condition(ref, "Ready", "True", wait_periods=5) cr = k8s.get_resource(ref) @@ -493,7 +493,7 @@ def test_update_insights(self, table_insights): } # Patch k8s resource k8s.patch_custom_resource(ref, updates) - assert k8s.wait_on_condition(ref, "ACK.ResourceSynced", "True", wait_periods=5) + assert k8s.wait_on_condition(ref, "Ready", "True", wait_periods=5) cr = k8s.get_resource(ref) assert cr['spec']['contributorInsights'] == "DISABLE" assert self.table_insight_status(table_name, "DISABLED") diff --git a/test/e2e/tests/test_table_replicas.py b/test/e2e/tests/test_table_replicas.py index 0286bcd..70d0243 100644 --- a/test/e2e/tests/test_table_replicas.py +++ b/test/e2e/tests/test_table_replicas.py @@ -372,25 +372,16 @@ def test_terminal_condition_for_invalid_stream_specification(self, table_with_in max_wait_seconds = 120 interval_seconds = 10 start_time = time.time() - terminal_condition_found = False while time.time() - start_time < max_wait_seconds: try: - condition.assert_type_status( - ref, - condition.CONDITION_TYPE_TERMINAL, - True) - - terminal_condition_found = True - cond = k8s.get_resource_condition( - ref, condition.CONDITION_TYPE_TERMINAL) - assert "table must have DynamoDB Streams enabled with StreamViewType set to NEW_AND_OLD_IMAGES" in cond[ - "message"] + condition.assert_terminal(ref, "table must have DynamoDB Streams enabled with StreamViewType set to NEW_AND_OLD_IMAGES") break except: time.sleep(interval_seconds) - assert terminal_condition_found, "Terminal condition was not set for invalid StreamSpecification" + condition.assert_terminal(ref, "table must have DynamoDB Streams enabled with StreamViewType set to NEW_AND_OLD_IMAGES") + def test_staged_replicas_and_gsi_updates(self, table_replicas_gsi): (ref, cr) = table_replicas_gsi