You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "villebro (via GitHub)" <gi...@apache.org> on 2026/09/13 16:45:00 UTC

[PR] fix(rbac): grant supersets/finalizers for owner references [superset-kubernetes-operator]

villebro opened a new pull request, #359:
URL: https://github.com/apache/superset-kubernetes-operator/pull/359

   ## Summary
   
   Creating a `Superset` instance fails to reconcile on OpenShift with:
   
   ```
   reconciling ServiceAccount: serviceaccounts "superset" is forbidden: cannot set
   blockOwnerDeletion if an ownerReference refers to a resource you can't set
   finalizers on: , <nil>
   ```
   
   The operator stamps `blockOwnerDeletion` owner references on every child object it creates (ServiceAccounts, Deployments, Services, Jobs, HPAs, PDBs, ConfigMaps, …) via `controllerutil.SetControllerReference`. When the `OwnerReferencesPermissionEnforcement` admission plugin is active — which it is **by default on OpenShift**, but not on upstream Kubernetes — the API server rejects those references unless the actor holds `update` on the owning CR's finalizers subresource (`superset.apache.org/supersets/finalizers`). The operator's RBAC never granted it, so reconciliation fails on the first owned child the API server validates (the ServiceAccount). This is why the bug reproduces on OpenShift but slips past typical Kind-based dev/e2e clusters.
   
   This affects **v0.2.0 and `main`**.
   
   Fixes #357.
   
   ## Details
   
   - Add `// +kubebuilder:rbac:groups=superset.apache.org,resources=supersets/finalizers,verbs=update` and regenerate `config/rbac/role.yaml`. `update` is the verb the admission plugin checks; the fix uses the specific `supersets/finalizers` resource rather than a broad `*/finalizers` to stay least-privilege.
   - Mirror the rule in the hand-maintained Helm `managerRules` helper (`charts/superset-operator/templates/_helpers.tpl`), which renders into both the cluster-scoped `ClusterRole` and per-namespace `Role`s, so both install modes are fixed.
   - No controller logic changes — the operator registers no finalizer on the `Superset` CR itself; this is purely the RBAC grant that `blockOwnerDeletion` requires.
   
   ### Tests
   
   - `TestManagerRole_GrantsFinalizersForOwnerReferences` — regression guard asserting the generated ClusterRole grants `update` on `supersets/finalizers`.
   - `TestHelmManagerRulesMatchGeneratedClusterRole` — drift guard comparing the generated ClusterRole rules against the Helm `managerRules` helper (the two are independent RBAC sources), so they can no longer silently diverge. Verified it fails when the rule is present in one source but not the other.
   
   The existing least-privilege guard `TestManagerRole_GrantsNoSecretsAccessOrWildcards` still passes (the specific finalizers rule uses no wildcards).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(rbac): grant supersets/finalizers for owner references [superset-kubernetes-operator]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #359:
URL: https://github.com/apache/superset-kubernetes-operator/pull/359#issuecomment-5654638823

   ## [Codecov](https://app.codecov.io/gh/apache/superset-kubernetes-operator/pull/359?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 93.25%. Comparing base ([`f38a92f`](https://app.codecov.io/gh/apache/superset-kubernetes-operator/commit/f38a92fc384e0a03179c16c5e495536bf48165c6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`409971c`](https://app.codecov.io/gh/apache/superset-kubernetes-operator/commit/409971c7f4ff2c9dd44bfc38d58d0568c3c59e54?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset-kubernetes-operator/pull/359?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(rbac): grant supersets/finalizers for owner references [superset-kubernetes-operator]

Posted by "madhushreeag (via GitHub)" <gi...@apache.org>.
madhushreeag commented on code in PR #359:
URL: https://github.com/apache/superset-kubernetes-operator/pull/359#discussion_r4002734357


##########
internal/controller/security_test.go:
##########
@@ -193,3 +183,103 @@ func TestManagerRole_GrantsNoSecretsAccessOrWildcards(t *testing.T) {
 		}
 	}
 }
+
+// TestManagerRole_GrantsFinalizersForOwnerReferences guards against a
+// regression of issue #357. The operator stamps blockOwnerDeletion owner
+// references on every child object via controllerutil.SetControllerReference;
+// the OwnerReferencesPermissionEnforcement admission plugin (enabled by default
+// on OpenShift) rejects those unless the operator can write the owning CR's
+// finalizers subresource, which requires this RBAC grant.
+func TestManagerRole_GrantsFinalizersForOwnerReferences(t *testing.T) {
+	role := loadManagerClusterRole(t)
+
+	if !ruleGrants(role.Rules, "superset.apache.org", "supersets/finalizers", "update") {
+		t.Errorf("manager ClusterRole must grant 'update' on supersets/finalizers so blockOwnerDeletion "+
+			"owner references are accepted (issue #357); rules: %+v", role.Rules)
+	}
+}
+
+// TestHelmManagerRulesMatchGeneratedClusterRole guards against RBAC drift
+// between the two independent sources of the operator's manager rules: the
+// generated config/rbac/role.yaml (from +kubebuilder:rbac markers) and the
+// hand-maintained Helm helper. They render into the deployed ClusterRole and
+// per-namespace Roles respectively, so a rule added to one but not the other
+// silently under- or over-privileges one install path.
+func TestHelmManagerRulesMatchGeneratedClusterRole(t *testing.T) {

Review Comment:
   One thought here - when this test fails, it tells you to run `make manifests` and then go hand-edit `_helpers.tpl` to match. So we've automated the detecting, but the fixing is still a manual chore someone has to remember.
   The chart already pulls generated CRDs in automatically via make `helm-sync-crds`. Could we do the same for the rules - a `helm-sync-rbac` that rewrites the `managerRules` block straight from `config/rbac/role.yaml`, wrapped in BEGIN/END sentinel comments so the rest of the file is untouched? Then the two copies can't drift in the first place, and `make codegen` fixes it for you.
   
   Not blocking, this can totally be a follow-up PR if it makes sense.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(rbac): grant supersets/finalizers for owner references [superset-kubernetes-operator]

Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro merged PR #359:
URL: https://github.com/apache/superset-kubernetes-operator/pull/359


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org