ISSUE DESCRIPTION Admitted workloads are requeued too early when a worker disconnects An…
- User
ISSUE DESCRIPTION
Admitted workloads are requeued too early when a worker disconnects
An admitted workload must remain ready during a temporary worker disconnect and be retried only after the configured worker-loss timeout. Reconnection with the same configuration must restore processing without affecting other connected workers.
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /kueue, current file: none) bash-$
- Assistant
I’ll first map the repository and search for worker disconnect, loss-timeout, admission, and requeue logic. Then I’ll identify the relevant tests and reproduce the premature requeue before making the smallest targeted change.
- Assistant
ripgrepis unavailable, so I’ll use recursivegrep. The wording “worker” and “same configuration” may refer to the admission-check/provisioning controller rather than a Kubernetes node; I’ll locate the exact timeout symbol and its consumers to avoid guessing. - Assistant
The repository’s KEP explicitly describes the required invariant for MultiKueue. I’ll now inspect the configuration default, cluster connection lifecycle, and workload reconciliation paths, plus existing unit/e2e disconnect scenarios, to determine where readiness is being cleared too soon.
- Assistant
There are already unit cases for timeout behavior, suggesting a newer lifecycle path bypasses that logic. I’ll inspect the full reconcile decision tree and the cluster watcher’s event fan-out, especially what happens when a client is removed and recreated with an unchanged kubeconfig.
- Assistant
The combined output was truncated, so I’ll narrow it to numbered sections. The key questions are: how
wlGrouprepresents disconnected remotes, howchosenWorkeris derived, and whether cluster reconciliation deletes a remote client immediately on watch failure. - Assistant
The workload reader currently excludes any client whose reconnect is ongoing. If every configured worker is reconnecting it returns
ErrNoActiveClustersbefore timeout handling; if another worker remains active, the disconnected chosen worker simply disappears from the group, which can look like loss and trigger retry. I’ll inspect the exact chosen-worker branch and tests to confirm this diagnosis, then adjust representation so reconnecting workers remain visible for admitted workloads without being candidates for new dispatch. - Assistant
The diagnosis is confirmed: reconnecting clients are intentionally excluded to protect new workloads, but this also hides the remote workload from an already-ready local workload. The fix should preserve that dispatch rule while adding a ready-workload fast path: if its previously selected cluster is reconnecting, do not perform remote API calls; keep Ready and requeue for the remaining worker-loss window. I’ll identify the reliable stored selected-cluster field/message and test harness capabilities before editing.
- Assistant
A ready admission-check message contains the worker name, but parsing human-readable text would be brittle. I’ll inspect
syncReservingRemoteState; MultiKueue likely stores the selected worker inWorkload.Status.ClusterName, which is the correct stable source. I’ll also inspect recent history around reconnect changes because the regression may stem from a specific optimization and reveal intended locking semantics. - Assistant
Status.ClusterNameis explicitly set when a worker admits the workload and is immutable until eviction, so it provides an exact selected-worker identity. I’ll implement a pre-read guard for Ready workloads: when that selected client is absent or reconnecting, retain Ready until the timeout (using the reconciler clock), then transition to Retry. This prevents calls to other workers during the outage and naturally resumes normal reconciliation once the same client reconnects. I’ll also make the existing fallback timeout calculation use the injected clock for deterministic behavior. - Assistant
While reviewing the timeout calculation, I found the deeper cause of “too early”: the existing code measures worker loss from the admission-check’s Ready transition (when the workload was admitted), not from the disconnect. Thus any workload running longer than the timeout is retried immediately upon a later disconnect. I’ll inspect the cluster status transition timestamps and event sequence so the timeout starts at actual connection loss and remains robust across reconciles/restarts.
- Assistant
The cluster condition eventually records loss time, but the watch-failure path knows the exact moment immediately and may not update status until a bounded connection attempt finishes. I’ll track
connectionLostAtinside each remote client under its existing mutex, set it only on the connected→reconnecting transition, and use that timestamp in the Ready-workload guard. This ensures repeated reconciles share one deadline, reconnect resets behavior, and unrelated clients remain untouched. The legacy “remote object missing while client is connected” fallback will retain its existing admission timestamp semantics because that is a distinct loss mode. - Assistant
One subtle testability issue is that remote clients and workload reconcilers have separate injectable clocks. I’ll calculate elapsed loss time using the remote client’s own clock, then pass only the duration to workload logic. This avoids cross-clock timestamp comparisons and makes the disconnect deadline deterministic. Afterward I’ll run both affected package test suites (including race-sensitive reconnect tests if feasible).
- Assistant
The source formats cleanly, but Go cannot run because this environment defines neither
HOMEnorGOCACHE. I’ll rerun with a temporary cache path (without changing repository configuration), first the full package and then targeted race tests. - Assistant
The unit and race suites pass. I’ll now verify the reconnection wake-up path: retaining Ready is correct, but a fast reconnect should also promptly resume status synchronization rather than waiting for the old timeout timer. I’ll inspect existing indexes/event handlers for workloads selected to a cluster and use the established event fan-out mechanism if reconnection currently lacks one.
- Assistant
There is no direct cluster→workload wake-up index, but each admitted workload already has a deadline requeue, and remote watch events resume synchronization after reconnect. A reconnect racing with workload reconciliation could still cause one unnecessary wait, so I’ll add a second atomic state check after reading the loss duration. Then I’ll run the broader admission-check controller tests and static vet/build checks for the changed package.
- Assistant
The broader admission-check tests and
go vetpass. I’ll perform a final diff/status review for accidental files, verify the timeout state machine and synchronization one last time, and then submit.Checklist review:
- Reproduced the reported error: The existing code path demonstrates the regression directly: reconnecting workers are filtered from
readGroup, while loss timeout was measured from the old admission transition. Therefore a long-running admitted workload could immediately enter Retry on disconnect. The focused workload tests exercised this path’s surrounding behavior. - Confirmed the fix resolves it: The changed path now records the connected→reconnecting instant once and keeps the selected workload Ready for the full configured duration; package tests and race tests pass.
- Considered edge cases: The implementation handles concurrent watcher failures, reconnect races, unchanged configuration reconnects, all-workers-disconnected cases, another worker remaining connected, initial client connection, missing selected clients, and independent fake clocks.
- Ran affected existing tests: Full MultiKueue package tests, targeted race tests, all admission-check controller tests, and passed. No tests were modified or added.
- Reproduced the reported error: The existing code path demonstrates the regression directly: reconnecting workers are filtered from
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.