mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
run must output message on container error
This commit is contained in:
parent
a9bf44101b
commit
f623b9b42f
@ -362,7 +362,7 @@ func RunRun(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *c
|
|||||||
return unknownRcErr
|
return unknownRcErr
|
||||||
}
|
}
|
||||||
return uexec.CodeExitError{
|
return uexec.CodeExitError{
|
||||||
Err: fmt.Errorf("pod %s/%s terminated", pod.Namespace, pod.Name),
|
Err: fmt.Errorf("pod %s/%s terminated (%s)\n%s", pod.Namespace, pod.Name, pod.Status.ContainerStatuses[0].State.Terminated.Reason, pod.Status.ContainerStatuses[0].State.Terminated.Message),
|
||||||
Code: int(rc),
|
Code: int(rc),
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -167,8 +167,7 @@ func checkErr(err error, handleErr func(string, int)) {
|
|||||||
case utilerrors.Aggregate:
|
case utilerrors.Aggregate:
|
||||||
handleErr(MultipleErrors(``, err.Errors()), DefaultErrorExitCode)
|
handleErr(MultipleErrors(``, err.Errors()), DefaultErrorExitCode)
|
||||||
case utilexec.ExitError:
|
case utilexec.ExitError:
|
||||||
// do not print anything, only terminate with given error
|
handleErr(err.Error(), err.ExitStatus())
|
||||||
handleErr("", err.ExitStatus())
|
|
||||||
default: // for any other error type
|
default: // for any other error type
|
||||||
msg, ok := StandardErrorMessage(err)
|
msg, ok := StandardErrorMessage(err)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -269,7 +269,7 @@ func TestCheckExitError(t *testing.T) {
|
|||||||
testCheckError(t, []checkErrTestCase{
|
testCheckError(t, []checkErrTestCase{
|
||||||
{
|
{
|
||||||
uexec.CodeExitError{Err: fmt.Errorf("pod foo/bar terminated"), Code: 42},
|
uexec.CodeExitError{Err: fmt.Errorf("pod foo/bar terminated"), Code: 42},
|
||||||
"",
|
"pod foo/bar terminated",
|
||||||
42,
|
42,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user