-
Notifications
You must be signed in to change notification settings - Fork 616
MultiKueue: one slow remote no longer stalls every other cluster #11305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 3 commits into
kubernetes-sigs:main
from
trilamsr:fix/multikueue-per-cluster-lock
May 19, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| "sync" | ||
| "testing" | ||
| "time" | ||
|
|
||
|
|
@@ -1267,3 +1268,91 @@ func TestEstablishBackoffSchedule(t *testing.T) { | |
| }) | ||
| } | ||
| } | ||
|
|
||
| // Regression for #11297. A remote stuck inside Watch must not stop | ||
| // reconciles of other clusters. | ||
| func TestSetRemoteClientConfigDoesNotBlockOtherClusters(t *testing.T) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice test, thanks for adding 👍 |
||
| // stuckWatchTimeout is the per-phase budget for the test: how long we | ||
| // wait for the slow watch to be reached, for the fast reconcile to | ||
| // finish, and for the slow goroutine to clean up after release. Generous | ||
| // enough to survive a loaded CI runner. | ||
| const stuckWatchTimeout = 5 * time.Second | ||
|
|
||
| ctx, _ := utiltesting.ContextWithLog(t) | ||
|
|
||
| slowReached := make(chan struct{}) | ||
| slowRelease := make(chan struct{}) | ||
| var releaseOnce sync.Once | ||
| releaseSlow := func() { releaseOnce.Do(func() { close(slowRelease) }) } | ||
| t.Cleanup(releaseSlow) | ||
|
|
||
| gatedBuilder := func(config *clientConfig, _ client.Options) (client.WithWatch, error) { | ||
| kubeconfig := string(config.Kubeconfig) | ||
| b := getClientBuilder(ctx).WithInterceptorFuncs(interceptor.Funcs{ | ||
| Watch: func(watchCtx context.Context, c client.WithWatch, obj client.ObjectList, opts ...client.ListOption) (watch.Interface, error) { | ||
| if strings.Contains(kubeconfig, "slow-user") { | ||
| close(slowReached) | ||
| select { | ||
| case <-slowRelease: | ||
| return nil, errors.New("released") | ||
| case <-watchCtx.Done(): | ||
| return nil, watchCtx.Err() | ||
| } | ||
| } | ||
| return c.Watch(watchCtx, obj, opts...) | ||
| }, | ||
| }) | ||
| return b.Build(), nil | ||
| } | ||
|
|
||
| slowCluster := utiltestingapi.MakeMultiKueueCluster("cluster-slow"). | ||
| KubeConfig(kueue.SecretLocationType, "secret-slow").Generation(1).Obj() | ||
| fastCluster := utiltestingapi.MakeMultiKueueCluster("cluster-fast"). | ||
| KubeConfig(kueue.SecretLocationType, "secret-fast").Generation(1).Obj() | ||
| slowSecret := makeTestSecret("secret-slow", testKubeconfig("slow-user")) | ||
| fastSecret := makeTestSecret("secret-fast", testKubeconfig("fast-user")) | ||
|
|
||
| localClient := getClientBuilder(ctx). | ||
| WithLists(&kueue.MultiKueueClusterList{Items: []kueue.MultiKueueCluster{*slowCluster, *fastCluster}}). | ||
| WithLists(&corev1.SecretList{Items: []corev1.Secret{slowSecret, fastSecret}}). | ||
| WithStatusSubresource(slowCluster, fastCluster). | ||
| Build() | ||
|
|
||
| reconciler := newClustersReconciler(localClient, TestNamespace, 0, defaultOrigin, nil, nil, &NoOpClusterProfileCreds{}, nil) | ||
| reconciler.rootContext = ctx | ||
| reconciler.builderOverride = gatedBuilder | ||
|
|
||
| slowDone := make(chan struct{}) | ||
| go func() { | ||
| defer close(slowDone) | ||
| _, _ = reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: "cluster-slow"}}) | ||
| }() | ||
|
|
||
| select { | ||
| case <-slowReached: | ||
| case <-time.After(stuckWatchTimeout): | ||
| t.Fatal("slow cluster's reconcile did not reach the Watch call in time") | ||
| } | ||
|
|
||
| fastDone := make(chan error, 1) | ||
| go func() { | ||
| _, err := reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: types.NamespacedName{Name: "cluster-fast"}}) | ||
| fastDone <- err | ||
| }() | ||
|
|
||
| select { | ||
| case err := <-fastDone: | ||
| if err != nil { | ||
| t.Fatalf("cluster-fast reconcile returned err: %v", err) | ||
| } | ||
| case <-time.After(stuckWatchTimeout): | ||
| t.Fatal("cluster-fast reconcile was blocked by cluster-slow (head-of-line)") | ||
| } | ||
|
|
||
| releaseSlow() | ||
| select { | ||
| case <-slowDone: | ||
| case <-time.After(stuckWatchTimeout): | ||
| t.Fatal("slow goroutine did not exit after release") | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, in theory this lock is redundant, because I think there's only one reconcile running per
MultiKueueClusterat any given point, so in theory there's at most one thread accessingc.remoteClients[clusterName].But this would be very implicit, so having this lock just in case sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, the workqueue dedup makes it redundant in production. Kept as a local safety net because that guarantee is invisible from this file, and tests can bypass the workqueue (the one in this PR does).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I missed that. Having said that I'm ok with either option, both have some merit: explicit check + a bit more robust tests, vs. less production code.
I'm ok to keep as is.