Skip to content

Commit

Permalink
Don't error if log reconnection fails due to context canceled
Browse files Browse the repository at this point in the history
Don't retry either as the context won't become uncanceled
  • Loading branch information
willthames committed Oct 13, 2023
1 parent 5c4dfac commit 5ae50ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ func (kw *kubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout
errMsg := fmt.Sprintf("Error getting pod %s/%s. Error: %s", podNamespace, podName, err)
kw.Error(errMsg)
kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0)

break

Check failure on line 228 in pkg/workceptor/kubernetes.go

View workflow job for this annotation

GitHub Actions / lint-receptor

break with no blank line before (nlreturn)
}

Expand All @@ -239,6 +238,13 @@ func (kw *kubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout
for *stdinErr == nil { // check between every line read to see if we need to stop reading
line, err := streamReader.ReadString('\n')
if err != nil {
if kw.ctx.Err() == context.Canceled {
kw.Info(
"Context was canceled while reading logs for pod %s/%s. Assuming pod has finished",
podNamespace,
podName)
return

Check failure on line 246 in pkg/workceptor/kubernetes.go

View workflow job for this annotation

GitHub Actions / lint-receptor

return with no blank line before (nlreturn)
}

Check warning on line 247 in pkg/workceptor/kubernetes.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/kubernetes.go#L241-L247

Added lines #L241 - L247 were not covered by tests
kw.Info(
"Detected Error: %s for pod %s/%s. Will retry %d more times.",
err,
Expand Down

0 comments on commit 5ae50ec

Please sign in to comment.