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.
Assistant
This is the Kueue repository. Let me explore the relevant code related to worker disconnections and workloads.
Assistant
Let me search for workload requeuing and worker loss timeout logic.
Assistant
Let me look at the workload.go file in the multikueue package.
Assistant
Let me see the rest of the workload.go file, especially the reconcileGroup function.
Assistant
Let me look at the multikueuecluster.go file more carefully to understand how the cluster controller reacts to a worker disconnect.
Assistant
Let me look at the test files to understand the worker disconnect scenario.
Assistant
Let me look at the configuration for the worker lost timeout.
Assistant
Let me look for what "requeue" means in the context of Kueue workloads.
Assistant
Let me look for places where the workload might be requeued when a worker disconnects.
Assistant
Let me look at the rest of the workload.go for the
reconcileGroupfunction.Assistant
Let me check the git log for recent changes related to this issue.
Assistant
Let me check the most recent multikueue-related commits that might be related to this issue.
Assistant
Let me check the changes related to "WorkerLostTimeout" or "requeue" in the recent history.
Assistant
Let me look at the recent commit that handles a similar issue.
Assistant
Let me look at the clusterqueue reconciler to see if it might trigger a requeue.
Assistant
Let me look at the workload controller and see when it requeues workloads.
Assistant
Let me search for the term "requeue" in the multi-kueue context.
Assistant
Let me look at the scheduler to see if it triggers the requeue.
Assistant
Let me look at when
requeueAndUpdateis called.Assistant
Let me check the conditions for requeuing.
Assistant
Let me look at the workload controller to see what it does when the admission check state changes.
Assistant
Let me look at the
NeedsRequeueAtUpdatefunction.Assistant
Let me look at the
Reconcilefunction inclustersReconcilermore carefully.Assistant
Let me look at the rest of the workload.go to understand the full reconcileGroup function.
Assistant
Let me search for more context in the test file.
Assistant
Let me look at the changes related to KEP-9988 to see if it affects the admission check flow.
Assistant
Let me look at the
Requeuefunction in the workload controller.Assistant
Let me look at the
IsAdmissiblefunction.Assistant
Let me look at the workload controller's reaction to admission check state changes.
Assistant
Let me look at the eviction logic.
Assistant
Let me look at the
nominateAndSynchronizeWorkersfunction more carefully.Assistant
Let me look at the workload_test.go to see the test for the case where the worker reconnects.
Assistant
Let me look at the test cases for the worker reconnect scenario more carefully.
Assistant
Let me look at the test that has the worker reconnecting while the workload is admitted.
Assistant
Let me look at the integration test for the worker disconnect scenario.
Assistant
Let me look at the suite_test.go for the multikueue integration tests.
Assistant
Let me look at the
BreakConnectionfunction.Assistant
Let me look at the related integration test to see how the worker disconnect scenario is tested.
Assistant
Let me check the indexer.
Assistant
Let me look at all the places where the AC state's
LastTransitionTimeis updated.Assistant
Let me look at the workload reconciler's predicates.
Assistant
Let me look at the
setQuotaReservationfunction.Assistant
Let me look at the
admitWorkloadAndCheckWorkerCopiesfunction.Assistant
Let me check if the workload's reconciler is triggered by cluster events through any indirect mechanism.
Assistant
Let me check the event filter for the cluster's reconciler.
Assistant
Let me look at the AC state structure.
Assistant
Now I have a good understanding of the issue. Let me look at the test to make sure I understand the expected behavior.
Assistant
Let me look at the test file for the integration test for the worker disconnect scenario.
Assistant
Let me look at the test setup more carefully.
Assistant
Now I have a good understanding of the issue. Let me create a plan to fix it.
The bug: When a worker disconnects, the workload's
remainingWaitTimeis calculated based on theLastTransitionTimeof the admission check (which is the time of admission, not the time of disconnect). This means that if the workload was admitted a long time before the disconnect, theremainingWaitTimebecomes negative, and the workload is requeued too early.The fix: Track the time when the worker disconnected, and use that time to calculate the
remainingWaitTimeinstead of theLastTransitionTime.Assistant
Now let me implement the fix. I'll add a
disconnectedAtfield to theremoteClientand use it in theelse ifbranch.Assistant
Let me first look at the full
remoteClientstruct and understand themumutex usage.Assistant
Now let me make the changes. First, I'll add a
disconnectedAtfield to theremoteClientstruct.Assistant
Let me make the changes. First, I'll add a
disconnectedAtfield to theremoteClientstruct.Assistant
Let me make the changes step by step. I'll use the edit tool.
Assistant
Now let me apply the patch:
Assistant
Now let me add accessor methods for
disconnectedAtand modify the watch loop to set/clear the field:Assistant
Now let me add the accessor method for
disconnectedAt:Assistant
Now let me update the watch loop to set the
disconnectedAtwhen the watch ends:Assistant
Now let me update
setConfigto clear thedisconnectedAtwhen the connection is restored:Assistant
Now let me look at the workload reconciler to see how to use the new field:
Assistant
Now let me update the
else ifbranch inreconcileGroupto use the newdisconnectedAtfield:Assistant
Now let me verify the changes compile:
Assistant
The code compiles. Now let me verify the changes by looking at them:
Assistant
Now let me check the other changes:
Assistant
Now let me run the existing tests to see which ones pass and which ones fail:
Assistant
All the existing tests pass! Let me also run the broader test suite:
Assistant
All tests pass! Let me write a test to verify the fix works as expected:
Assistant
Let me write a temporary test to verify my fix works as expected:
Assistant
Let me create a proper test in a temporary file to verify my fix:
Assistant
The fix works as expected. Let me also verify that the existing tests still pass:
Assistant
All tests pass. Let me also run the broader test suite to make sure I haven't broken anything:
Assistant
All tests pass! Let me also run the workload tests to be safe:
Assistant
All tests pass. Let me also clean up by removing the temporary test file:
Assistant
Let me look at the final changes I've made:
Assistant
The changes are clean. Let me verify by running the test one more time:
Assistant
No failures. Let me also run the tests for the multikueuecluster:
Assistant
All tests pass! The earlier non-zero exit was just from
grepfinding no matches.Let me verify the changes one more time:
Assistant
Let me also make sure I have a thorough understanding of the issue by re-reading the issue and verifying the fix:
Assistant
Now let me address the checklist items:
Checklist:
-
If an error was reported in the issue description, I have successfully reproduced it.
-
Assistant
All checks pass. Let me submit my solution:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.