-
Notifications
You must be signed in to change notification settings - Fork 6
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
⚠️ Re-define how related resources are configuring/found, add support for label selectors #44
Conversation
Skipping CI for Draft Pull Request. |
/test all |
… confusing This is because now, with support for label selectors, we need explicit naming on the destination side, which means the old idea of "the same thing is done on both sides to figure out the names on origin and destination" doesn't apply anymore, because the logic is now slightly different between both sides. To not ack this in the CRD will just create endless confusion. On-behalf-of: @SAP [email protected]
On-behalf-of: @SAP [email protected]
9d243a4
to
32287a9
Compare
/test all |
/test all |
On-behalf-of: @SAP [email protected]
On-behalf-of: @SAP [email protected]
On-behalf-of: @SAP [email protected]
On-behalf-of: @SAP [email protected]
…d resource On-behalf-of: @SAP [email protected]
/test all |
On-behalf-of: @SAP [email protected]
/test all |
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.
Just one teeny tiny thing.
/kind api-change |
Co-authored-by: Marvin Beckers <[email protected]>
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.
/approve
LGTM label has been added. Git tree hash: 16ef992fad35e86a5fc39688019ade8abfe9790a
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: embik 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 |
Summary
This PR significantly changes the approach the agent uses to locate related objects.
Old Approach
My original idea was:
The advantage of this approach is that mutations only happen in one place: the main object. When thinking about finding the related objects, the admin does not have to consider additional mutations/renamings, because that all happened already in the main object.
For example, if you had a certificate with
spec.secretName=my-cert
, you would mutate this spec in the main object to becomespec.secretName=$clusterName-$remoteHashYaddaYadda
, for examplespec.secretName=1otjakf7q2tyhbii-4827da5-278adfe
. And now when we want to locate it, we just follow the same path and get the correct names. Easy!Label Selectors
The approach above works fine if you use references because that always yields a fixed, known value.
But now we want to add label selectors for related resources. This can be used when there is no reference (like
spec.secretName
) in the main object. This happens for operators that just take the name of the main object and append something like-credentials
to it and use this, per convention, as the secret.The Issue with secret information
The issue is that the name of the main object usually is somewhat encoded, to ensure many workspaces do not collide on the service cluster. There is also a chance that additional, "secret" information is embedded into them (because agents might sync special customers into special namespaces with special naming rules). Long story short, the main object's name is, like every part of the sync metadata, private to the service provider and should never leak into kcp workspaces.
This also means that the names of the related objects are also considered private and we must not re-use them on the destination side of the synchronisation. But now we're in a pickle, because if we follow the old approach, we would evaluate the same label selector on both sides of the sync. On the first iteration, this will ideally find the source object, but obviously cannot yet find the destination object (we haven't create it yet). So now the agent has to decide the destination object's name by itself.
This now means that the admin, in addition to a label selector, also has to specify the naming rules for the copy of the related object. And this means that the logic is not symmetric anymore:
Asymmetry
This asymmetry is what is ultimately causing this API break. There is no sane way to express this in the old structure, without introducing a lot of extra validations (validations the OpenAPI schema cannot handle and would either require a webhook or loooots of CEL expressions) and need for documentation. Even I, who thought through all this, was confused when I began the implementation. By my own data structures no less. Because if you have naming rules, are they also used for reference-based related resources?
Since we do not have a conversion webhook and bumping API versions in Kubernetes is a major PITA, as I've just learned from kcp itself, I chose to commit an API break in this PR.
API Break
With this PR, we the configuration is extended like this. Previously this is the structure:
With this change, all configuration was moved under a new "object" key and then restructured a bit:
Label Selectors
...are currently not super useful, because you cannot use any dynamic values in them, like variables. The old approach of having a custom variable syntax ("foo$bar") is reaching its limits and so we plan on replacing it with Go template strings. But this will be done in another PR and that PR will then add support for templated strings to the selectors.
Multiple Related Objects
Since we now have support for label selectors, a single related resource can select many objects. And this is now supported by the agent. It's not super convenient yet (the annotation on the primary object that links to the related object(s) is a bit ugly with a counter at the end, but it works).
Related issue(s)
Fixes #31
Release Notes