Skip to content

Commit 7ec4b4f

Browse files
authored
fix get container logs panic in some case (#4592)
Signed-off-by: Patrick Zhao <zhaoyu@koderover.com>
1 parent f6c95f1 commit 7ec4b4f

File tree

1 file changed

+3
-0
lines changed
  • pkg/tool/kube/containerlog

1 file changed

+3
-0
lines changed

pkg/tool/kube/containerlog/log.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func GetContainerLogs(namespace, podName, containerName string, follow bool, tai
4747
if len(pod.Status.ContainerStatuses) == 0 {
4848
return fmt.Errorf("length of container statuses is 0 for pod %s in ns %s", podName, namespace)
4949
}
50+
if pod.Status.ContainerStatuses[0].State.Terminated == nil {
51+
return fmt.Errorf("failed to get pod status' terminated message")
52+
}
5053

5154
_, err = out.Write([]byte(pod.Status.ContainerStatuses[0].State.Terminated.Message))
5255
return err

0 commit comments

Comments
 (0)