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

fix(k8s): fix scope assignment to the resource #12879

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lukidzi
Copy link
Contributor

@lukidzi lukidzi commented Feb 18, 2025

Motivation

While working on another issue I noticed that we incorrectly set the scope for Kubernetes CRDs.

Implementation information

When isNamespaced set scope Namespaced

@lukidzi lukidzi requested a review from a team as a code owner February 18, 2025 12:36
@lukidzi lukidzi changed the title chore(k8s): fix scope assignment to the resource fix(k8s): fix scope assignment to the resource Feb 18, 2025
Copy link
Contributor

Reviewer Checklist

🔍 Each of these sections need to be checked by the reviewer of the PR 🔍:
If something doesn't apply please check the box and add a justification if the reason is non obvious.

  • Is the PR title satisfactory? Is this part of a larger feature and should be grouped using > Changelog?
  • PR description is clear and complete. It Links to relevant issue as well as docs and UI issues
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as an image registry)
  • IPv6 is taken into account (.e.g: no string concatenation of host port)
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • Don't forget ci/ labels to run additional/fewer tests
  • Does this contain a change that needs to be notified to users? In this case, UPGRADE.md should be updated.
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)

Copy link
Contributor

@Icarus9913 Icarus9913 left a comment

Choose a reason for hiding this comment

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

2 Questions:

  • If we changed the +kubebuilder:resource:scope=Namespaced marker, we need to generate the new k8s CRD yaml right?
  • Do we need to touch the legacy policies?

@lukidzi
Copy link
Contributor Author

lukidzi commented Feb 19, 2025

If we changed the +kubebuilder:resource:scope=Namespaced marker, we need to generate the new k8s CRD yaml right?

I don't think we need to generate new CRD the scope change touches only <LegacyPolicy>List which I belive it's not CRD only <LegacyPolicy> is a CRD

Do we need to touch the legacy policies?

The error was only here

Copy link
Contributor

@lahabana lahabana left a comment

Choose a reason for hiding this comment

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

This change has no other side effects? Interesting...

@lahabana
Copy link
Contributor

I don't think we need to generate new CRD the scope change touches only List which I belive it's not CRD only is a CRD

Is it maybe unecessary then?

@lukidzi
Copy link
Contributor Author

lukidzi commented Feb 19, 2025

I feel that these functions are used in kube clients for .List(), but there is no corresponding CRD for them. I wanted to keep it consistent. Additionally, if we later need to check whether an object is namespace-scoped or cluster-scoped for some operation, the current approach might return incorrect results (though only at the code level).

@lahabana
Copy link
Contributor

Do we need these annotations yes or no?

@lukidzi
Copy link
Contributor Author

lukidzi commented Feb 19, 2025

Do we need these annotations yes or no?

No, we don't

https://kubernetes.io/docs/reference/using-api/api-concepts/#collections

Keep in mind that the Kubernetes API does not have a kind named List.

kind: List is a client-side, internal implementation detail for processing collections that might be of different kinds of object. Avoid depending on kind: List in automation or other code.

@Icarus9913
Copy link
Contributor

OK, it's *List. So the comment marker would not impact the CRD, you're right.

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

Successfully merging this pull request may close these issues.

3 participants