Skip to content

fix(chart): gate main ClusterRole rules by engine and provider - #432

Merged
dmitsh merged 1 commit into
NVIDIA:mainfrom
teerthsharma:codex/rbac-gating-386
Aug 19, 2026
Merged

fix(chart): gate main ClusterRole rules by engine and provider#432
dmitsh merged 1 commit into
NVIDIA:mainfrom
teerthsharma:codex/rbac-gating-386

Conversation

@teerthsharma

@teerthsharma teerthsharma commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #386.

The main Topograph API server ClusterRole renders the same Kubernetes RBAC rules regardless of the selected engine and provider. A chart installed with a combination that never reaches the Kubernetes API — for example provider: test with engine: slurm — is still granted pods list, nodes get/list, and daemonsets get cluster-wide.

This change gates the main ClusterRole rules on engine.name and provider.name, extending the gating pattern already applied to pods/exec, configmaps, and nodes patch.

Gating

Rule Rendered when
nodes get,list engine k8s, slinky, nfd, or provider dra, infiniband-k8s
nodes patch engine k8s or slinky (unchanged)
pods list engine slinky or provider infiniband-k8s
daemonsets get provider infiniband-k8s
configmaps create,get,update engine slinky (unchanged)
pods/exec create provider infiniband-k8s, or Slinky partition discovery (unchanged)

The ClusterRole and ClusterRoleBinding are omitted entirely when no rule applies. The namespaced NFD Role and RoleBinding are unaffected and continue to render for engine: nfd. There is no change to the node-observer or node-data-broker RBAC, to any values schema key, or to any Go code.

Validation

From PR head c71a7b0 rebased on main at 6466969, helm v4.1.1 with helm-unittest 1.1.1:

  • helm lint charts/topograph: 1/1 chart linted, 0 failed.
  • helm unittest charts/topograph: 141/141 tests passed across 19/19 suites, 153/153 snapshots passed.

The rbac suite adds coverage for the dra provider (nodes without pods or daemonsets), the infiniband-k8s provider (pods, daemonsets, and pods/exec), the nfd engine (nodes without pods or node patch), the slurm engine with a Kubernetes provider (ClusterRole still rendered), and test + slurm (0 documents rendered).

Snapshot deltas are confined to the ClusterRole document in seven umbrella renders: pods list and daemonsets get drop from the four k8s-engine renders, and daemonsets get drops from the three slinky renders. The values.k8s.ib-example.yaml snapshot is unchanged, which is the control — infiniband-k8s retains both rules.

Limits

The gates read Helm values, while /v1/generate accepts provider.name and engine.name in the request payload and falls back to the configured values only when the request omits them (pkg/server/http_server.go:181). A deployment installed for one combination and sent a request naming a Kubernetes-backed engine or provider will receive Forbidden from the API server. This mismatch predates the change — main already gates pods/exec, configmaps, and nodes patch the same way — but the change widens the surface it applies to. Constraining request-time selection to the configured values, or documenting the deployment contract, is a separate decision for maintainers.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • All commits are signed off per DCO (git commit -s).

@copy-pr-bot

copy-pr-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@teerthsharma
teerthsharma marked this pull request as ready for review July 26, 2026 21:34
@greptile-apps

greptile-apps Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR narrows the main Topograph server’s Kubernetes permissions according to its configured engine and provider.

  • Gates node, pod, daemonset, ConfigMap, and pod-exec rules independently.
  • Omits the main ClusterRole and ClusterRoleBinding when none of those rules apply.
  • Extends Helm RBAC tests and updates affected rendering snapshots and the changelog.

Confidence Score: 4/5

This PR should not merge until request-time engine and provider selection is reconciled with the install-time RBAC gates.

The main role is still rendered solely from Helm values, while generate requests may override those values with any registered engine or provider; selecting a Kubernetes-backed component whose permissions were omitted causes its Kubernetes API operations to fail.

Files Needing Attention: charts/topograph/templates/rbac.yaml and pkg/server/http_server.go

Important Files Changed

