File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
internal/controller/workloads Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ func TestEnsureDiscoveryConfigMode(t *testing.T) {
3030
3131 tests := []testCase {
3232 {
33- name : "missing annotation with legacy role configmap should set legacy mode and requeue" ,
33+ name : "missing annotation with legacy role configmap should set legacy mode without requeue" ,
3434 buildExtraObjects : func (rbg * workloadsv1alpha1.RoleBasedGroup ) []runtime.Object {
3535 return []runtime.Object {
3636 & corev1.ConfigMap {
@@ -41,13 +41,13 @@ func TestEnsureDiscoveryConfigMode(t *testing.T) {
4141 },
4242 }
4343 },
44- wantRequeue : true ,
44+ wantRequeue : false ,
4545 wantMode : workloadsv1alpha1 .LegacyDiscoveryConfigMode ,
4646 wantModeAnnotation : true ,
4747 },
4848 {
49- name : "missing annotation without legacy signal should set refine mode and requeue" ,
50- wantRequeue : true ,
49+ name : "missing annotation without legacy signal should set refine mode without requeue" ,
50+ wantRequeue : false ,
5151 wantMode : workloadsv1alpha1 .RefineDiscoveryConfigMode ,
5252 wantModeAnnotation : true ,
5353 },
Original file line number Diff line number Diff line change @@ -273,7 +273,7 @@ func (r *RoleBasedGroupReconciler) ensureDiscoveryConfigMode(
273273 return false , nil
274274 }
275275
276- // determine mode, update annotation and then requeue
276+ // determine mode, update annotation
277277 legacy , err := r .shouldUseLegacyDiscoveryConfig (ctx , rbg )
278278 if err != nil {
279279 return true , err
@@ -291,7 +291,9 @@ func (r *RoleBasedGroupReconciler) ensureDiscoveryConfigMode(
291291 }
292292
293293 log .FromContext (ctx ).Info ("Initialized discovery config mode" , "mode" , mode )
294- return true , nil
294+ // Don't requeue here - continue to reconcile ConfigMap and workloads in the same loop
295+ // to avoid race condition where workload is created before ConfigMap exists
296+ return false , nil
295297}
296298
297299func (r * RoleBasedGroupReconciler ) shouldUseLegacyDiscoveryConfig (
You can’t perform that action at this time.
0 commit comments