Skip to content

Commit

Permalink
fix log line and lock on borrowContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-video committed Jun 16, 2024
1 parent 7a4dcc9 commit d01070b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ func (w *Worker) borrowContainer(ctx context.Context, pipeline, modelID string)
for key, rc := range w.externalContainers {
if rc.Pipeline == pipeline && rc.ModelID == modelID {
// The current implementation of ai-runner containers does not have a queue so only do one request at a time to each container
slog.Info("selecting container to run request", slog.Int("type", int(rc.Type)), slog.Int("capacity", rc.Capacity), slog.String("url", rc.Endpoint.URL))
if rc.Capacity > 0 {
w.mu.Unlock()
slog.Info("selecting container to run request", slog.Int("type", int(rc.Type)), slog.Int("capacity", rc.Capacity), slog.String("url", rc.Endpoint.URL))
w.externalContainers[key].Capacity -= 1
w.mu.Unlock()
return rc, nil
}
}
Expand All @@ -333,7 +333,7 @@ func (w *Worker) borrowContainer(ctx context.Context, pipeline, modelID string)
}

func (w *Worker) returnContainer(rc *RunnerContainer) {
slog.Info("returning container to be available", slog.Int("type", int(rc.Type)), slog.String("url", rc.Endpoint.URL))
slog.Info("returning container to be available", slog.Int("type", int(rc.Type)), slog.Int("capacity", rc.Capacity), slog.String("url", rc.Endpoint.URL))

switch rc.Type {
case Managed:
Expand All @@ -342,7 +342,7 @@ func (w *Worker) returnContainer(rc *RunnerContainer) {
w.mu.Lock()
defer w.mu.Unlock()
//free external container for next request
for key, rc := range w.externalContainers {
for key, _ := range w.externalContainers {
if w.externalContainers[key].Endpoint.URL == rc.Endpoint.URL {
w.externalContainers[key].Capacity += 1
}
Expand Down

0 comments on commit d01070b

Please sign in to comment.