-
Notifications
You must be signed in to change notification settings - Fork 238
bug: verify existing ownership of CRD managed by ResourceGraphDefinition to prevent conflict #562
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
d92d623
to
87caeae
Compare
Thankyou for the PR. Would you please rebase to latest main. ? |
aOwnerName := a.Labels[ResourceGraphDefinitionNameLabel] | ||
aOwnerID := a.Labels[ResourceGraphDefinitionIDLabel] | ||
|
||
bOwnerName := b.Labels[ResourceGraphDefinitionNameLabel] | ||
bOwnerID := b.Labels[ResourceGraphDefinitionIDLabel] |
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 we also check for the existence of these labels, for example aOwnerName, ok := ...
. I believe If those labels don't exist we should return false or an error saying labels are missing. Also can we have some unit tests for it?
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.
Apologies for the delay in responding. I added a test cases including when there are no ownership labels. Is that sufficient?
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.
Yep that's great, tahnks!
Unknown CLA label state. Rechecking for CLA labels. Send feedback to sig-contributor-experience at kubernetes/community. /check-cla |
ping @a-buck any chance you can take a look at this? |
…ion to prevent conflict this prevents 2 ResourceGraphDefinitions fighting to manage the same CRD Signed-off-by: abuck <abuck@spotify.com>
Signed-off-by: abuck <abuck@spotify.com>
62e337e
to
e6e845f
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: a-buck 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 |
Signed-off-by: abuck <abuck@spotify.com>
e6e845f
to
13bc019
Compare
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.
Neat - thank you @a-buck! I left a few comments below
return ok && booleanFromString(v) | ||
} | ||
|
||
// HasMatchingKROOwner returns true if resources have the same RGD owner |
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: can you document that the caller is reponsible of making sure that kro labels exist? otherwise we can just delegate this existance check to this function.
}) | ||
} | ||
|
||
func (w *CRDWrapper) verifyNoConflict(existingCRD *v1.CustomResourceDefinition, newCRD v1.CustomResourceDefinition) 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.
nit: s/verifyNoConflict/verifyOwnership/
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 please add a comment/godoc explaining why we need to check this
cc @a-buck are you still working on this? |
Hi 👋 This PR intends to fix #554. This is my first first PR to the project - please don't hesitate to give me feedback.
This PR adds a check to verify ownership of the CRD created by a ResourceGraphDefinition, and returns an error if the CRD already exists (not managed by KRO), or exists and is managed by a different ResourceGraphDefinition.
Example: Given a CustomResourceDefinition that pre-exists and is managed by another ResourceGraphDefinition
If another ResourceGraphDefinition is created that also attempts to manage this CRD, an error will be surfaced in the status. I trimmed some fields for brevity