diff --git a/executor/linux/build.go b/executor/linux/build.go index c31e2938..d59d5700 100644 --- a/executor/linux/build.go +++ b/executor/linux/build.go @@ -536,6 +536,7 @@ func (c *client) StreamBuild(ctx context.Context) error { return nil }) case <-ctx.Done(): + c.Logger.Debug("streaming context canceled") // build done or canceled return nil } diff --git a/executor/local/build.go b/executor/local/build.go index 70556d9e..233c1c49 100644 --- a/executor/local/build.go +++ b/executor/local/build.go @@ -374,7 +374,7 @@ func (c *client) StreamBuild(ctx context.Context) error { select { case req := <-c.streamRequests: streams.Go(func() error { - fmt.Fprintf(os.Stdout, "streaming %s container %s", req.Key, req.Container.ID) + fmt.Fprintf(os.Stdout, "[%s: %s] > Streaming container '%s'...\n", req.Key, req.Container.Name, req.Container.ID) err := req.Stream(streamCtx, req.Container) if err != nil { diff --git a/runtime/kubernetes/container.go b/runtime/kubernetes/container.go index 28e0932d..ab6914c1 100644 --- a/runtime/kubernetes/container.go +++ b/runtime/kubernetes/container.go @@ -232,10 +232,6 @@ func (c *client) setupContainerEnvironment(ctn *pipeline.Container) error { func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io.ReadCloser, error) { c.Logger.Tracef("tailing output for container %s", ctn.ID) - // create a logsContext that will be canceled at the end of this - logsContext, logsDone := context.WithCancel(ctx) - defer logsDone() - // create object to store container logs var logs io.ReadCloser @@ -259,9 +255,9 @@ func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io stream, err := c.Kubernetes.CoreV1(). Pods(c.config.Namespace). GetLogs(c.Pod.ObjectMeta.Name, opts). - Stream(logsContext) + Stream(ctx) if err != nil { - c.Logger.Errorf("%v", err) + c.Logger.Errorf("error while requesting pod/logs stream for container %s: %v", ctn.ID, err) return false, nil } @@ -303,8 +299,9 @@ func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io // perform the function to capture logs with periodic backoff // // https://pkg.go.dev/k8s.io/apimachinery/pkg/util/wait?tab=doc#ExponentialBackoff - err := wait.ExponentialBackoffWithContext(logsContext, backoff, logsFunc) + err := wait.ExponentialBackoffWithContext(ctx, backoff, logsFunc) if err != nil { + c.Logger.Errorf("exponential backoff error while tailing container %s: %v", ctn.ID, err) return nil, err }