diff --git a/internal/worker/worker.go b/internal/worker/worker.go index 72362d983..5d91a7e07 100644 --- a/internal/worker/worker.go +++ b/internal/worker/worker.go @@ -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) @@ -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)