-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running oc
with Proc to avoid command expansion
#176
Running oc
with Proc to avoid command expansion
#176
Conversation
/ok-to-test |
500a32e
to
77aa61f
Compare
I believe the test failure is a problem of the test suite: To run openshift.rsh("some-pod", "ps", "ax") not openshift.rsh("some-pod", "ps ax") The latter should be interpreted as running an executable named |
if the test was passing as it was, then people may have written pipelines expecting that behavior as well, so changing/breaking it is not an option. |
@bparees Right, that could break things. A practical use case is to pass environment variables with values containing spaces and special bash characters (like |
I don't disagree, but i also don't want to break existing users, so I think we need to think about the best way to introduce this change..we may have to introduce a flag so people are opting into the new behavior. |
@bparees Thanks for the explanation. I'll also think about the best way to make this change. |
@bparees Following are my thoughts to make the change compatible:
What do you think? |
it sounds ok to me, but let's wait for @gabemontero to come back on monday and see if he has any other ideas/thoughts that could avoid having to have a top level config field for this. |
@bparees Thanks. I'll adding an option to see if this change can pass all tests. |
a5fe218
to
b4a5cba
Compare
So on situation related to the second commit ... the precise failure may have provided some context and reminders of prior history for me (I can't find it now), but I suspect that the grouping of "ps aux" may have stemmed from groovy shortcomings and OpenShiftDSL method signature shortcomings that arose as a result. For example, I vaguely recall groovy confusing the Assuming my recollections are on the right path, I'd be curious if @vfreex could examine the arg array in https://github.com/openshift/jenkins-client-plugin/blob/master/src/main/resources/com/openshift/jenkins/plugins/OpenShiftDSL.groovy#L908-L914 and entries in the array along spaces, and create a new array with the extra entries, and get the "ps aux" scenario to pass. If so, I'd say we could punt on the config opt in stuff. If this is not the right track, then I'll need a repro of the failure with the relevant logs, etc. Generally speaking, I really like @vfreex 's change here, and getting off Durable Task. That said, my initial thought is not get this into 3.11, it is too late, and target this for 4.0, where it gets a full release worth of soaking with our upstream users. But we can discuss that in parallel as needed. |
@gabemontero Thanks for your comment. I examined the Groovy code and it seems to me the caller passes arguments to Personally I don't expect the behavior of spiting arguments by spaces to become a long-term solution, otherwise it will be impossible to pass arguments including spaces unless introducing escape characters, which will increase the complexity. For example, to create a file named |
@gabemontero Thanks for digging out. I'll take a look soon. |
@gabemontero What I'll file a bug report to Jenkins. At the same time, a workaround for this PR should be used. Options like:
|
sounds good on all points @vfreex - we'll await your next update |
b4a5cba
to
436e900
Compare
@gabemontero Hi, I've updated the PR. The new change uses |
a817ca5
to
9457ab3
Compare
This PR reimplements the mechanism to run `oc` command on a slave. When using OpenShift Pipeline DSL, `oc` process is started with `DurableTask`, which is designed to run a bash script or batch script on a slave. This is not ideal because when the command arguments include special characters (like whitespaces, `#`, `!`, `;`), it's hard to escape them correctly. The new implementation uses standard Jenkins API to start a `oc` process on a slave. `stdout` and `stderr` outputs are piped to Jenkins master so that polling is not needed.
9457ab3
to
ea6bc45
Compare
oc
with Launcher to avoid command explansionoc
with Proc to avoid command expansion
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gabemontero, vfreex The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
verified the verbose fix locally ... thanks again @vfreex I'll initiate a new version shortly and update here and in the bugzilla To remind on an earlier comment, given the depth of change, for now at least, we'll only pull into v4 of our openshift jenkins images. As time progresses and we get some traction with the upstream community, we can reassess updating older releases. |
Running `oc` with Proc to avoid command expansion
v1.0.17 of the client plugin as been initiated at the jenkins update center |
Hey @vfreex ... fyi, turns out the switch from See https://bugzilla.redhat.com/show_bug.cgi?id=1657208 The oc command is getting executed in the jnlp default container using the alpine image, where of course it is not present. The sidecar scenario works with the version of this plugin (the last being v1.0.16) that leveraged the jenkins Launcher to invoke As a shot in the dark, I did pick up your jenkinsci/kubernetes-plugin#377 by bumping the k8s plugin to 1.12.9, but it had no effect. I've started considering the option 1) you noted in #176 (comment) as a means to both solve the verbose logging issue as well as re-engage the k8s plugin container decorator to get the command running in the right container. If you have a sec and recall any issues if and when you tried that, please let me know. thanks |
my prototype seems to be working ... hope to have a PR up soon |
This PR reimplements the mechanism to run
oc
command on a slave. It fixes https://bugzilla.redhat.com/show_bug.cgi?id=1625518Why this is needed
We met issues when using pipeline syntax with Jenkins Client Plugin. When an option passed to a
Selector
contains spaces or special characters (like#
,;
, etc), they are mistakenly explained by shell rather than passed to theoc
process.The current implementation
When using OpenShift Pipeline DSL,
oc
process is started withDurableTask
,which is designed to run a bash script or batch script on a slave.
This is not ideal because when the command arguments include special characters
(like whitespaces,
#
,!
,;
), it's hard to escape them correctly.The new implementation
The new implementation uses standard Jenkins API to start a
oc
processon a slave.
stdout
andstderr
outputs are piped to Jenkins masterso that polling is not needed.