feat(mpi): add --disable-mpi-rbac-management flag#1
Conversation
|
@cheyang, could you please review this PR? Thanks in advance. |
62f5b57 to
a5ad06a
Compare
When the flag is set to true, the MPIJob controller skips creating ServiceAccount, Role, and RoleBinding, skips injecting ServiceAccountName into the launcher pod, and skips watching RBAC resources. Users must pre-provide a ServiceAccount with sufficient permissions via the launcher pod template's spec.serviceAccountName. ConfigMap creation and kubectl delivery remain unconditional. Signed-off-by: Vico Chu <vico24826@gmail.com>
Add integration test that starts a second envtest instance with DisableMPIRBACManagement=true and verifies: - No Role/RoleBinding/ServiceAccount created by the operator - ConfigMap and kubectl delivery init container still created - Role changes do not trigger reconcile (watch suppressed) - ConfigMap changes still trigger reconcile (positive control) - Launcher pod recreated only after ConfigMap-triggered reconcile Also adds kubectl delivery init container assertion to pin the spec invariant that kubectl delivery remains unconditional. Signed-off-by: Vico Chu <vico24826@gmail.com>
a5ad06a to
b847f6b
Compare
cheyang
left a comment
There was a problem hiding this comment.
Reviewed the feature end to end and ran the MPI envtest suite against this PR head — the added “disabled RBAC management” specs pass. The gating is consistent across the three sites (watch setup, ReconcilePods, launcher SA injection), and since podSpec is a DeepCopy of the launcher template, a user-supplied serviceAccountName is correctly preserved when the flag is on. Two things worth addressing before merge, plus a docs gap (inline).
There was a problem hiding this comment.
Pull request overview
Adds a new --disable-mpi-rbac-management flag to allow the MPIJob controller to run without creating/watching launcher RBAC resources, enabling reduced-privilege / multi-tenant deployments where users provide their own ServiceAccount.
Changes:
- Gate RBAC watches (Role/RoleBinding/ServiceAccount) behind
DisableMPIRBACManagement. - Skip launcher ServiceAccount/Role/RoleBinding reconciliation and ServiceAccountName injection when RBAC management is disabled.
- Add CLI/config plumbing and controller tests covering the disabled-RBAC behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/controller.v1/mpi/mpijob_controller.go | Conditionally disables RBAC watches, RBAC resource creation, and SA name injection based on the new config flag. |
| pkg/controller.v1/mpi/mpijob_controller_test.go | Adds envtest coverage verifying no RBAC resources are created and controller still reconciles correctly when disabled. |
| pkg/config/config.go | Adds DisableMPIRBACManagement to shared controller config. |
| cmd/training-operator.v1/main.go | Wires up the --disable-mpi-rbac-management CLI flag. |
Comments suppressed due to low confidence (1)
pkg/controller.v1/mpi/mpijob_controller_test.go:711
- This test resets DisableMPIRBACManagement to false unconditionally. Restoring the previous value reduces coupling to global state and avoids surprising behavior if the suite default ever changes.
ctlrconfig.Config.DisableMPIRBACManagement = true
defer func() {
ctlrconfig.Config.DisableMPIRBACManagement = false
}()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add kubectl delivery init container check to the first disabled RBAC test context, mirroring the assertion in the SetupWithManager test. Both ConfigMap creation and kubectl delivery are unconditional (not gated by the flag), so both should be verified when the flag is true. Signed-off-by: Vico Chu <vico24826@gmail.com>
5bdb068 to
e95f639
Compare
…cceeds Signed-off-by: Vico Chu <vico24826@gmail.com>
…ment help text Specify that the user-provided ServiceAccount needs a Role granting get, list, watch on pods and create on pods/exec, matching the permissions that newLauncherRole would have granted. Signed-off-by: Vico Chu <vico24826@gmail.com>
…ncher template Signed-off-by: Vico Chu <vicochu@gmail.com>
d11ef50 to
8f8a791
Compare
What this PR does / why we need it:
Adds a new
--disable-mpi-rbac-managementCLI flag (default:false) to the MPIJob controller. When set totrue, the controller will:This allows operators to run with reduced privileges and supports multi-tenant environments where users pre-provide their own ServiceAccount with the necessary permissions (
pods get/list/watch,pods/exec create) viaspec.serviceAccountNamein the launcher pod template.Which issue(s) this PR fixes (optional, in
Fixes #<issue number>, #<issue number>, ...format, will close the issue(s) when PR gets merged):Fixes #
Checklist:
- [ ] Docs included if any changes are user facing