Skip to content

Commit 67fe91b

Browse files
author
玖宇
committed
fix e2e failed
1 parent 2a34861 commit 67fe91b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

internal/controller/workloads/discovery_config_mode_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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
},

internal/controller/workloads/rolebasedgroup_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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

297299
func (r *RoleBasedGroupReconciler) shouldUseLegacyDiscoveryConfig(

0 commit comments

Comments
 (0)