-
Notifications
You must be signed in to change notification settings - Fork 171
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,6 +14,7 @@ | |||||
package runtime | ||||||
|
||||||
import ( | ||||||
"context" | ||||||
"encoding/json" | ||||||
"fmt" | ||||||
"strings" | ||||||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. nit: spelling
Suggested change
|
||||||
// when the Synced condition is not there, it returns true. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is this this the case? If the for loop doesn't find a |
||||||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. p: "Res" is a bit unclear. Maybe |
||||||
for _, c := range res.Conditions() { | ||||||
if c.Type == ackv1alpha1.ConditionTypeResourceSynced { | ||||||
if c.Status == corev1.ConditionTrue { | ||||||
return true, nil | ||||||
} | ||||||
// TODO(michaelhtm) we should probably start relying more and more in IsSynced below. | ||||||
// Or maybe store the RequeueError in ackCondition.RequeueError... | ||||||
return false, fmt.Errorf("resource is not synced") | ||||||
|
||||||
} | ||||||
} | ||||||
|
||||||
synced, err := rm.IsSynced(ctx, res) | ||||||
return synced, err | ||||||
} | ||||||
|
||||||
// IsReadOnly returns true if the supplied AWSResource has an annotation | ||||||
// indicating that it is in read-only mode. | ||||||
func IsReadOnly(res acktypes.AWSResource) bool { | ||||||
|
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 ofPrepared
.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.