-
Notifications
You must be signed in to change notification settings - Fork 155
Add opt-in RBAC management UI via rbacManagement flag #4865
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
Changes from all commits
fe5a490
7316a17
0d99f55
971bf87
73d1c97
5051f2a
b655d8f
34e17ae
4aee36e
58cef85
bb4bfc1
e4cb0e3
26b06e4
5e4bcd5
b5c1b21
b614cbf
dd12844
0089629
7c92e79
fca30bc
30c4c4e
f907d50
c665375
6ff6508
3724a80
6ffec3d
a42d5c3
99a6c3c
9140984
99f3939
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // Copyright (c) 2026 Tigera, Inc. All rights reserved. | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package v1 | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestRBACManagementEnabled(t *testing.T) { | ||
| state := func(s RBACUIStatusType) *RBACUIStatusType { return &s } | ||
|
|
||
| for _, tc := range []struct { | ||
| name string | ||
| m *Manager | ||
| want bool | ||
| }{ | ||
| // Nil paths: RBACManagementEnabled is called as managerCR.RBACManagementEnabled() | ||
| // where managerCR is nil when no Manager CR exists, so a nil receiver (and each | ||
| // nil field below) must return false rather than panic. | ||
| {name: "nil Manager", m: nil, want: false}, | ||
| {name: "nil RBACUI", m: &Manager{}, want: false}, | ||
| {name: "nil State", m: &Manager{Spec: ManagerSpec{RBACUI: &RBACUI{}}}, want: false}, | ||
|
|
||
| {name: "State Enabled", m: &Manager{Spec: ManagerSpec{RBACUI: &RBACUI{State: state(RBACUIEnabled)}}}, want: true}, | ||
| {name: "State Disabled", m: &Manager{Spec: ManagerSpec{RBACUI: &RBACUI{State: state(RBACUIDisabled)}}}, want: false}, | ||
| // Any value other than Enabled is off (the Enum marker rejects this at the | ||
| // apiserver, but the helper must not treat a non-empty value as enabled). | ||
| {name: "State unrecognized value", m: &Manager{Spec: ManagerSpec{RBACUI: &RBACUI{State: state("SomethingElse")}}}, want: false}, | ||
| } { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| defer func() { | ||
| if r := recover(); r != nil { | ||
| t.Fatalf("RBACManagementEnabled panicked on %s: %v", tc.name, r) | ||
| } | ||
| }() | ||
| if got := tc.m.RBACManagementEnabled(); got != tc.want { | ||
| t.Errorf("RBACManagementEnabled() = %v, want %v", got, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -252,6 +252,14 @@ func Add(mgr manager.Manager, opts options.ControllerOptions) error { | |||||
| return fmt.Errorf("tigera-installation-controller failed to watch primary resource: %v", err) | ||||||
| } | ||||||
|
|
||||||
| // Watch the Manager CR so changes to spec.rbac re-run the installation | ||||||
| // reconcile (the rbacsync controller in calico-kube-controllers is | ||||||
| // gated on it). | ||||||
| err = c.WatchObject(&operatorv1.Manager{}, &handler.EnqueueRequestForObject{}) | ||||||
| if err != nil { | ||||||
| return fmt.Errorf("tigera-installation-controller failed to watch Manager: %v", err) | ||||||
| } | ||||||
|
|
||||||
| // watch for change to primary resource LogCollector | ||||||
| err = c.WatchObject(&operatorv1.LogCollector{}, &handler.EnqueueRequestForObject{}) | ||||||
| if err != nil { | ||||||
|
|
@@ -1049,6 +1057,7 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile | |||||
|
|
||||||
| var managementCluster *operatorv1.ManagementCluster | ||||||
| var managementClusterConnection *operatorv1.ManagementClusterConnection | ||||||
| var managerCR *operatorv1.Manager | ||||||
| var logCollector *operatorv1.LogCollector | ||||||
| if r.enterpriseCRDsExist { | ||||||
| logCollector, err = utils.GetLogCollector(ctx, r.client) | ||||||
|
|
@@ -1071,6 +1080,12 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile | |||||
| return reconcile.Result{}, err | ||||||
| } | ||||||
|
|
||||||
| managerCR, err = utils.GetManager(ctx, r.client, false, "") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should we update GetManager to return nil, nil on NotFound? |
||||||
| if err != nil { | ||||||
| r.status.SetDegraded(operatorv1.ResourceReadError, "Error reading Manager", err, reqLogger) | ||||||
| return reconcile.Result{}, err | ||||||
| } | ||||||
|
|
||||||
| if managementClusterConnection != nil && managementCluster != nil { | ||||||
| err = fmt.Errorf("having both a managementCluster and a managementClusterConnection is not supported") | ||||||
| r.status.SetDegraded(operatorv1.ResourceValidationError, "", err, reqLogger) | ||||||
|
|
@@ -1705,7 +1720,8 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile | |||||
| // the kube-controllers component (and deleted when the WAF extension is | ||||||
| // disabled); the caBundle is the operator CA that issued the serving | ||||||
| // cert above. | ||||||
| WAFWebhookCABundle: certificateManager.KeyPair().GetCertificatePEM(), | ||||||
| WAFWebhookCABundle: certificateManager.KeyPair().GetCertificatePEM(), | ||||||
| RBACManagementEnabled: managerCR.RBACManagementEnabled(), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since utils.GetManager returns nil, nil on not found won't this now panic?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Brian-McM It shouldn't panic,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| components = append(components, kubecontrollers.NewCalicoKubeControllers(&kubeControllersCfg)) | ||||||
|
|
||||||
|
|
||||||
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.