From 48702dd149360fbffc83043a3010ae8bc5246809 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 30 May 2024 16:43:40 -0700 Subject: [PATCH] Harden unload for empty runners --- server/sched.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/sched.go b/server/sched.go index 6bf5eb1f..9eb4430e 100644 --- a/server/sched.go +++ b/server/sched.go @@ -588,6 +588,10 @@ func (s *Scheduler) findRunnerToUnload() *runnerRef { runnerList = append(runnerList, r) } s.loadedMu.Unlock() + if len(runnerList) == 0 { + slog.Debug("no loaded runner to unload") + return nil + } // In the future we can enhance the algorithm to be smarter about picking the optimal runner to unload // e.g., if we have multiple options, will one make room for the request?