Repository navigation
RFC: Deprecate and remove RecreateRBGOnPodRestart restart policy #339
Description
Summary
This RFC proposes deprecating and removing the RecreateRBGOnPodRestart restart policy and its associated Pod Controller from the RBG project.
Motivation
The RecreateRBGOnPodRestart policy was originally designed to recreate all workloads in an RBG when any pod experiences a restart (container crash, pod deletion, etc.). In practice, this policy has no valid production use case — operators overwhelmingly prefer finer-grained restart strategies like RecreateRoleInstanceOnPodRestart (which recreates only the affected instance) or None (which relies on the workload controller's native replacement logic).
Meanwhile, the implementation introduces significant architectural complexity and operational risk:
1. Dual-controller pod management creates state races
The RecreateRBGOnPodRestart policy requires a dedicated Pod Controller that watches all pod events and independently manages RBG status conditions (RestartInProgress). This creates a race condition between the Pod Controller and the RBG Controller:
- Both controllers write to
rbg.status.conditionsusing Server-Side Apply withForce=true - The RBG Controller can overwrite the Pod Controller's condition updates, causing
RestartInProgress=Trueto become permanently stuck - This manifests as flaky e2e tests that are difficult to reproduce and fix reliably
2. Increased control plane pressure
The Pod Controller watches all pods labeled with RBG ownership and triggers full RBG reconciliation on any pod event (restarts, deletions, status changes). This amplifies the number of API server requests and reconciliation cycles, particularly in large clusters with many RBG-managed workloads.
3. Code complexity with no offsetting value
The feature adds:
- An entire controller (
pod_controller.go) with its own event filtering, RBAC, and reconciliation logic - A
RecreateWorkloadmethod on everyWorkloadReconcilerimplementation (Deployment, StatefulSet, LeaderWorkerSet, RoleInstanceSet) - A dedicated status condition type (
RestartInProgress) with its own lifecycle management - Special-case field manager handling to attempt (unsuccessfully) to avoid SSA conflicts
All of this complexity serves a policy that no known deployment uses in production.
Proposal
- Remove the
RecreateRBGOnPodRestartenum value from theRestartPolicyfield in bothv1alpha1andv1alpha2API versions - Remove the Pod Controller entirely
- Remove the
RestartInProgresscondition type - Remove the
RecreateWorkloadmethod from theWorkloadReconcilerinterface - Update CRD validation to only allow
{None, RecreateRoleInstanceOnPodRestart}
Migration Path
- Existing RBGs with
restartPolicy: RecreateRBGOnPodRestartshould be updated to either:RecreateRoleInstanceOnPodRestart— recreates the affected role instance (recommended for most distributed workloads)None— relies on the workload controller's native pod replacement (recommended for stateless workloads)
- Since this is an alpha API, breaking changes are acceptable per Kubernetes API conventions
Alternatives Considered
Fix the race condition with separate field managers: We attempted to use distinct SSA field managers (rbg vs rbg-pod-controller) to allow independent ownership of different conditions. While this resolves the immediate conflict, it doesn't address the fundamental architectural issue of dual-controller pod management or the unnecessary control plane pressure.
References
- Related flaky test investigation:
RestartInProgresscondition stuck atTrueindefinitely due to SSA race between controllers - Kubernetes SSA documentation on field ownership and
Force=truesemantics
Activity
chore(rbg): deprecate and remove RecreateRBGOnPodRestart restart poli…