Skip to content
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

Do not use version when indexing Used resources in Usage Handler #5353

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

turkenh
Copy link
Member

@turkenh turkenh commented Feb 7, 2024

Description of your changes

This PR fixes a bug in the Usage handler with multi versioned CRDs by dropping the usage of the version from the index string used by the handler.

Example Scenario:

We define the following Usage resource:

apiVersion: apiextensions.crossplane.io/v1alpha1
kind: Usage
metadata:
  name: do-not-delete-namespace
spec:
  of:
    apiVersion: kubernetes.crossplane.io/v1alpha1
    kind: Object
    resourceRef:
      name: ns-test-namespace
  reason: Namespace should not be deleted

For the following Object:

apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
  name: ns-test-namespace
spec:
  forProvider:
    manifest:
      apiVersion: v1
      kind: Namespace
      metadata:
        name: test-namespace
  readiness:
    policy: SuccessfulCreate

And we're running the latest provider kubernetes which has a v1alpha2 as the storage version for Object. So, when we get the Object back after creation, we already see the version as v1alpha2.

Prior to this PR, deletion of the ns-test-namespace Object is not blocked by the Usage since we were using the version in the indexer, so v1alpha1 Objects blocked but not v1alpha2s. With this PR, we will drop the version from the index, hence it will block Objects independent of versions.

Related previous discussion: #4215 (comment)

Need help with this checklist? See the cheat sheet.

Signed-off-by: Hasan Turken <turkenh@gmail.com>
Copy link
Contributor

@phisco phisco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @turkenh!

@phisco phisco changed the title Do not use version with indexing Used resources in Usage Handler Do not use version when indexing Used resources in Usage Handler Feb 7, 2024
@phisco phisco merged commit 9db12b7 into crossplane:master Feb 7, 2024
20 checks passed
Copy link

github-actions bot commented Feb 7, 2024

Backport failed for release-1.14, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-1.14
git worktree add -d .worktree/backport-5353-to-release-1.14 origin/release-1.14
cd .worktree/backport-5353-to-release-1.14
git switch --create backport-5353-to-release-1.14
git cherry-pick -x f3f5ece2f65afc19ea8d16c88e5ef12889e8d813

Copy link

github-actions bot commented Feb 7, 2024

Successfully created backport PR for release-1.15:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants