-
Notifications
You must be signed in to change notification settings - Fork 170
Adding upsert for adopt-or-create #184
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?
Adding upsert for adopt-or-create #184
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: JonathanGraniero The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @JonathanGraniero. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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'm going to open this when it's ready to review, I'm still working on the test but just opened this in draft to visibly see my changes before making filling out the details. |
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.
Hello @JonathanGraniero
Thank you for the contribution!
Left one inline comment!
if adoptionPolicy == AdoptionPolicy_AdoptOrCreate { | ||
err = populated.PopulateResourceFromAnnotation(adoptionFields) | ||
if err != nil { | ||
rlog.Debug("Ignoring adoption field population error for adopt-or-create", "error", err) | ||
} | ||
} else { | ||
// For regular adoption, maintain existing behavior | ||
err = populated.PopulateResourceFromAnnotation(adoptionFields) | ||
if err != nil { | ||
return nil, err | ||
} |
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.
👍
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.
For this one, we were planning on implementing a different method.
Instead of PopulateResourceFromAnnotation
we can give the method context of whether it is adopt
or adopt-or-create
. This will allow it to either Populate both Spec and Status, or only Status.
Honestly i'm not sure what the expected Error should be if you need to provide a required field in Status on adopt-or-create
but you fail to do so. Should that be a terminal error? Or just return nothing, and just create the resource...
cc: @gfaraj @havard024
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.
I'm open to suggestions here, what I was trying to solve for here is that in the process of doing my migration, I found that I had some resources that were setup incorrectly and were not standardized. So I want to standardize them in one shot rather than doing first getting the reconciler to accept the adopted policy, then go and remove the extra code that I was just doing to be able to adopt the resource.
If this is in line with what y'all need to, or you need me to add some more branching logic, totally up to adding that in 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.
Can you test your use case with the latest released controllers? I believe this issue came up before, and we just cut releases for it today..
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.
can you also create an issue describing the issue you encountered? just in case we also have it in other controllers
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.
Done! aws-controllers-k8s/community#2481 I'll also update that in the PR description
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.
Thank you @JonathanGraniero
just responded on the Github issue. I believe this was resolved in the latest release
Issue: aws-controllers-k8s/community#2481
Description of changes:
When using the
adopt-or-create
annotation, the current functionality is that it will come up with reconcile errors if you are trying to adopting an existing resource on second reconcile. What is happening is that when there are differences in the spec compared to what is deployed, it's error'ing out and failing due to a mismatch on resources.In most cases, the resource values in ACK should be the accepted source of truth and this should be an upsert.
The goal of this PR is that the desired manifest should be set as the latest manifest, so that when the controller reconciles the changes, it overrides the deployed values with the values in the spec section from the resource manifest.
For example, I have a queue named
my-queue
that is currently deployed. All of the resources are the same as below. The exception would bevisibilityTimeout
which is set at300
.I would expect the visibility timeout to be updated on my deployed queue to be 30 rather than the 300 that is currently deployed. The current behavior is that this would fail to reconcile due to a mismatch on the field.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.