-
Notifications
You must be signed in to change notification settings - Fork 19
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
Allow configuring a default namespace for operators #204
Allow configuring a default namespace for operators #204
Conversation
This sets the command-line flag added by the companion PR open-cluster-management-io/config-policy-controller#204 This only sets that flag when the managed cluster is using OpenShift v4. It should be noted that this flag is *not* currently configurable by the user (it is not for example exposed through an annotation). Refs: - https://issues.redhat.com/browse/ACM-9896 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
|
||
err := json.Unmarshal(policy.Spec.Subscription.Raw, &sub) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to unmarshal from spec.subscription: %w", err) |
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.
Since this becomes user facing in the status (I think), how about?
return nil, fmt.Errorf("unable to unmarshal from spec.subscription: %w", err) | |
return nil, fmt.Errorf("the policy spec.subscription is invalid: %w", err) |
// buildOperatorGroup bootstraps the OperatorGroup spec defined in the operator policy | ||
// with the apiversion and kind in preparation for resource creation | ||
func buildOperatorGroup( | ||
policy *policyv1beta1.OperatorPolicy, defaultNS string, |
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.
policy *policyv1beta1.OperatorPolicy, defaultNS string, | |
policy *policyv1beta1.OperatorPolicy, namespace string, |
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.
It would still use the namespace specified by the user if one is provided, so I feel like defaultNS
is a more accurate name. But, thinking about it, we should probably stop and alert the user if the specified namespace for the operator group does not match what the subscription will use.
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.
In which case, the parameter should just be called namespace
😆
4187afd
to
d76d6b5
Compare
I adjusted the way the relatedObjects is marked as optional, so the controller shouldn't get stuck if the cluster still has the old version of the CRD where the field is required: https://github.com/open-cluster-management-io/config-policy-controller/compare/4187afd2e0bd400b5160e0104c093675187ca9d1..d76d6b5eee52b5f3d7ed8789c0958468e7a8ad75#diff-c1ba6e7a77ddcb50f7ecdd75bd3556d38d1d58414b685c17a84953b947e5cb1cR103-R104 |
This sets the command-line flag added by the companion PR open-cluster-management-io/config-policy-controller#204 This only sets that flag when the managed cluster is using OpenShift v4. It should be noted that this flag is *not* currently configurable by the user (it is not for example exposed through an annotation). Refs: - https://issues.redhat.com/browse/ACM-9896 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
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.
/hold for the optional minor wording change
This commit only moves some definitions around so that things are in a more consistent order, which may help other refactoring work. Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
This will allow OperatorPolicies to use a default namespace when the user does not specify one in the policy. For example, on OpenShift, it's conventional to install operators to the openshift-operators namespace when they are cluster-wide. This default namespace is set via a command line flag, so it can be customized per deployment. This commit also adds a validation condition to OperatorPolicy, for reporting when the subscription or operatorgroup specs are invalid. Refs: - https://issues.redhat.com/browse/ACM-9896 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
Other status fields are not required, and this field was specifically causing an issue for the new validation condition, since it does not have any relatedObjects associated with it. This both fixes the CRD and the behavior of the controller (so that field is always set) so that if the CRD on the cluster is still the old one, the controller will not get stuck. Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
d76d6b5
to
98f2a68
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JustinKuli, mprahl 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 |
/unhold |
296b1b7
into
open-cluster-management-io:main
This sets the command-line flag added by the companion PR open-cluster-management-io/config-policy-controller#204 This only sets that flag when the managed cluster is using OpenShift v4. It should be noted that this flag is *not* currently configurable by the user (it is not for example exposed through an annotation). Refs: - https://issues.redhat.com/browse/ACM-9896 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com>
This sets the command-line flag added by the companion PR open-cluster-management-io/config-policy-controller#204 This only sets that flag when the managed cluster is using OpenShift v4. It should be noted that this flag is *not* currently configurable by the user (it is not for example exposed through an annotation). Refs: - https://issues.redhat.com/browse/ACM-9896 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com> (cherry picked from commit 010070d5d134801cb3a257bf865f216318156b58)
This sets the command-line flag added by the companion PR open-cluster-management-io/config-policy-controller#204 This only sets that flag when the managed cluster is using OpenShift v4. It should be noted that this flag is *not* currently configurable by the user (it is not for example exposed through an annotation). Refs: - https://issues.redhat.com/browse/ACM-9896 Signed-off-by: Justin Kulikauskas <jkulikau@redhat.com> (cherry picked from commit 010070d5d134801cb3a257bf865f216318156b58)
This adds a command line flag for setting a default namespace for subscriptions/operatorgroups when not specified in an OperatorPolicy spec. This will allow (for example) OpenShift clusters to default to the "openshift-operators" namespace, which is conventionally used for cluster-wide operator installations.
Note to reviewers: the first commit is just re-arranging code blocks to a more consistent order; going through the other 2 commit by commit is probably easier to read.