Bug 1909289

Summary: oc debug of an init container no longer works
Product: OpenShift Container Platform Reporter: Clayton Coleman <ccoleman>
Component: ocAssignee: Clayton Coleman <ccoleman>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.5CC: aos-bugs, jokerman, maszulik, mfojtik, nstielau
Target Milestone: ---   
Target Release: 4.7.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: InitContainer support was lost during changes to oc debug command. Consequence: It is not possible to debug init containers. Fix: Add support for init containers in oc debug command. Result: It is possible to oc debug init container.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-24 15:47:16 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:
Bug Depends On:    
Bug Blocks: 1913109    

Description Clayton Coleman 2020-12-18 20:29:29 UTC
Sometime in last few releases init containers stopped being debuggable with `oc debug pod/foo -c <init_container_name>`.  The root cause is the wait logic for the pod container to be running ignores init containers.

The fix is to adjust the wait logic to correctly read init containers. Also, I simplified and removed some logic that was subject to exiting early on errors that might be transient (for instance, the first image pull can fail and the second can succeed) and replaced those with warning messages.

May need a backport for 4.6.

Comment 1 Nick Stielau 2021-01-04 20:10:14 UTC
Sounds like this is a regression but not a new one.  Moving to blocker- to denote that we won't block the release on this.

Comment 3 zhou ying 2021-01-07 01:56:56 UTC
Confirmed with latest oc client, can't reproduce the issue now:

[root@dhcp-140-138 ~]# oc version --client -o yaml 
  buildDate: "2021-01-06T04:18:42Z"
  compiler: gc
  gitCommit: d69d7c45db12728241a16411bf81d534fbcad7c4
  gitTreeState: clean
  gitVersion: 4.7.0-202101060325.p0-d69d7c4
  goVersion: go1.15.5
  major: ""
  minor: ""
  platform: linux/amd64

[root@dhcp-140-138 ~]# oc debug  po/openshift-kube-scheduler-ip-1xxxx.compute.internal -c wait-for-host-port
If you don't see a command prompt, try pressing enter.
sh-4.4# exit

Removing debug pod ...

Comment 6 errata-xmlrpc 2021-02-24 15:47:16 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 (Moderate: OpenShift Container Platform 4.7.0 security, bug fix, and enhancement 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.