Bug 1679937 - oc cmd doesn't work in jenkins build step 'OpenShift - Generic OC Invocation'
Summary: oc cmd doesn't work in jenkins build step 'OpenShift - Generic OC Invocation'
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Image
Version: 4.1.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 4.1.0
Assignee: Gabe Montero
QA Contact: XiuJuan Wang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-22 09:41 UTC by XiuJuan Wang
Modified: 2019-06-04 10:44 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Known Issue
Doc Text:
Cause: compatibility between java based jenkins process launching and golang based oc argument processing is sometime incompatable; for example, on `oc get`, you must use `type/name`, not `type name` Consequence: not every possible argument combination from the linux command line is possible from the jenkins; you have to use the valid forms Fix: update the UI help to inform users of some of the restrictions Result: users will know what form to use
Clone Of:
Environment:
Last Closed: 2019-06-04 10:44:26 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0758 None None None 2019-06-04 10:44:33 UTC

Description XiuJuan Wang 2019-02-22 09:41:27 UTC
Description of problem:
oc cmd doesn't work in jenkins build step 'OpenShift - Generic OC Invocation' 

Version-Release number of selected component (if applicable):
jenkins quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:0cb6e590a504f26a5794e5104275d5cea1ca9d84fbc794eafe7965910563bdd6

openshift-client plugin 1.0.25

How reproducible:
always

Steps to Reproduce:
1.Create a freestyle item
2.Add build step:
"OpenShift - Generic OC Invocation"
Input value like below:
Command to pass into the `oc` binary: 'get'
Arguments associated with the above command: 'pod hello-openshift'


Actual results:
step 2: Job failed
Started by user xiuwang
Building in workspace /var/lib/jenkins/jobs/test/workspace
Executing: oc --server=https://172.30.0.1:443 --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt --namespace=xiu --token=XXXXX get pod hello-openshift  
Error: unknown command "get pod hello-openshift" for "oc"
Run 'oc --help' for usage.
Client tool terminated with status: 1
Build step 'OpenShift - Generic OC Invocation' marked build as failure

Expected results:
Should get pod returned

Additional info:
Could get correct result in the jenkins server pod.
sh-4.2$ oc --server=https://172.30.0.1:443  --certificate-authority=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt --namespace=xiu  get pod hello-openshift --token Ts-RV_r3aQ9U-HNn8Jfrz-5V7ZTfoqYYAHMSmV1V7C4 
NAME              READY   STATUS    RESTARTS   AGE
hello-openshift   1/1     Running   0          11m

Comment 1 Gabe Montero 2019-02-22 16:09:28 UTC
Should be able to address this in time, but given the infrequency of freestyle jobs and client plugin we see
(I might remember 1 github issue *ever*, very early on, and no support cases)

Marking both priority and severity as low

Comment 2 Gabe Montero 2019-02-22 18:28:51 UTC
OK this is different than what I thought.  There is some difference in how `oc` works when launched via process string from Jenkins than it does when launched from the command line.  Jenkins must be setting the args in the actual process fork in a way that is confusing `oc`.

I can confirm that like XiuJuan manually running the command exactly as we pass it Jenkins, it works.  

Now, If you change "pod hello-openshift" to "pod/hello-openshift" in the "Arguments associated with the above command", with "get" in the "Command to pass into the `oc` binary", then it works from Jenkins with the freestyle build step.

By the way, when you leverage the pipeline dsl form of this, the plugin constructs the command line as "pod/hello-openshift".  Pretty sure that is a workaround for this issue.


Now, I ran with -loglevel=10 on the jenkins run, and it wants to treat "pod <podname>" as the actual type, vs. type/name.  Jenkins must someone group the name and type with a space in between as one arg from the oc/golang perspective.


So ACTION PLAN:
1) XiuJuan - re-run where you change "pod hello-openshift" to "pod/hello-openshift" in the "Arguments associated with the above command", with "get" in the "Command to pass into the `oc` binary" and confirm it works for you too
2) if so, I'll use this bug to update the help text in the Jenkins UI, and that is all we do 

getting kube/cli fixes to deal with getting forked by Jenkins API is a lost cause

Comment 3 XiuJuan Wang 2019-02-26 09:11:52 UTC
Gabe
So ACTION PLAN:
1)re-run where you change "pod hello-openshift" to "pod/hello-openshift" in the "Arguments associated with the above command", with "get" in the "Command to pass into the `oc` binary" 
This works for me
Thanks!

Comment 4 Gabe Montero 2019-02-27 18:51:31 UTC
PR https://github.com/openshift/jenkins-client-plugin/pull/240 is up

Comment 5 Gabe Montero 2019-02-27 20:50:21 UTC
plugin PR has merged

Next steps:
- cut a new version of the plugin
- update the image

Comment 6 Gabe Montero 2019-03-01 20:21:10 UTC
v1.0.27 of the client plugin has been generated with the new field help for the Jenkins UI panel for client plugin free style jobs 

image PR will get created when the version is available at the jenkins update center

Comment 7 Gabe Montero 2019-03-04 19:20:14 UTC
ok new rpm has been cut in osbs/distgit via http://pkgs.devel.redhat.com/cgit/rpms/jenkins-2-plugins/commit/?h=rhaos-4.0-rhel-7&id=af50d53fa52ca60840c40f26af2c02a26963817e

sending to QE to look out for the next ocp build with that to verify new help text is available

Comment 8 XiuJuan Wang 2019-03-07 08:21:45 UTC
The help doc have updated with 
registry.svc.ci.openshift.org/ocp/4.0-2019-03-07-043538@sha256:3ae4400256748815121ffb2e09e341802abe0d90afbba8e7a41ad45efb9bd73c

The arguments associated with the command provided. Note, if you are to operate on a specific type and instance of an API object, like `oc get pod `, you have to use the form `oc get pod/`. The space separator between type and instance ID is not supported. 

Mark this to verified.
Thanks

Comment 11 errata-xmlrpc 2019-06-04 10:44:26 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, 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-2019:0758


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