Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/controller/admissionchecks/multikueue/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,14 @@ func (w *wlReconciler) nominateAndSynchronizeWorkers(ctx context.Context, group
for workerName := range group.remotes {
nominatedWorkers = append(nominatedWorkers, workerName)
}
if group.local.Status.ClusterName == nil && !equality.Semantic.DeepEqual(group.local.Status.NominatedClusterNames, nominatedWorkers) {

if !equality.Semantic.DeepEqual(group.local.Status.NominatedClusterNames, nominatedWorkers) {
// ClusterName != nil indicates possibly stale cache (eviction just cleared ClusterName
// but the informer hasn't caught up yet). Avoid creating remote workloads without a
// confirmed nomination — wait for the cache to sync.
if group.local.Status.ClusterName != nil {
return reconcile.Result{}, nil
}
if err := workload.PatchAdmissionStatus(ctx, w.client, group.local, w.clock, func(wl *kueue.Workload) (bool, error) {
wl.Status.NominatedClusterNames = nominatedWorkers
return true, nil
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/admissionchecks/multikueue/workload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,7 @@ func TestNominateAndSynchronizeWorkers_MoreCases(t *testing.T) {
dispatcherMode string
remotes map[string]*kueue.Workload
nominatedWorkers []string
localClusterName *string
cond *metav1.Condition
createErr error
wantCreated []string
Expand All @@ -2139,6 +2140,13 @@ func TestNominateAndSynchronizeWorkers_MoreCases(t *testing.T) {
remotes: map[string]*kueue.Workload{remoteNames[0]: {}, remoteNames[1]: {}},
wantCreated: nil,
},
{
name: "AllClusters: stale cache ClusterName set, nominations not confirmed — no remote workloads created",
dispatcherMode: config.MultiKueueDispatcherModeAllAtOnce,
remotes: map[string]*kueue.Workload{remoteNames[0]: nil, remoteNames[1]: nil},
localClusterName: new(remoteNames[0]),
wantCreated: nil,
},
// Incremental dispatcher tests were moved to a separate file.
{
name: "External controller: no nominated workers, nothing created",
Expand Down Expand Up @@ -2171,6 +2179,7 @@ func TestNominateAndSynchronizeWorkers_MoreCases(t *testing.T) {
Status: kueue.WorkloadStatus{
Conditions: make([]metav1.Condition, 0, 1),
NominatedClusterNames: tt.nominatedWorkers,
ClusterName: tt.localClusterName,
},
}

Expand Down