Bug 2074902 - `oc debug node/nodename — chroot /host somecommand` should exit with non-zero when the sub-command failed
Summary: `oc debug node/nodename — chroot /host somecommand` should exit with non-zero...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.11
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.11.0
Assignee: Arda Guclu
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-04-13 10:01 UTC by zhou ying
Modified: 2022-08-10 11:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-08-10 11:07:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift oc pull 1115 0 None open Bug 2074902: Pass non-zero exit code to debug command 2022-04-21 08:04:20 UTC
Red Hat Product Errata RHSA-2022:5069 0 None None None 2022-08-10 11:07:26 UTC

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


Note You need to log in before you can comment on or make changes to this bug.