Description of problem: When launching a oc exec with a command that returns a non zero code, we are unable to capture it since it is not returned by the oc exec command which return only a 1 exit code. Version-Release number of selected component (if applicable): 3.x How reproducible: Always Steps to Reproduce: 1. oc exec dummycomand exec: "dummycommand": executable file not found in $PATH error: Error executing remote command: Error executing command in container: Error executing in Docker Container: -1 2. echo $? 1 3. dummycommand 4. echo $? 127 Actual results: Expected results: 1. oc exec dummycomand exec: "dummycommand": executable file not found in $PATH error: Error executing remote command: Error executing command in container: Error executing in Docker Container: 127 2. echo $? 127 Additional info:
This is a bug, does not have to be an RFE. Impacts scriptability.
Not a 3.2 blocker IMO
Create an upstream issue: https://github.com/kubernetes/kubernetes/issues/26424
https://github.com/kubernetes/kubernetes/issues/26541 has been merged in upstream during the 1.4 release cylce.
This has been merged into ose and is in OSE v3.4.0.17 or newer.
Tested on latest OCP v3.4.0.19 and reproduced by original steps (error occurred on step 2) # oc run dc --image=aosqe/hello-openshift (wait until the pod is ready and running) 1) Successful and code is passed correctly: # oc exec dc-1-vo5vt ls bin ... # echo $? 0 2) Error code 127 can not be passed out from container: # oc exec dc-1-vo5vt somecmd exec: "somecmd": executable file not found in $PATH error: error stream protocol error: invalid exit code value "-1" # echo $? 1 # somecmd bash: somecmd: command not found... # echo $? 127 3) Container get the expected error code # oc rsh dc-1-vo5vt / $ somecmd /bin/sh: somecmd: not found / $ echo $? 127
With kubectl 1.4.5: # kubectl exec sleep-661823049-44uzt somecmd rpc error: code = 2 desc = "oci runtime error: exec failed: exec: \"somecmd\": executable file not found in $PATH"% # echo $? 126 # kubectl exec sleep-661823049-44uzt -- /bin/sh -c somecmd /bin/sh: somecmd: not found # echo $? 127 The 126 should be a 127 as well IMO. Looks like "oc exec" behaves differently. Might be a rebase error.
The 126 is what Docker report for failed exec commands.
I was able to reproduce the "-1" of "oc exec somecmd" using upstream kube and upstream kubectl and Docker 1.10.3 on the nodes. It looks like the exit code return by the "exec start" command of the Docker API is "-1" for 1.10.3 and 126 for 1.12.1.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2017:0066