Filename Overview
charts/topograph/templates/rbac.yaml Introduces engine/provider-derived flags that conditionally render individual main-server RBAC rules and the enclosing ClusterRole and binding.
charts/topograph/tests/rbac_test.yaml Adds coverage for DRA, InfiniBand Kubernetes, NFD, Slinky, and non-Kubernetes engine/provider combinations.
charts/topograph/tests/snapshot/render_snapshot_test.yaml.snap Updates chart snapshots to reflect removal of pod and daemonset permissions from combinations that do not require them.
CHANGELOG.md Documents the newly gated main-server Kubernetes permissions.

Reviews (2): Last reviewed commit: "fix(chart): gate main ClusterRole by eng..." | Re-trigger Greptile

Comment thread charts/topograph/templates/rbac.yaml Outdated
@teerthsharma
teerthsharma marked this pull request as draft July 26, 2026 22:04
@dmitsh

dmitsh commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Hi @teerthsharma, just wanted to check if you’re planning to continue working on this PR. If so, could you please rebase it on the latest main branch when you have a chance?
If you’re no longer planning to work on it, no problem at all. Just let us know, and we can take it over from here.
Thanks!

@teerthsharma

Copy link
Copy Markdown
Contributor Author

Hi @teerthsharma, just wanted to check if you’re planning to continue working on this PR. If so, could you please rebase it on the latest main branch when you have a chance? If you’re no longer planning to work on it, no problem at all. Just let us know, and we can take it over from here. Thanks!

Will rebase clear & merge conflicts , always up to work !! Shall I make it open for review after rebasing?

Signed-off-by: teerth sharma <teerth.2428010112@muj.manipal.edu>
@teerthsharma
teerthsharma force-pushed the codex/rbac-gating-386 branch from f9b0348 to c71a7b0 Compare August 19, 2026 08:02
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 087bc6f5-70f2-41c0-823b-ca1b6f16ccde

📥 Commits

Reviewing files that changed from the base of the PR and between 6466969 and c71a7b0.

⛔ Files ignored due to path filters (1)
  • charts/topograph/tests/__snapshot__/render_snapshot_test.yaml.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • CHANGELOG.md
  • charts/topograph/templates/rbac.yaml
  • charts/topograph/tests/rbac_test.yaml

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (3)
CHANGELOG.md

📄 CodeRabbit inference engine (AGENTS.md)

User-facing changes recorded in CHANGELOG.md [Unreleased] when applicable

Files:

  • CHANGELOG.md
charts/topograph/templates/**/*.yaml

📄 CodeRabbit inference engine (AGENTS.md)

Enable both ingress.enabled and gatewayAPI.enabled in the same Helm release

Files:

  • charts/topograph/templates/rbac.yaml
