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 start by exploring the repository structure to understand the codebase and locate relevant files related to workloads, workers, and requeueing logic. Let's first see what's in the root directory.
- Assistant
Let me explore the repository structure to understand the codebase.
- Assistant
Let me explore the repository structure to understand the codebase, focusing on workloads, workers, and requeueing logic. Let me start with the pkg directory and internal directory.
- Assistant
Let me look at the issue more carefully. The issue mentions:
- 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
This seems related to the multikueue functionality where workloads are dispatched to remote workers. Let me look at the multikueue controller code.
- Assistant
Let me look at the multikueue workload controller and understand how worker disconnection is handled.
- Assistant
Let me search for more specific handling around worker loss, disconnection, and requeueing logic.
- Assistant
Let me look at the reconcileGroup function and the worker loss timeout logic.
- Assistant
Let me look at the reconcileGroup function to understand the current behavior when a worker disconnects.
- Assistant
Now let me look at the
nominateAndSynchronizeWorkersandreadGroupfunctions: - Assistant
Let me understand the issue better. Looking at the reconcileGroup function:
- Step 6 handles the case where a remote workload is reserving/admitted - it sets the AC to ready state and requeues after workerLostTimeout.
- There's also handling for when ACS is ready but no remote has the admitted condition - it keeps the workload admitted for workerLostTimeout before requeueing.
Let me look at the
nominateAndSynchronizeWorkersfunction to understand the full flow better, and also look at the clusters reconciler to understand how worker disconnection is detected. - Assistant
Now let me look at the clusters reconciler to understand how worker disconnection is detected and handled:
- Assistant
Let me look at the multikueuecluster.go file and controllers.go to understand how worker disconnection is detected and handled:
- Assistant
Now let me look at the
remoteClientandclustersReconcilerto understand how worker connectivity is tracked: - Assistant
Now let me look at the multikueuecluster.go file to understand how worker connection state is tracked:
- Assistant
Let me look at the clusters reconciler Reconcile function to understand how disconnection is detected:
- Assistant
Let me look at the reconcile function for clustersReconciler and also look at how the workload is being requeued when a worker disconnects.
- Assistant
Let me look at the
Reconcilefunction in clustersReconciler and also theremoteClientsForACfunction in workload.go: - Assistant
Now let me look at the
remoteClientsForACfunction to understand what happens when a cluster disconnects: I'll search for theremoteClientsForACfunction in the workload.go file to understand how it retrieves clients for admission checks. I'll also look forcontrollerForandconnectingto see how connection states are managed. - Assistant
Let me look at the remoteClientsForAC function to understand how it handles disconnected clients.
- Assistant
Let me look at the full remoteClientsForAC function.
- Assistant
Now I need to understand the
nominateAndSynchronizeWorkersfunction and what happens when no remote is admitted but workers are still connecting: - Assistant
Now let me look at the
syncToSingleClusterfunction: - Assistant
Let me examine the key section of reconcileGroup more carefully, specifically step 6 and the else branch that handles the "reserving remote lost" case:
- Assistant
Let me look at the
controllerForfunction and how it handles disconnected clusters: - Assistant
Now let me look at the workload_test.go to understand the expected behavior:
- Assistant
Let me look at the tests for the workload reconciler to understand the expected behavior and find relevant tests for worker disconnection:
- Assistant
Let me look at the test cases for worker disconnection and reconnect behavior:
- Assistant
Now let me look at how the test environment sets up the remote clients (connecting state):
- Assistant
Let me look at the test "reconnecting clients are skipped":
- Assistant
Let me understand how the test environment is set up, particularly the remote clients and the
remoteClientsForACfunction: - Assistant
Let me search for tests related to reconnection and check the test expectations:
- Assistant
Let me look at the test more carefully to understand the expected flow when a worker disconnects:
- Assistant
Let me look at how the fake clock is set up in the test:
- Assistant
Let me look at the git log to understand recent changes:
- Assistant
Let me search for integration tests related to this issue:
- Assistant
Let me look at the integration test that's about requeueing when the connection to the admitting worker is lost:
- Assistant
Let me look at the integration test that checks the behavior when connection to admitting worker is lost:
- Assistant
Let me now look at the
readGroupfunction to understand how remote clients are collected, and then let's look at the scenario where only one worker disconnects: - Assistant
Let me search for all places where
CheckStateRetryis set: - Assistant
Let me look at the integration tests more carefully to understand the expected behavior:
- Assistant
Let me look at what
BreakConnectiondoes to understand how a worker disconnect is simulated: - Assistant
Let me look at the BreakConnection function to understand how worker disconnect is simulated.
- Assistant
Let me look at the git log for recent changes related to multikueue or worker disconnect:
- Assistant
Let me look at how the multikueue integration test suite is configured for the workerLostTimeout:
- Assistant
Let me now look at how
PatchAdmissionStatusworks: - Assistant
Let me now run the existing multikueue workload tests to understand the current behavior:
- Assistant
I need to set up the Go environment properly.
- Assistant
Let me look at the workload tests more carefully:
- Assistant
Let me find the correct test name:
- Assistant
Let me run the workload reconcile test:
- Assistant
Now I understand the issue. Let me carefully re-read the key section of the reconcile logic to understand the bug:
- Assistant
Now I understand the issue clearly. Let me trace through the scenario:
- Workload admitted on worker at T=0.
LastTransitionTimeset to T=0. ReturnsRequeueAfter: 5min. - At T=5min: reconcile fires, worker connected.
syncReservingRemoteStateupdatesLastTransitionTimeto T=5min. ReturnsRequeueAfter: 5min. - At T=7min: Worker disconnects.
- At T=7min+ε: Event triggers reconcile. No admitted remote found (worker excluded). Falls to
else if acs.State == CheckStateReady. remainingWaitTime = 5min - time.Since(T=5min) = 5min - 2min = 3min > 0. ReturnsRequeueAfter: 3min.- At T=10min: Timer fires.
remainingWaitTime = 5min - 5min = 0. Workload set to Retry.
The workload is requeued at T=10min, which is only 3 minutes after the disconnect, not the full 5-minute
workerLostTimeout! The timeout is measured from the last sync, not from when the disconnect was detected.The fix: when the disconnect is first detected, update
LastTransitionTimeto the current time so the full timeout period starts from that point. Let me look at thePatchAdmissionStatusfunction to understand how to patch correctly: - Workload admitted on worker at T=0.
- Assistant
Now let me look at how
updateACSworks to understand the pattern for patching: - Assistant
Now I understand the issue clearly. Let me look at what happens step by step. The
else if acs.State == kueue.CheckStateReadyblock usestime.Since(acs.LastTransitionTime.Time)to compute remaining wait time. TheLastTransitionTimeis set bysyncReservingRemoteStateevery time the workload is synced with the worker. When a worker disconnects,LastTransitionTimereflects the last sync time, not the disconnect detection time. This means if the last sync was 4 minutes ago andworkerLostTimeoutis 5 minutes, the workload is requeued in just 1 minute instead of the full 5 minutes.The fix: when the disconnect is first detected, reset
LastTransitionTimeto the current time so the full timeout starts from that point. I need to addstringsimport and modify theelse ifbranch: - Assistant
Now let me make the fix. First, add
"strings"to the imports: - Assistant
Let me add
"strings"to the import block. - Assistant
Now let me modify the
else if acs.State == kueue.CheckStateReadybranch: - Assistant
Let me see the current code around line 505:
- Assistant
Now I need to replace the
else ifbranch with the fix: - Assistant
Now let me verify the change was applied correctly:
- Assistant
I notice I need to also update the message in my patch so that subsequent reconciles don't keep resetting the
LastTransitionTime. Let me fix that: - Assistant
Let me verify the change:
- Assistant
Now let me run the tests to see if the existing tests pass:
- Assistant
Some tests are failing. Let me look at the failure details:
- Assistant
The failure message isn't very detailed. Let me get more verbose output:
- Assistant
The tests are failing because my initial fix changes behavior even when the worker is still in the group (connected) but the remote workload is missing. I need to only reset the timeout when the previously-reserving worker is no longer in the group (i.e., truly disconnected). Let me refine the fix:
- Assistant
Now let me verify the change:
- Assistant
Now let me run the tests:
- Assistant
All tests pass. Let me also run the full test suite for the multikueue package:
- Assistant
All tests pass. Let me also run the broader test suite to make sure nothing else is broken:
- Assistant
Good, the build succeeds. Let me also run the workload package tests:
- Assistant
Let me check the full diff of my changes to make sure everything is correct:
- Assistant
The diff looks good. Let me now run a broader set of tests to make sure nothing is broken:
- Assistant
All tests pass. Let me also run the scheduler tests to verify nothing is broken:
- Assistant
Let me also check the admission check controller tests:
- Assistant
All tests pass. Let me now do a final review of my changes:
- Assistant
Let me verify the final state of my changes one more time:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.