Skip to content

Commit

Permalink
Merge pull request #1592 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1571-to-release-4.14

[release-4.14] OCPBUGS-22702: Reflect container's exit code for long running tasks not attached to terminal
  • Loading branch information
openshift-ci[bot] committed Nov 2, 2023
2 parents 035884c + 111c7d7 commit 9b1e0d2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pkg/cli/debug/debug.go
Expand Up @@ -627,7 +627,29 @@ func (o *DebugOptions) RunDebug() error {
case err != nil:
return err
case !o.Attach.Stdin:
return o.getLogs(pod)
if err = o.getLogs(pod); err != nil {
return err
}
lastWatchEvent, err := watchtools.UntilWithSync(ctx, lw, &corev1.Pod{}, preconditionFunc, conditions.PodDone)
if err != nil {
if kapierrors.IsNotFound(err) {
return nil
}
return err
}

resultPod, ok := lastWatchEvent.Object.(*corev1.Pod)
if ok {
for _, s := range append(append([]corev1.ContainerStatus{}, resultPod.Status.InitContainerStatuses...), resultPod.Status.ContainerStatuses...) {
if s.Name != o.ContainerName {
continue
}
if s.State.Terminated != nil && s.State.Terminated.ExitCode != 0 {
return conditions.ErrNonZeroExitCode
}
}
}
return nil
default:
if !o.Quiet {
// TODO this doesn't do us much good for remote debugging sessions, but until we get a local port
Expand Down

0 comments on commit 9b1e0d2

Please sign in to comment.