Skip to content

Commit 0e75d4c

Browse files
Requeue disabled GPUClusterConfig to detect ClusterPolicy removal
Signed-off-by: Karthik Vetrivel <kvetrivel@nvidia.com>
1 parent 04066ee commit 0e75d4c

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎controllers/gpuclusterconfig_controller.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ func (r *GPUClusterConfigReconciler) Reconcile(ctx context.Context, req ctrl.Req
9494
if condErr := r.conditionUpdater.SetConditionsError(ctx, instance, conditions.ReconcileFailed, msg); condErr != nil {
9595
logger.Error(condErr, "failed to set condition")
9696
}
97-
return ctrl.Result{}, nil
97+
// Requeue so the ClusterPolicy's deletion is noticed and the instance
98+
// recovers; nothing watches ClusterPolicy here, mirroring the ready-path
99+
// resync below.
100+
return ctrl.Result{RequeueAfter: time.Minute}, nil
98101
}
99102

100103
// Singleton, first-wins (mirroring ClusterPolicy): the first instance to reconcile

‎controllers/gpuclusterconfig_controller_test.go‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func newGPUClusterConfigReconciler(t *testing.T, objs ...client.Object) (*GPUClu
6363
// fakeStateManager returns canned SyncState results so the controller tests don't load
6464
// real manifests. It records the last info catalog passed to SyncState so tests can
6565
// assert on its entries. GetWatchSources is promoted from the embedded (nil) interface
66-
// and is never called here — only SetupWithManager calls it, which these tests skip.
66+
// and is never called here; only SetupWithManager calls it, which these tests skip.
6767
type fakeStateManager struct {
6868
state.Manager
6969
results state.Results
@@ -117,14 +117,22 @@ func TestGPUClusterConfigReconcileNotFound(t *testing.T) {
117117

118118
// A ClusterPolicy in the cluster disables the GPUClusterConfig: the two paths are
119119
// mutually exclusive, so the DRA stack is not deployed alongside ClusterPolicy.
120+
// The result requeues so the instance recovers once the ClusterPolicy is removed.
120121
func TestGPUClusterConfigDisabledByClusterPolicy(t *testing.T) {
121122
cfg := &nvidiav1alpha1.GPUClusterConfig{ObjectMeta: metav1.ObjectMeta{Name: "config"}}
122123
cp := &gpuv1.ClusterPolicy{ObjectMeta: metav1.ObjectMeta{Name: "cluster-policy"}}
123124
r, c := newGPUClusterConfigReconciler(t, cfg, cp)
124125

125-
gccReconcile(t, r, cfg.Name)
126+
res, err := r.Reconcile(t.Context(), gccRequest(cfg.Name))
127+
require.NoError(t, err)
128+
require.Positive(t, res.RequeueAfter, "disabled instance must requeue to detect ClusterPolicy removal")
126129

127130
require.Equal(t, nvidiav1alpha1.Disabled, gccState(t, c, cfg.Name))
131+
132+
// Removing the ClusterPolicy lets the next reconcile recover the instance.
133+
require.NoError(t, c.Delete(t.Context(), cp))
134+
gccReconcile(t, r, cfg.Name)
135+
require.Equal(t, nvidiav1alpha1.Ready, gccState(t, c, cfg.Name))
128136
}
129137

130138
// First-reconciled wins (mirroring ClusterPolicy): whichever instance reconciles first

0 commit comments

Comments
 (0)