Skip to content

Commit 40e555e

Browse files
fix: remove invalid Unlock calls in scaleset worker
- Remove Unlock call in handleScaleDown that was called before any lock was acquired - Change defer Unlock to immediate Unlock in consolidateRunnerState loop to avoid holding locks until function exit
1 parent 35ac87d commit 40e555e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

workers/scaleset/scaleset.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ func (w *Worker) consolidateRunnerState(runners []params.RunnerReference) error
566566
slog.DebugContext(w.ctx, "runner is locked; skipping", "runner_name", runner.Name)
567567
continue
568568
}
569-
defer locking.Unlock(runner.Name, false)
569+
locking.Unlock(runner.Name, false)
570570

571571
if _, ok := providerRunnersByName[runner.Name]; !ok {
572572
// The runner is not in the provider anymore. Remove it from the DB.
@@ -893,7 +893,6 @@ func (w *Worker) handleScaleDown() {
893893
switch runner.RunnerStatus {
894894
case params.RunnerTerminated, params.RunnerActive:
895895
slog.DebugContext(w.ctx, "runner is not in a valid state; skipping", "runner_name", runner.Name, "runner_status", runner.RunnerStatus)
896-
locking.Unlock(runner.Name, false)
897896
continue
898897
}
899898
locked := locking.TryLock(runner.Name, w.consumerID)

0 commit comments

Comments
 (0)