Hi Valentin,

Maybe this is a difference of expectation, based on a different interpretation of the name.

If I called:

   ifExecutableElse("curl", "curl " + myurl, "wget " + myurl)

Then I'd expect it to execute the first command if curl exists, and the second command if curl does not (i.e. I read this as "if executable exists then ... else ...").

However, it generates the opposite command:

   if test -z `which curl`; then curl ...; else wget ...; fi

To make its semantics clearer, perhaps this method should be renamed to something like "ifExecutableDoesNotExistElse"? Or perhaps change the semantics to what I expected and call it "ifExecutableExistsElse" (or with the same method name, but ensure javadoc is clear).

---
The ifExecutableElse0 does things the other way round:

   return alternativesGroup(
                    chainGroup(format("test -z `which %s`",
   executable), "true"),
                    command);

i.e. in the current implementation, ifExecutableElse0(executable, command) is the equivalent of calling ifExecutableElse(executable, true, command).

Aled


On 10/04/2016 21:24, Valentin Aitken wrote:
Hi,

BashCommands.ifExecutableElse(String, List, List) is correct and it has been tested many times before. It is an extension of BashCommands.ifExecutableElse0(String executable, String command) but with an else option.

test -z checks whether stdout length is zero. I will elaborate this with an example if test -z `which dir`; then echo executing the other; else echo executing dir; fi

---
Aled, I think Riak is not tested in CentOS 7. The installation steps should be the same but it may have some small differences with firewall or else.

Valentin.

On 10/04/16 23:11, Aled Sage wrote:
Regarding Svet's finding that RiakCluster has a problem:

   Found a problem with template 3 - it's failing because of a problem
   in RiakCluster. It's swapping the install scripts for redhat and
   debian based systems, see [1].

   [1]
https://github.com/apache/brooklyn-library/blob/master/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java#L195


This works for me.

I tested on aws-ec2:eu-central-1 and it worked (letting it choose an AMI - ubuntu-trusty-14.04-amd64-server-20160406.manifest.xml (ami-311dfc5e)).

I also tested with CentOS 6 (RightImage_CentOS_6.5_x64_v14.1.3.1_EBS (ami-e82016f5)).

For CentOS 7 (RightImage_CentOS_7.0_x64_v14.2.1_HVM_EBS (ami-70d3ee6d)), each RiakNode reported healthy but the RiakCluster failed during the joinCluster command - I've reported this at https://issues.apache.org/jira/browse/BROOKLYN-252. I don't think we should let that block the release, but should definitely investigate and fix (for a 0.9.1 and/or 0.10.0).

---
The line you pointed at looks wrong, but it seems to actually work! This is because of the implementation of BashCommands.ifExecutableElse (which is only ever called by this one place).

It builds up the command:

   if test -z `which <cmd>`; then <ifTrue>; else <otherwise>; fi

That also seems the wrong way round, which therefore negates the error in RiakNodeSshDriver:L195.

Aled





Reply via email to