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 what we're working with. Let's first get an overview.
- Assistant
Let me explore the repository structure to understand what we're working with. This looks like a Go project called "kueue" (a Kubernetes-native job queueing system). Let me understand the issue: "Admitted workloads are requeued too early when a worker disconnects". We need to ensure that when a worker disconnects temporarily, the admitted workload remains ready and is retried only after the configured worker-loss timeout.
Let me first get a better understanding of the codebase structure.
- Assistant
Let me explore the repository to understand the issue. The issue is about admitted workloads being requeued too early when a worker disconnects. I need to find the relevant code related to:
- Admitted workloads
- Worker disconnect3. Requeue logic
- Worker-loss timeout
Let me explore the repository structure first.
- Assistant
Let me understand the issue better. The issue is about admitted workloads being requeued too early when a worker disconnects. Let me look for code related to requeuing, worker disconnects, and timeouts.
- Assistant
Let me search for "worker" related code to understand the worker disconnect issue.
- Assistant
The issue is about "admitted workloads are requeued too early when a worker disconnects". This seems related to multi-kueue or kueue internals. Let me look for "multikueue" and "disconnect" or "worker loss" related code.
- Assistant
Let me look at the multikueue worker disconnect handling code more closely.
- Assistant
Let me look at the workload.go file in multikueue to understand the requeue logic:
- Assistant
Let me search for the specific reconcileGroup function and the handling of worker disconnections:
- Assistant
Let me look at the reconcileGroup function more closely:
- Assistant
Let me look at the test file for the workload controller in multikueue:
- Assistant
Let me look at the
readGroupfunction: - Assistant
Let me look at the readGroup function:
- Assistant
Let me now look at the test file to understand the expected behavior:
- Assistant
Let me look at these test cases:
- Assistant
Let me look at the
syncReservingRemoteStatefunction more closely: - Assistant
Let me look at the
syncReservingRemoteStatefunction more carefully: - Assistant
Let me look at the
syncReservingRemoteStatefunction: - Assistant
Let me look at how the cluster handles disconnection:
- Assistant
Now let me search for how
readGrouphandles connection errors - specifically when remote clients cannot be connected: - Assistant
Let me look at remoteClientsForAC to understand how it handles disconnected clients.
- Assistant
Let me look at the
readGroupmore carefully and understand what happens with connection errors: - Assistant
Let me look at the watcher and connection state handling:
- Assistant
Let me look at the
setConfigfunction to understand how the reconnection flow works: - Assistant
Let me understand the full flow better. Let me look at what happens during a worker disconnection scenario. Let me check the git log for recent changes:
- Assistant
Let me search for recent commits related to worker disconnect or worker loss:
- Assistant
Let me look at the issue more carefully. The key code is in the reconcileGroup function. When the worker disconnects, the local workload's AC state is
CheckStateReady, but there are no remote workloads visible. The code enters theelse if acs.State == kueue.CheckStateReadybranch. Let me understand how the requeueing happens: - Assistant
Now I understand the flow. Let me look at how the
syncReservingRemoteStatefunction behaves more carefully - I see a potential issue: - Assistant
Now let me look at how the test setup works to understand what scenarios exist:
- Assistant
Let me look at the test setup more to understand the expected behavior.
- Assistant
Let me find where
defaultWorkerLostTimeoutis defined. - Assistant
Let me look at the specific test cases for worker disconnect and understand the expected behavior:
- Assistant
Let me look at the test for "worker reconnects":
- Assistant
Let me now look at how the test setup works to understand the test infrastructure:
- Assistant
Let me look at git log for recent changes to the multikueue workload file:
- Assistant
Let me search for git changes related to the "worker lost timeout" or requeue:
- Assistant
Now I understand the issue. Let me look at the
SetAdmissionCheckStatefunction to understand how theLastTransitionTimeis managed: - Assistant
Let me search for SetAdmissionCheckState.
- Assistant
Let me look at the SetAdmissionCheckState function.
- Assistant
Let me look at how
FindAdmissionCheckworks: - Assistant
Let me look at this function to understand if it returns a pointer.
- Assistant
Now let me understand the core issue. Let me look at how
PatchAdmissionStatusworks: - Assistant
Let me look at PatchAdmissionStatus and PatchStatus:
- Assistant
Now I understand the issue. Let me trace through the exact flow to understand the bug:
- When
syncReservingRemoteStateis called with a worker that's already connected (acs.State == kueue.CheckStateReady),needsACUpdateis true, and it setsacs.LastTransitionTime = metav1.NewTime(w.clock.Now()). - But
SetAdmissionCheckStateonly updatesLastTransitionTimewhen the state changes (from theif existingCondition.State != newCheck.Statecheck). - So when the state is already
CheckStateReady, theLastTransitionTimeis never persisted on subsequent reconciles. - When the worker disconnects,
acs.LastTransitionTime.Timeis from when the state was first set toCheckStateReady, not from the last successful sync.
This means
remainingWaitTimecan be immediately negative, causing the workload to be requeued immediately.Let me verify this understanding by looking at the exact flow once more:
- When
- Assistant
Now I understand the bug. The issue is in
syncReservingRemoteState. Let me trace through the exact problem:-
When a workload is first admitted,
syncReservingRemoteStatetransitionsacs.StatetoCheckStateReadyand setsacs.LastTransitionTime = now.SetAdmissionCheckStatedetects the state change and persistsLastTransitionTime. -
On subsequent reconciles (when the worker is still connected),
syncReservingRemoteStateis called again. It setsacs.LastTransitionTime = nowon the local pointer, and callsSetAdmissionCheckState(&wl.Status.AdmissionChecks, *acs, w.clock). ButSetAdmissionCheckStatechecksexistingCondition.State != newCheck.State- since both areCheckStateReady, it does NOT updateLastTransitionTimein the persisted workload. -
When the worker disconnects, the code enters the
else if acs.State == kueue.CheckStateReadybranch and calculates . Since was only persisted at the initial admission (and never updated since), it could be very old, making immediately negative and requeuing the workload.
-
- Assistant
Let me set up the Go environment.
- Assistant
I need to set up HOME or GOCACHE for Go to work.
- Assistant
Good, all tests pass. Now let me understand the root cause better. Let me trace through exactly what happens:
- Assistant
Let me look at the
syncToSingleClusterfunction to understand the flow better: - Assistant
Let me look at the
syncToSingleClusterandnominateAndSynchronizeWorkersfunctions: - Assistant
Now let me understand the exact flow more carefully. Let me look at
patchStatusto understand how the workload is being persisted: - Assistant
Let me look at the
patchStatusfunction to understand how the workload status is being updated. - Assistant
Now I fully understand the issue. Let me trace through the exact problem:
- In
syncReservingRemoteState,acsis a pointer to the admission check ingroup.local.Status.AdmissionChecks acs.LastTransitionTime = metav1.NewTime(w.clock.Now())updates the pointer in memory- Then
workload.SetAdmissionCheckState(&wl.Status.AdmissionChecks, *acs, w.clock)is called with*acs(by value) - Inside
SetAdmissionCheckState,existingCondition.State != newCheck.Stateis FALSE when state is alreadyCheckStateReady - So
LastTransitionTimeis NOT updated in the persisted workload - When the worker disconnects,
acs.LastTransitionTimefrom the API server is stale (from when the state first transitioned) remainingWaitTimeis immediately negative → workload requeued immediately
The fix: in
syncReservingRemoteState, after callingSetAdmissionCheckState, explicitly updateLastTransitionTimeon the existing admission check inwl.Status.AdmissionChecks: - In
- Assistant
Now let me implement the fix. I need to update
LastTransitionTimeon the admission check in the workload even when the state hasn't changed: - Assistant
Now let me apply the fix:
- Assistant
Now let me apply the fix:
- Assistant
Now let me apply the fix:
- Assistant
Good, the fix is applied. Now let me verify it compiles and the tests still pass:
- Assistant
The build succeeded. Now let me run the tests:
- Assistant
All tests pass. Let me run all tests in the multikueue package:
- Assistant
All tests pass. Let me also run the workload package tests since we're modifying admission check state logic:
- Assistant
Good, all tests pass. Let me also run the broader related tests:
- Assistant
Let me also run the scheduler tests:
- Assistant
All tests pass. Let me verify the diff looks correct:
- Assistant
The diff looks correct. Let me now review my work against the checklist:
Checklist:
-
If an error was reported in the issue description, I have successfully reproduced it.
The issue describes a behavioral problem: "Admitted workloads are requeued too early when a worker disconnects." I traced through the code and identified the root cause:SetAdmissionCheckStateonly updatesLastTransitionTimeon state transitions, so when the check is already , subsequent calls to don't persist the updated . This means the worker-loss timeout timer measures from the time of initial admission rather than the last confirmed contact with the worker.
-
- Assistant
Let me also run the util/admissioncheck package tests:
- Assistant
All tests pass. Let me verify the complete fix once more:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.