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
HOSTEDCP-1513: Add operator scoping support to nodepool controller #3928
Conversation
Skipping CI for Draft Pull Request. |
✅ Deploy Preview for hypershift-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@lucaspalm: This pull request references HOSTEDCP-1513 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.16.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
22235d2
to
fd412e8
Compare
support/util/util.go
Outdated
// is to accept all nodepool events in which the owning hostedcluster resource does not have a corresponding scope annotation defined. | ||
// The ENABLE_HOSTEDCLUSTERS_ANNOTATION_SCOPING env var must also be set to "true" to enable the scoping feature. | ||
func PredicatesForNodepoolAnnotationScoping(r client.Reader) predicate.Predicate { | ||
hcAnnotationScopingEnabledEnvVal := os.Getenv(EnableHostedClustersAnnotationScopingEnv) |
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: let's prefer to read these values at startup or as close to startup in main()
as we can and pass them via normal function parameters to aid in understanding control flow
support/util/util.go
Outdated
// match the "scope" annotation specified in the HOSTEDCLUSTERS_SCOPE_ANNOTATION env var. If not defined or empty, the | ||
// default behavior is to accept all events for hostedclusters that do not have the annotation. | ||
// The ENABLE_HOSTEDCLUSTERS_ANNOTATION_SCOPING env var must also be set to "true" to enable the scoping feature. | ||
func PredicatesForNodepoolChildResourcesAnnotationScoping(r client.Reader) predicate.Predicate { |
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.
Could you DRY out these helpers by passing in the function to extract the HostedCluster
's NamespacedName
from the obj client.Object
?
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.
What function are you referring to exactly? Is there one that exists already somewhere or are you saying to create one use that?
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.
The latter - it seemed like the only difference between these utilities
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.
@stevekuznetsov Check out the changes in 3c11c28. I was able to shrink down this predicate utility code quite a bit! I made sure to test these changes in a local environment to ensure the same results I was seeing before. Thanks for the idea!
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.
Nice! This looks really good!
/lgtm |
@lucaspalm: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/approve |
/override "Red Hat Konflux / hypershift-main-enterprise-contract / hypershift-operator-main" |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: csrwng, lucaspalm 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 |
@csrwng: Overrode contexts on behalf of csrwng: Red Hat Konflux / hypershift-main-enterprise-contract / hypershift-operator-main In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
54f9ed0
into
openshift:main
What this PR does / why we need it:
These changes extend the hostedcluster annotation scoping support to the nodepool controller. This feature was originally introduced in #3702, but support was only added to the hostedcluster controller at that time.
Which issue(s) this PR fixes:
https://issues.redhat.com//browse/HOSTEDCP-1513