Skip to content

Commit

Permalink
fix(log): Fixing useless error when pod is deleted
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Aug 30, 2023
1 parent 3cc592b commit c942228
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ func (l Logger) Log(ctx context.Context, kube client.Kube) error {
if event.Type == watch.Deleted || event.Type == watch.Error || pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodFailed {
if ok {
streamCancel.(context.CancelFunc)()
activeStreams.Delete(pod.UID)

if event.Type == watch.Deleted {
activeStreams.Delete(pod.UID)
}
} else if pod.Status.Phase == v1.PodSucceeded || pod.Status.Phase == v1.PodFailed {
l.handlePod(ctx, kube, &activeStreams, streaming, *pod)
}
Expand Down Expand Up @@ -168,7 +171,7 @@ func (l Logger) logPod(ctx context.Context, kube client.Kube, namespace, name, c
Container: container,
}).DoRaw(ctx)
if err != nil {
kube.Err("%s", err)
kube.Err("get logs: %s", err)
return
}

Expand All @@ -182,7 +185,7 @@ func (l Logger) streamPod(ctx context.Context, kube client.Kube, namespace, name
Container: container,
}).Stream(ctx)
if err != nil {
kube.Err("%s", err)
kube.Err("stream logs: %s", err)
return
}

Expand Down

0 comments on commit c942228

Please sign in to comment.