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 locate worker-disconnect, admission, and worker-loss timeout logic. Then I’ll identify existing tests that model disconnect/reconnect behavior and reproduce the premature requeue before changing the implementation.
- Assistant
rgis unavailable, so I’ll use recursivegrep. Kueue’s multi-cluster controller is the likely subsystem: “worker” appears to mean a MultiKueue worker cluster, whose connection state and lost-worker timeout govern admitted workload placement. - Assistant
The relevant code and tests are under
pkg/controller/admissionchecks/multikueue. I’ll inspect the client state machine, workload reconciliation paths, and the existing integration scenario that explicitly tests delayed requeue after connection loss. This should reveal whether disconnect state is being propagated globally, timestamped incorrectly, or interpreted as immediate worker loss. - Assistant
The existing integration expectation confirms the reported old behavior: it waits for admission-check Pending and quota removal immediately after disconnection. The requested behavior reverses that during the configured loss grace period. I need the exact workload grouping and loss timer logic, plus configuration defaults/options, so I’ll inspect targeted symbols rather than the previously truncated output.
- Assistant
The current timeout exists, but the implementation measures it from the admission check’s
LastTransitionTime, not from disconnect time. For a workload that has been Ready longer than the timeout, a fresh disconnect therefore causes immediate Retry—exactly the issue. I’ll verify that flow and inspect how reconnect events are queued and how remote clients are selected, because the fix needs a per-worker disconnect timestamp and must not perturb other connected workers. - Assistant
The bug is confirmed in source and tests: every successful sync rewrites the admission check transition time, and loss handling later treats that workload-local time as the disconnect time. A robust fix should record
disconnectedAton eachremoteClientwhen its first watcher ends, clear it only after successful reconnection, and calculate all admitted workloads’ grace periods from that shared worker timestamp. I’ll inspect locking/test construction and event fan-out to implement this race-safely and ensure reconnect re-enqueues affected workloads. - Assistant
There is an additional architectural detail: disconnected clients are intentionally omitted from each workload group. Thus loss handling must look up the immutable
Status.ClusterName(the admitting worker) in the cluster reconciler’s full client map, while ordinary synchronization continues using only connected clients. This preserves isolation from other workers. I’ll inspect cluster reconciliation and watches to verify that disconnect/reconnect causes workload reconciles, then add a synchronized timestamp accessor and adapt loss handling. - Assistant
Cluster status transitions likely trigger admission-check/config reconciliation that fan out to workloads, while each workload’s delayed requeue handles timeout. The core implementation remains per-client timestamp. One subtle case is startup: a client begins
connecting=truebefore ever being connected; this is not “worker lost.” The timestamp must only be set on an established watch ending, not initial connection failures. I’ll inspect cluster event fan-out and then edit the remote client and workload loss branch. - Assistant
A disconnect event only reconciles the cluster, but updating its Active condition is consumed elsewhere through admission-check/config watches; the current integration test demonstrates that workloads do get reconciled. I also need to handle the “all configured workers disconnected” case: today
readGroupreturnsErrNoActiveClustersbefore reaching loss grace logic, which may leave admitted workloads Ready indefinitely or rely on unrelated events. I’ll inspect the top-level workload reconcile error path and then make admitted-worker loss handling happen before active-client group construction when possible. - Assistant
The top-level flow confirms a disconnected admitting worker must be handled before
readGroup, especially when no workers are active. I’ll implement that early guard. Reconnection also needs prompt workload reconciliation even when another worker kept the AdmissionCheck globally Active; otherwise reconnect could wait until the old delayed timeout. I’ll find whetherstatus.clusterNameis indexed; if not, I’ll use the existing admission-check/config fan-out mechanism or add a bounded local workload list filtered in memory on successful reconnect. - Assistant
No dedicated index is present, but MultiKueueCluster Active-condition changes fan out through AdmissionCheck updates to all config users, so reconnect already prompts workload reconciliation—even if another worker stayed connected, because the condition reason/message changes between
SomeActiveClustersstates. I’ll now add the per-worker loss timestamp, set it atomically on the first watch failure, clear it only after all watches reconnect, and short-circuit Ready workloads assigned to that disconnected worker before active-client discovery. Legacy fallback behavior remains for workloads withoutStatus.ClusterName. - Assistant
The implementation now ties the grace period to the worker’s first failed established watch, and the early guard keeps the workload Ready even if it is the only configured worker. It also uses the reconciler clock in the legacy path, improving deterministic timeout behavior. I’ll run the focused MultiKueue unit tests (including race-sensitive client tests if feasible), then inspect failures for assumptions around
ClusterNameand fake clocks. - Assistant
The test did not start because this container has neither
HOMEnorGOCACHE; that is an environment issue, not a code failure. I’ll rerun with temporary Go cache paths, keeping repository files untouched. - Assistant
Focused tests pass. While reviewing concurrency, I found a narrow reconnect race in the first version: a workload could observe
connecting=true, then set a timestamp just after reconnection had cleared it, leaving stale state for the next outage. I’ll close this by combining the connection-state check and timestamp initialization under the client mutex; reconnection’sStore(false)followed by clearing then cannot leave a stale timestamp. Afterward I’ll run unit tests with the race detector. - Assistant
The race-enabled focused suite passes, including existing disconnect/reconnect tests. I’ll now run the broader admission-check controller test tree to catch interactions with AdmissionCheck status fan-out and core admission behavior, then review the final diff for accidental or generated-file changes.
- Assistant
All admission-check controller tests pass, and only the two intended source files are modified. I’ll do a final semantic review of the diff and inspect clock/locking order for deadlocks:
disconnectedSincetakes onlyremoteClient.mu; reconnect takessetConfigLockand briefly the same mutex in separate calls, so there is no lock inversion. I’ll also confirm no direct unsynchronized reads of the new field.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.