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, admission, and worker-loss timeout handling. Then I’ll identify or reproduce the premature requeue path, patch it, and run focused plus broader tests.
- Assistant
This is the Go-based Kueue repository. Since ripgrep is unavailable, I’ll use
git grep; the issue likely concerns MultiKueue worker-cluster disconnect handling, so I’ll narrow searches around its controllers and timeout configuration. - Assistant
Existing unit and integration coverage already targets the timeout, suggesting a regression in state/timestamp handling rather than missing behavior wholesale. I’ll inspect the reconcile branches around disconnected clients and the relevant test fixtures, then compare recent repository history if available.
- Assistant
The current timeout calculation uses the admission check’s
LastTransitionTime, which records when the workload became Ready—not when the worker disconnected. For a long-running admitted workload, that timestamp is already older than the timeout, so the first disconnect reconcile immediately marks it Retry. I’ll confirm the exact branch and inspect remote client lifecycle fields to choose a disconnect timestamp source that also supports same-config reconnection and isolates workers. - Assistant
The defect is confirmed by code inspection:
time.Since(acs.LastTransitionTime)incorrectly measures admission age. A robust fix needs a per-remote-client “connection lost at” value set exactly when disconnect/reconnect begins, preserved across same-configuration reconnect attempts, and reset only after successful connection. I’ll inspectsetConfigand client replacement semantics before implementing that state. - Assistant
A client-local disconnect timestamp is preferable to mutating every workload’s admission status. However,
readGroupcurrently drops reconnecting clients entirely, so the workload reconciler needs to retain enough knowledge to recognize its reserving worker while avoiding calls through a disconnected client. I’ll inspect how the selected cluster is persisted (Status.ClusterNameand AC message) and how cluster events enqueue workloads. - Assistant
Status.ClusterNamereliably identifies the immutable reserving worker once admitted. I’ll use that to look up the disconnected client directly. The remaining concern is when workload reconciliation is triggered after disconnect and reconnect; I’ll inspect controller watches/index mappings and then implement the smallest stateful correction with fake-clock-compatible timing. - Assistant
The code deliberately refreshes
LastTransitionTimeas a heartbeat on successful remote reconciliation, but that only approximates loss time and can be almost one full timeout stale. I’ll add exact per-client loss tracking: set once when a watch transitions from connected to reconnecting, preserve it through same-config backoff retries, clear it on successful reconnect, and base an admitted workload’s delay on its assigned client’s loss time. I’ll retain the old timestamp as a fallback for legacy/unit scenarios where the assigned client no longer exists. - Assistant
The core patch is in place and formatted. I’ll now run the focused package tests to catch API/interface and behavior issues. I’ll also inspect failures for whether existing fake-client fixtures need code compatibility (without changing tests).
- Assistant
The test did not compile because the environment has no
HOME,XDG_CACHE_HOME, orGOCACHE; this is infrastructure setup rather than a code failure. I’ll rerun with a temporary Go build cache explicitly configured. - Assistant
Focused tests compile and pass. To verify the reported timing regression specifically without adding/modifying tests, I’ll identify the existing table-test name and run the full package suite; then I’ll inspect test helpers to see whether an existing case exercises a connecting client with an immutable
ClusterName(the real scenario). - Assistant
The package suite passes, but inspection exposes an edge case: if the assigned worker is the only configured worker,
readGroupreturnsErrNoActiveClustersbefore reaching timeout logic. That violates the same requirement after a prolonged loss. I’ll allow reconciliation to proceed with an empty active group only for an already-Ready workload whose persisted assigned client is reconnecting; unadmitted workloads will still receive the existing no-active-cluster error. - Assistant
The new branch hit a Go name-shadowing compile error because a local variable named
remoteClienthides the type used inmake(map[string]*remoteClient). I’ll rename the local toassignedClientand rerun the complete package suite. - Assistant
The compile issue is fixed and all MultiKueue unit tests pass. Next I’ll run the broader admission-check controller tests and race-enabled focused tests, then review the final diff for synchronization correctness and unintended changes.
- Assistant
Broader tests and the race detector pass. Final review confirms the timestamp is mutex-protected, persists across retry backoff, is reset only on successful connection, and is stored per worker so one outage cannot affect other clients. I’ll run
go veton the changed package and the wider controller unit suite as final validation. - Assistant
Final validation succeeded, and only the two intended source files are modified.
Checklist:
- Successfully reproduced the reported error: code-path reproduction showed the old calculation subtracting the admission check’s last successful transition from
workerLostTimeout; for a workload admitted longer than the timeout, the first disconnect reconciliation immediately selected Retry. The existing table case with an old Ready transition also confirms that behavior. - Confirmed the fix resolves it: timeout calculation now starts from the per-worker watch disconnect time, remains Ready for the full configured interval, and the focused/full MultiKueue tests plus race tests pass.
- Considered edge cases: the loss timestamp survives repeated same-configuration reconnect/backoff attempts, clears on successful reconnect, is isolated per worker, handles controller startup lazily, retains legacy fallback behavior, and allows timeout processing when the disconnected worker is the only worker.
- Successfully reproduced the reported error: code-path reproduction showed the old calculation subtracting the admission check’s last successful transition from
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.