charts/topograph/**

⚙️ CodeRabbit configuration file

charts/topograph/**: - Check RBAC least privilege and Kubernetes API compatibility.

  • ingress.enabled and gatewayAPI.enabled must remain mutually exclusive.
  • HTTPRoute must contain only portable Gateway API v1 fields.
  • Flag changes where values, schema, templates, NOTES, tests,
    snapshots, documentation, or changelog become inconsistent.

Files:

  • charts/topograph/templates/rbac.yaml
  • charts/topograph/tests/rbac_test.yaml
🔇 Additional comments (3)
charts/topograph/templates/rbac.yaml (1)

2-15: LGTM!

Also applies to: 25-51, 57-82, 101-102

charts/topograph/tests/rbac_test.yaml (1)

65-79: LGTM!

Also applies to: 108-185, 209-266, 328-341

CHANGELOG.md (1)

16-19: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Security

    • Reduced Kubernetes permissions to only those required by the selected engine and provider.
    • Prevented unnecessary ClusterRole resources from being created for unsupported combinations.
    • Added targeted access for pod execution, node updates, daemonsets, and configmaps where needed.
  • Tests

    • Expanded coverage for DRA, InfiniBand, Slinky, Slurm, NFD, and unsupported configurations.
  • Documentation

    • Documented the updated conditional Kubernetes RBAC behavior.

Walkthrough

The Helm RBAC template now gates ClusterRole resources and Kubernetes permissions by engine and provider. Chart tests cover supported and unsupported combinations. The changelog documents the security change.

Changes

RBAC gating

Layer / File(s) Summary
Engine/provider RBAC gating
charts/topograph/templates/rbac.yaml
The template conditionally renders ClusterRole resources and gates node, pod, pod exec, daemonset, and configmap permissions by engine and provider.
Provider and engine coverage
charts/topograph/tests/rbac_test.yaml, CHANGELOG.md
Tests validate permission presence, denial, and resource omission across engine/provider combinations. The changelog records the RBAC change.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to c71a7

The chart now limits ClusterRole permissions to applicable engine and provider combinations, with the affected render cases covered by passing validation. No actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Values as Helm values
  participant Template as rbac.yaml
  participant Role as ClusterRole
  participant Binding as ClusterRoleBinding
  Values->>Template: Provide engine and provider
  Template->>Role: Render required permission rules
  Template->>Binding: Render binding when a ClusterRole exists
Loading

Possibly related PRs

  • NVIDIA/topograph#439: Modifies the same RBAC template and tests for engine/provider-specific permissions.
  • NVIDIA/topograph#443: Updates the same RBAC template and tests for provider-specific Kubernetes permissions.

Suggested reviewers: ravisoundar, dmitsh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The reviewable changes satisfy the issue objectives, but snapshot regeneration cannot be verified because the snapshot file was excluded by a path filter. Verify charts/topograph/tests/snapshot/render_snapshot_test.yaml.snap was regenerated and contains only the intended RBAC rule changes.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changelog, RBAC template, and Helm tests are directly related to the linked issue and contain no evident unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main change: gating ClusterRole rules by engine and provider.
Description check ✅ Passed The description directly explains the RBAC gating changes, affected permissions, tests, and security rationale.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@dmitsh

dmitsh commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@dmitsh
dmitsh marked this pull request as ready for review August 19, 2026 11:25
@dmitsh

dmitsh commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

/ok-to-test c71a7b0

@ArangoGutierrez ArangoGutierrez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing here blocks merge.

One note on test coverage. The gating itself lines up with what each engine and provider actually calls, and the ClusterRole/ClusterRoleBinding omission for non-Kubernetes combinations reads correctly.

  1. [should-fix] This is the only case that isolates the provider's node access — every other infiniband-k8s case leaves the engine at k8s, which grants nodes on its own. It checks the document count and the absence of nodes/patch, but never that nodes get,list is present, so the new (eq $provider "infiniband-k8s") term in $needsNodes has no test behind it: dropping that term removes the nodes rule entirely for this combination and the suite still reports 141 passed / 153 snapshots passed. The same mutation on the dra term, the infiniband-k8s arm of $needsPods, and $needsDaemonSets each fail a test, so this is the one gap. A contains for apiGroups: [""] / resources: [nodes] / verbs: [get, list] at documentIndex 0 closes it, and it backs a live call at pkg/providers/infiniband/provider_k8s.go:72. (charts/topograph/tests/rbac_test.yaml:266)

apiGroups: [""]
resources: [nodes]
verbs: [patch]
documentIndex: 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only case that isolates the provider's node access — every other infiniband-k8s case leaves the engine at k8s, which grants nodes on its own. It checks the document count and the absence of nodes/patch, but never that nodes get,list is present, so the new (eq $provider "infiniband-k8s") term in $needsNodes has no test behind it: dropping that term removes the nodes rule entirely for this combination and the suite still reports 141 passed / 153 snapshots passed. The same mutation on the dra term, the infiniband-k8s arm of $needsPods, and $needsDaemonSets each fail a test, so this is the one gap. A contains for apiGroups: [""] / resources: [nodes] / verbs: [get, list] at documentIndex 0 closes it, and it backs a live call at pkg/providers/infiniband/provider_k8s.go:72.

@dmitsh
dmitsh merged commit 249f959 into NVIDIA:main Aug 19, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RBAC: engine/provider-gate the main Topograph ClusterRole (node/pod/daemonset verbs)

3 participants