rhtconsulting / rhc-ose

OpenShift Automation and Utilities by Red Hat Consulting
42 stars 34 forks source link

using osc-provision requires --num-etcd argument when it shouldn't #141

Open oybed opened 8 years ago

oybed commented 8 years ago

Running a plain "osc-provision" fails if the --num-etcd parameter isn't supplied. By default it should work the same way as it used to (i.e.: one etcd on the master) and don't error out.

Below is an example run:

./osc-provision --num-nodes=2 --key=obedin-ose3-pub-key
WARNING: Did not request a specific OSE version, or version not supported (3.0|3.1) - using default version/configuration
Provisioning Utility Host. This could take several minutes.
Complete!
Provisioning master. This could take several minutes.
Complete!
Provisioning -1 etcd. This could take several minutes.
ERROR (CommandError): num_instances should be >= 1
ERROR: Provisioning Failed.
sabre1041 commented 8 years ago

@oybed I ran through a fresh repository clone and did not run into this issue.

Could it possibly be an issue with the name of your key?

oybed commented 8 years ago

@sabre1041 @JaredBurck finally got a chance to look into this a bit more and I believe it's the if-statement with the double brackets causing the discrepancy (see below). And it could be because maybe we're running different shells or versions of the shell. In my case it is:

>> $SHELL --version
GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)

The issue is that the if condition below doesn't work right in my case - i.e.: "-1 > 0" evaluates to true.

if [[ $num_etcd_instances > 0 ]]; then

I'd suggest changing this to the following to make it a bit more robust for various shells / versions:

if [ "${num_etcd_instances}" -gt "0" ]; then

... or, alternatively, the following is also A_OK, but I prefer the above:

if (("${num_etcd_instances}" > "0")); then