Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions ai/worker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ func (m *DockerManager) watchContainer(rc *RunnerContainer) {
defer ticker.Stop()

slog.Info("Watching container", slog.String("container", rc.Name))
var loadingStartTime time.Time
failures := 0
loadingStartTime := time.Now()
for {
if failures >= maxHealthCheckFailures {
slog.Error("Container health check failed too many times", slog.String("container", rc.Name))
Expand Down Expand Up @@ -641,17 +641,19 @@ func (m *DockerManager) watchContainer(rc *RunnerContainer) {
}
fallthrough
case OK:
failures = 0
failures, loadingStartTime = 0, time.Time{}
continue
case "LOADING": // TODO: Use enum when ai-runner SDK is updated
if !isBorrowed {
slog.Info("Container is loading, removing from pool", slog.String("container", rc.Name))
failures = 0
loadingStartTime = time.Now()

m.mu.Lock()
m.borrowContainerLocked(context.Background(), rc)
m.mu.Unlock()
case LOADING:
if loadingStartTime.IsZero() {
failures, loadingStartTime = 0, time.Now()

if !isBorrowed {
slog.Info("Container is loading, removing from pool", slog.String("container", rc.Name))

m.mu.Lock()
m.borrowContainerLocked(context.Background(), rc)
m.mu.Unlock()
}
}
if loadingTime := time.Since(loadingStartTime); loadingTime > containerTimeout {
failures++
Expand Down
Loading