Repository navigation
✨ Adopt ClusterObjectDeployment only when not controlled by another owner #3077
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
Open
perdasilva
wants to merge
3
commits into
operator-framework:main
Choose a base branch
from
perdasilva:adopt-clusterobjectdeployment-no-controller-ref
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+193
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| @BoxcutterRuntime | ||
| Feature: ClusterExtension refuses to adopt a ClusterObjectDeployment owned by another resource | ||
|
|
||
| As an OLM user, I want a ClusterExtension to report and retry an adoption conflict, | ||
| so that it does not take over a ClusterObjectDeployment controlled by another owner | ||
| and can proceed after that deployment is removed. | ||
|
|
||
| Background: | ||
| Given OLM is available | ||
| And an image registry is available | ||
| And namespace "${TEST_NAMESPACE}" is available | ||
| And a catalog "test" with packages: | ||
| | package | version | channel | replaces | contents | | ||
| | test | 1.2.0 | beta | | CRD, Deployment, ConfigMap | | ||
|
|
||
| Scenario: ClusterExtension retries after a foreign-owned deployment is removed | ||
| Given ClusterObjectDeployment with Namespace owner "${TEST_NAMESPACE}" is applied | ||
| """ | ||
| apiVersion: olm.operatorframework.io/v1 | ||
| kind: ClusterObjectDeployment | ||
| metadata: | ||
| name: ${NAME} | ||
| spec: | ||
| template: | ||
| spec: | ||
| collisionProtection: Prevent | ||
| phases: | ||
| - name: resources | ||
| objects: [] | ||
| """ | ||
| When ClusterExtension is applied | ||
| """ | ||
| apiVersion: olm.operatorframework.io/v1 | ||
| kind: ClusterExtension | ||
| metadata: | ||
| name: ${NAME} | ||
| spec: | ||
| namespace: ${TEST_NAMESPACE} | ||
| source: | ||
| sourceType: Catalog | ||
| catalog: | ||
| packageName: ${PACKAGE:test} | ||
| version: 1.2.0 | ||
| selector: | ||
| matchLabels: | ||
| "olm.operatorframework.io/metadata.name": ${CATALOG:test} | ||
| """ | ||
| Then ClusterExtension reports Progressing as True with Reason Retrying and Message includes: | ||
| """ | ||
| ClusterObjectDeployment "${NAME}" is already controlled by Namespace "${TEST_NAMESPACE}" | ||
| """ | ||
| When resource "clusterobjectdeployment/${NAME}" is removed | ||
| Then ClusterExtension is rolled out | ||
| And ClusterExtension is available | ||
| And ClusterObjectDeployment "${NAME}" is owned by ClusterExtension "${NAME}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If the controller owner matches on Group, Kind, Name, I think we should adopt. That would mean that the CE with the expected name was deleted and re-created (which is possible in a backup/restore situation)
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.
Good call — done.
checkAdoptablenow also adopts when the existing deployment's controllerRef matches the ClusterExtension by group + kind + name but carries a different UID (the delete-and-recreate / backup-restore case); a genuinely different owner (different name or kind) still gets the terminal refuse. The server-side apply then re-stamps the current UID as the sole controller (verified there's no dual controller ref). Added a unit test for the prior-incarnation case.Uh oh!
There was an error while loading. Please reload this page.
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 was doing some tests around this area. It seems like Kubernetes GC will delete an object whose owner ref points to an unknown UID, even if the rest of the owner ref fields match an existing object by name/group/kind.
So it may be that the original test using just UID is fine. I'll verify what I think I saw. If true, I think we can use the simpler approach.
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.
Confirmed. Objects with unknown UID'd controller refs are GC'd.