Bug 2074902

Summary: `oc debug node/nodename — chroot /host somecommand` should exit with non-zero when the sub-command failed
Product: OpenShift Container Platform Reporter: zhou ying <yinzhou>
Component: ocAssignee: Arda Guclu <aguclu>
oc sub component: oc QA Contact: zhou ying <yinzhou>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: aos-bugs, mfojtik
Version: 4.11   
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-10 11:07:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description zhou ying 2022-04-13 10:01:09 UTC
Description of problem:
`oc debug node/nodename — chroot /host somecommand` should exit with non-zero when the sub-command failed


Version-Release number of selected component (if applicable):
Client Version: 4.11.0-202204122151.p0.ge88515d.assembly.stream-e88515d


How reproducible:
Always

Steps to Reproduce:
Run command :
`oc debug node/ip-10-0-52-208.us-east-2.compute.internal -- chroot /host datest`


Actual results:
1. Sub command failed , but check the exit code is sitll 0:
oc debug node/ip-xxxxx.compute.internal -- chroot /host datest
Starting pod/ip-xxxxx.computeinternal-debug ...
To use host binaries, run `chroot /host`
chroot: failed to run command 'datest': No such file or directory

Removing debug pod ...
[root@localhost ~]# echo $?
0

  

Expected results:
When the sub command failed , the exit code should non-zero



Additional info:

Comment 1 Maciej Szulik 2022-04-15 14:17:20 UTC
Similar invocation but with oc rsh will indeed return non-zero exit code, so we should ensure both work similar.

Comment 4 zhou ying 2022-04-26 08:51:24 UTC
checked with latest oc, the issue has fixed:

oc debug node/yinzhou-0426-gstwh-master-0 -- chroot /host datest
Warning: would violate PodSecurity "restricted:latest": host namespaces (hostNetwork=true, hostPID=true), hostPath volumes (volume "host"), privileged (container "container-00" must not set securityContext.privileged=true), allowPrivilegeEscalation != false (container "container-00" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "container-00" must set securityContext.capabilities.drop=["ALL"]), restricted volume types (volume "host" uses restricted volume type "hostPath"), runAsNonRoot != true (pod or container "container-00" must set securityContext.runAsNonRoot=true), runAsUser=0 (container "container-00" must not set runAsUser=0), seccompProfile (pod or container "container-00" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
Starting pod/yinzhou-0426-gstwh-master-0-debug ...
To use host binaries, run `chroot /host`
chroot: failed to run command 'datest': No such file or directory

Removing debug pod ...
error: non-zero exit code from debug container
[root@localhost ~]# echo $?
1


 oc version --client
Client Version: 4.11.0-202204260818.p0.g5c77c00.assembly.stream-5c77c00
Kustomize Version: v4.5.4

Comment 6 errata-xmlrpc 2022-08-10 11:07:02 UTC
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 (Important: OpenShift Container Platform 4.11.0 bug fix and security update), 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/RHSA-2022:5069