Skip to content

Commit

Permalink
fix logs race condition in worker (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Lombardi <[email protected]>
  • Loading branch information
luke-lombardi and Luke Lombardi authored Apr 5, 2024
1 parent f8b7dfa commit fe44217
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,9 @@ func (s *Worker) RunContainer(request *types.ContainerRequest) error {

bundlePath := filepath.Join(s.userImagePath, request.ImageId)

hostname := fmt.Sprintf("%s:%d", s.podAddr, defaultWorkerServerPort)
err := s.containerRepo.SetWorkerAddress(request.ContainerId, hostname)
if err != nil {
return err
}

// Pull image
log.Printf("<%s> - lazy-pulling image: %s\n", containerID, request.ImageId)
err = s.imageClient.PullLazy(request.ImageId)
err := s.imageClient.PullLazy(request.ImageId)
if err != nil && request.SourceImage != nil {
log.Printf("<%s> - lazy-pull failed, pulling source image: %s\n", containerID, *request.SourceImage)
err = s.imageClient.PullAndArchiveImage(context.TODO(), *request.SourceImage, request.ImageId, nil)
Expand Down Expand Up @@ -501,6 +496,10 @@ func (s *Worker) spawn(request *types.ContainerRequest, bundlePath string, spec
}
s.containerInstances.Set(containerId, containerInstance)

// Set worker hostname
hostname := fmt.Sprintf("%s:%d", s.podAddr, defaultWorkerServerPort)
s.containerRepo.SetWorkerAddress(request.ContainerId, hostname)

// Handle stdout/stderr from spawned container
go s.containerLogger.CaptureLogs(request.ContainerId, outputChan)

Expand Down

0 comments on commit fe44217

Please sign in to comment.