-
Notifications
You must be signed in to change notification settings - Fork 170
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
base: main
Are you sure you want to change the base?
Conversation
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.
[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 |
@michaelhtm: The following tests failed, say
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. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spelling
// 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) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
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.