Skip to content
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

Fix parse error for multiple OPTIONS to run node #17212

Merged
merged 2 commits into from
Nov 14, 2017
Merged

Fix parse error for multiple OPTIONS to run node #17212

merged 2 commits into from
Nov 14, 2017

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Nov 7, 2017

bash env variables put single quotation ('') when the variable has
"". Due to this and behavior of golang's parse mechanism,
containerized OpenShift Node cannot start if OPTIONS contains multiple
variables.

This patch removes the double quotations from the start script of
OpenShift Node.

You can simulate the issue with following steps:

  1. Start running containerized OpenShift Node image
# /usr/bin/docker run -it --entrypoint=/bin/bash  \
-v /etc/origin/node:/etc/origin/node -e OPTIONS="--loglevel=3 --disable=proxy" \
registry.access.redhat.com/openshift3/node:v3.6.173.0.49
  1. Run /usr/local/bin/origin-node-run.sh or openshift start node '--loglevel=3 --disable=proxy'
[root@20de90d3c238 origin]# /usr/local/bin/origin-node-run.sh
Error: invalid argument "3 --disable=proxy" for --loglevel=3 --disable=proxy: strconv.ParseInt: parsing "3 --disable=proxy": invalid syntax
[root@eb7e4d9cea08 origin]# exec /usr/bin/openshift start node --config=/etc/origin/node/node-config.yaml '--loglevel=3 --disable=proxy'
Error: invalid argument "3 --disable=proxy" for --loglevel=3 --disable=proxy: strconv.ParseInt: parsing "3 --disable=proxy": invalid syntax

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 7, 2017
@nak3
Copy link
Contributor Author

nak3 commented Nov 7, 2017

@sdodson
Copy link
Member

sdodson commented Nov 7, 2017

@Miciah mind validating this bash change?

@sdodson
Copy link
Member

sdodson commented Nov 7, 2017

/assign miciah

@0xmichalis
Copy link
Contributor

/retest

@@ -8,4 +8,4 @@ if [ "$#" -ne 0 ]; then
opts=""
fi

exec /usr/bin/openshift start node "--config=${conf}" "${opts}" $@
exec /usr/bin/openshift start node "--config=${conf}" ${opts} $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine if we do not need to support values with whitespace.

/lgtm

However, if we do want to support values with whitespace (e.g., OPTIONS=--foo='bar baz' --foo=bar\ baz --foo="bar baz"), we need to do something a little fancier. The following uses eval to perform shell word splitting on the value of OPTIONS:

eval "opts=( ${OPTIONS:---loglevel=2} )"
if [[ "$#" -ne 0 ]]; then
  opts=( "$@" )
fi

exec /usr/bin/openshift start node "--config=${conf}" "${opts[@]}"

Alternatively, the following is simpler in my opinion (but use your own judgment):

if [[ "$#" -eq 0 ]]; then
  eval "set -- ${OPTIONS:---loglevel=2}"
fi

exec /usr/bin/openshift start node "--config=${conf}" "$@"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am quite sure that OpenShfit/k8s will not support whitespace options like OPTIONS=--foo='bar baz'. However, it is not 0%, and also I don't want to overlook @Miciah's excellent idea, so updated the PR with his second option.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2017
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2017
@nak3 nak3 changed the title Remove double quotations from docker env to run node Fix parse error for multiple OPTIONS to run node Nov 9, 2017
@Miciah
Copy link
Contributor

Miciah commented Nov 9, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2017
@sdodson
Copy link
Member

sdodson commented Nov 13, 2017

/approve

@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Miciah, nak3, sdodson

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 13, 2017
@nak3
Copy link
Contributor Author

nak3 commented Nov 14, 2017

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 14, 2017

@nak3: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_install_update 549f540 link /test extended_conformance_install_update

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit b4f00a8 into openshift:master Nov 14, 2017
@nak3 nak3 deleted the remove-quote-docker-env branch December 29, 2017 10:27
@sdodson
Copy link
Member

sdodson commented Jan 3, 2018

/cherrypick release-3.8

@openshift-cherrypick-robot

@sdodson: #17212 failed to apply on top of branch "release-3.8":

error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
M	images/node/scripts/origin-node-run.sh
Falling back to patching base and 3-way merge...
Auto-merging images/node/scripts/origin-node-run.sh
CONFLICT (content): Merge conflict in images/node/scripts/origin-node-run.sh
Patch failed at 0001 Remove double quotations from docker env to run node

In response to this:

/cherrypick release-3.8

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants