waltz icon indicating copy to clipboard operation
waltz copied to clipboard

Waltz commands should be idempotent

Open whynick1 opened this issue 6 years ago • 1 comments

Verifying cluster does not already exist...
Cluster already exists. Aborting.
[20:43:44 17560 williamp@poc-waltz01]$ java com.wepay.waltz.tools.zk.ZooKeeperCli add-storage-node --zookeeper 127.0.0.1:2181 --root /wrptest --storage 127.0.0.1:13000 --group  0
[success] Storage node added!

[20:47:57 17560 williamp@poc-waltz01]$ java com.wepay.waltz.tools.zk.ZooKeeperCli add-storage-node --zookeeper 127.0.0.1:2181 --root /wrptest --storage 127.0.0.1:13000 --group  0
[failed] Storage node already exists.

[20:48:11 17560 williamp@poc-waltz01]$ echo $?
0

If a cluster already exists, an attempt to create it should succeed. Similarly, an attempt to add a storage node that already exists should succeed. (In both cases, this is assuming that the currently existing cluster and the existing storage node are in the same state they would be in if they were now being initially created. I believe both of these commands are just manipulating znodes, so I think this is the case).

In the example above, we see the message '[failed] Storage node already exists', but a return value of 0 is given. This is inconsistent. If something returns 0, then by definition it has been successful. So the message indicating failure is just confusing.

whynick1 avatar Jul 08 '19 18:07 whynick1

I think we probably want to return a non-zero exit code rather than making it act like it succeeded even though it did nothing.

from @criccomini

whynick1 avatar Jul 08 '19 18:07 whynick1