@@ -232,10 +232,6 @@ func (c *client) setupContainerEnvironment(ctn *pipeline.Container) error {
232232func (c * client ) TailContainer (ctx context.Context , ctn * pipeline.Container ) (io.ReadCloser , error ) {
233233 c .Logger .Tracef ("tailing output for container %s" , ctn .ID )
234234
235- // create a logsContext that will be canceled at the end of this
236- logsContext , logsDone := context .WithCancel (ctx )
237- defer logsDone ()
238-
239235 // create object to store container logs
240236 var logs io.ReadCloser
241237
@@ -259,9 +255,9 @@ func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io
259255 stream , err := c .Kubernetes .CoreV1 ().
260256 Pods (c .config .Namespace ).
261257 GetLogs (c .Pod .ObjectMeta .Name , opts ).
262- Stream (logsContext )
258+ Stream (ctx )
263259 if err != nil {
264- c .Logger .Errorf ("%v" , err )
260+ c .Logger .Errorf ("error while requesting pod/logs stream for container %s: %v" , ctn . ID , err )
265261 return false , nil
266262 }
267263
@@ -303,8 +299,9 @@ func (c *client) TailContainer(ctx context.Context, ctn *pipeline.Container) (io
303299 // perform the function to capture logs with periodic backoff
304300 //
305301 // https://pkg.go.dev/k8s.io/apimachinery/pkg/util/wait?tab=doc#ExponentialBackoff
306- err := wait .ExponentialBackoffWithContext (logsContext , backoff , logsFunc )
302+ err := wait .ExponentialBackoffWithContext (ctx , backoff , logsFunc )
307303 if err != nil {
304+ c .Logger .Errorf ("exponential backoff error while tailing container %s: %v" , ctn .ID , err )
308305 return nil , err
309306 }
310307
0 commit comments