-
Notifications
You must be signed in to change notification settings - Fork 66
✨ OPRUN-4113: Compute target namespace defaults #2178
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
✨ OPRUN-4113: Compute target namespace defaults #2178
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2178 +/- ##
==========================================
+ Coverage 72.73% 72.77% +0.04%
==========================================
Files 79 79
Lines 7391 7421 +30
==========================================
+ Hits 5376 5401 +25
- Misses 1667 1671 +4
- Partials 348 349 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
/lgtm
3610edf
to
14e1789
Compare
if supportedInstallModes.Has(v1alpha1.InstallModeTypeSingleNamespace) { | ||
return nil | ||
} |
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'm just noticing, but this logic (both before and after) means that an operator could support only SingleNamespace
, and we'd allow that namespace to be the install namespace.
I don't think that's correct. We should only allow watchNamespace == installNamespace
if the OwnNamespace
install mode is supported.
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 trying to look through the v0 codebase to ascertain this anb neither in the enhancement nor in code do I find this a reference to this. But, it's certainly possible (that it is and that I've missed it). Do you have a ref?
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 don't have a ref, but I do remember conversations about the distinction related to RBAC where some teams wanted to keep operator namespace separate from operand namespace.
I'll try to find a definitive ref. This is non-blocking since this PR doesn't change this logic at all.
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.
Just let me know and I'll create another issue to address this. Should be straightforward enough. And a good one to fix before we go GA with Single/OwnNamespace
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.
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.
thank you! I kept looking for references to the specific type. Lemme fix that up.
97ffd8e
to
0a263ed
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.
/lgtm
/assign @thetechnick |
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
…on on single namespace mode Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
2fcbefa
to
4fc183a
Compare
case set.Len() == 0 || (set.Len() == 1 && set.Has("")): | ||
if supportedInstallModes.Has(string(v1alpha1.InstallModeTypeAllNamespaces)) { | ||
case set.Len() == 0: | ||
if supportedInstallModes.Len() == 1 && supportedInstallModes.Has(v1alpha1.InstallModeTypeSingleNamespace) { |
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.
Trying to make sense of this. Am I understanding correctly that set.Len()
will only be 0
if we were unable to set a default target namespace, and that only happens when neither AllNamespaces
nor OwnNamespace
are supported.
And therefore, by the time we get to this code, the possibilities are:
- only
SingleNamespace
- only
MultiNamespace
- both
SingleNamespace
andMultiNamespace
And of those three cases, the only one that requires exactly one target namespace is "only SingleNamespace
. Hence the if
conditional you have here.
If that's correct. Can you add a comment that explains this a little bit? I don't think it is obvious why we aren't checking other supported install mode combinations.
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.
Also, what if someone explicitly uses option WithTargetNamespaces(nil)
or WithTargetNamespaces([]string{}])
?
The result of that would be:
- The defaulting logic runs (setting a default in the case of All or Own namespace)
- The functional option runs (unsetting the default)
So we could have set.Len() == 0
for any combination of supported install modes unless we somehow require at least one namespace to be defined with that option. What if we did this?
func WithTargetNamespaces(namespace string, extraNamespaces ...string) Option {
return func(o *Options) {
o.TargetNamespaces = append([]string{namespace}, extraNamespaces...)
}
}
That way, using WithTargetNamespaces
only accepts 1..N
namespaces, not 0..N
.
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.
While I think this change in option does guarantee that at least one namespace is specified, it's annoying to use for the caller because it will force me to break up my slice of string into components. I won't be able to do targetNamespaces..., I'd need to do something like targetNamespace[0], targetNamespaces[1:]... but that will involve length checks, etc.
I think its ok for you to specify nil or empty...the validator will pick it up.
alternatively, we could just wrap an if around it and only update the value if len(namespaces) > 0? wdyt?
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 went with my proposed solution above. I've also added more checks for MultiNamespace (no including install namespace if no OwnNamespace support)
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 points! Your solution seems like a good compromise.
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: anik120, joelanford, oceanc80 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 |
b4aeb92
into
operator-framework:main
Description
Updates registry+v1 renderer to compute target namespace defaults based on the bundle's install mode configuration:
We also update the targetNamespace validation to ensure the own namespace cannot be used unless OwnNamespace install mode is supported
Reviewer Checklist