Skip to content

feat: wait for resource to sync before updating #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michaelhtm
Copy link
Member

Description of changes:
Currently, We've been setting a resource as NotSynced in ReadOne, if the
resource status is not a certain way (Eg. waiting for EKS Cluster to be
Active), and also checking the same resource Status in sdkUpdate.

This is the first attempt at addressing that issue. We are going to need
to ensure every controller/resource returns the proper NotSynced reason
and the requeue error inside the condition. This will allow us to set a
custom requeue right from ReadOne, that will be returned in preUpdate.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Currently, We've been setting a resource as NotSynced in ReadOne, if the
resource status is not a certain way (Eg. waiting for EKS Cluster to be
Active), and also checking the same resource Status in sdkUpdate.

This is the first attempt at addressing that issue. We are going to need
to ensure every controller/resource returns the proper NotSynced reason
and the requeue error inside the condition. This will allow us to set a
custom requeue right from ReadOne, that will be returned in preUpdate.
@ack-prow ack-prow bot requested review from jlbutler and knottnt May 22, 2025 21:49
Copy link

ack-prow bot commented May 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelhtm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the approved label May 22, 2025
michaelhtm added a commit to michaelhtm/ack-lambda-controller that referenced this pull request May 22, 2025
Copy link

ack-prow bot commented May 22, 2025

@michaelhtm: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
verify-attribution 55bad60 link false /test verify-attribution
unit-test 55bad60 link true /test unit-test
ec2-controller-test 55bad60 link true /test ec2-controller-test
sagemaker-controller-test 55bad60 link true /test sagemaker-controller-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link

@knottnt knottnt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we included some integration and unit tests.

@@ -70,6 +71,27 @@ func IsSynced(res acktypes.AWSResource) bool {
return false
}

// IsSyncedInRes is like IsSynced, but instead of returnning false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spelling

Suggested change
// IsSyncedInRes is like IsSynced, but instead of returnning false
// IsSyncedInRes is like IsSynced, but instead of returning false

// when the Synced condition is not there, it returns true.
// Note(michaelhtm) We will be using this as a preUpdate check to
// see if a resource has a NotSynced condition
func IsSyncedInRes(ctx context.Context, rm acktypes.AWSResourceManager, res acktypes.AWSResource) (bool, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p: "Res" is a bit unclear. Maybe IsSyncedInAWSResource? It's more verbose, but explicit about what is actually being checked.

@@ -70,6 +71,27 @@ func IsSynced(res acktypes.AWSResource) bool {
return false
}

// IsSyncedInRes is like IsSynced, but instead of returnning false
// when the Synced condition is not there, it returns true.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// when the Synced condition is not there, it returns true.

Is this this the case? If the for loop doesn't find a ConditionTypeResourceSynced condition it this function returns the result of IsSynced.

@@ -745,6 +745,13 @@ func (r *resourceReconciler) updateResource(
return latest, err
}

// We don't want to attempt updating the resource until it is Synced!
if synced, err := IsSyncedInRes(ctx, rm, latest); !synced {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to fully block the update call? For example in Bedrock Agent we need to make an API call to PrepareAgent before the resource is in the synced state of Prepared.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I believe @a-hilaly mentioned that we might want to also allow updates, such as tags, that don't depend on the status of the AWS resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants