-
Notifications
You must be signed in to change notification settings - Fork 239
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
wip:fix: don't assign external #3261
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
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.
@gemmahou let's use this comment thread. The problem persists in the new refactor too.
For instance, if a code block (or control flow) calls the function twice for a reference defined with r.Name
:
ref.ResolveExternal(...) // this one assigns the External value
ref.ResolveExternal(...) // this one sees the External assigned and the Name used so errors out...
The error will be cannot specify both name and external on reference
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.
Gotcha!
I'm thinking why we don't encounter this error during direct reconciliation of current resources: Since we always use a brand new object(code) when calling the resolver, and only resolve it once. It seems unnecessary to resolve it again unless there's a reason I'm not aware of?
We must have the resolved value assigned to External because we need it when converting KRM object proto(code). Here's another example in the mapper I wrote for compute resource.
Could you explain more on the error and maybe share the error message? I think it's intended to resolve and assign to r.External. I'm working on some refactoring on the resource_references.go code. New function looks like:
|
The canonical example for reference handling is that we either pass in:
Consider this example
k8s-config-connector/pkg/test/resourcefixture/testdata/basic/bigqueryanalyticshub/v1alpha1/bigqueryanalyticshublisting-base/create.yaml
Lines 23 to 25 in bcf1e3e
If the NormlizedExternal checks that only one of
r.External
orr.Name
is set BUT assignsr.External
at the end, future calls to this function will error out. IOW, the function is not idempotent and I think it should be because we may be calling this function repeatedly throughout the reconciliation of a resource.