swift-ring-builder exit status confusing

Asked by Mark Gius

I am very confused by the exit status of swift-ring-builder. According to the tool:

> Exit codes: 0 = ring changed, 1 = ring did not change, 2 = error

But when I run a successful "add" operation:

> ubuntu@proxy:~$ swift-ring-builder account.builder add z2-172.17.1.1:6000/sdb 1000.0
> Device z2-172.17.1.1:6000/sdb_"" with 1000.0 weight got id 3
> ubuntu@proxy:~$ echo $?
> 1

This makes no sense to me. I've changed the ring, I just haven't rebalanced and distributed the ring. Why is the ring builder returning "ring not changed?"

Or more to the point, why is swift-ring-builder not conforming to the standard practice of 0 = success, not 0 = failure? This makes scripting swift-ring-builder far more painful than it should be.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Object Storage (swift) Edit question
Assignee:
No assignee Edit question
Solved by:
Mark Gius
Solved:
Last query:
Last reply:
Revision history for this message
gholt (gholt) said :
#1

It was an idea from a long time ago that never really got used and apparently isn't even true anymore (the 0 = changed, 1 = no change, 2 = error). Updating that to be standard 0 = success, !0 = error seems fine by me, just needs someone to dedicate some time to it.

Revision history for this message
Mark Gius (markgius) said :
#2

Alright, I went ahead and filed a bug for changing the exit codes. I might fix it myself if I find the time, otherwise it should be a pretty easy fix for someone looking to start contributing.

Revision history for this message
vasanthakumar pandurangan (vasanthkumar1789) said :
#3

I'm new to Swift project. I have gone through the code of Ring Builder (in "bin\swift-ring-builder")

'add method' in Ring builder is implemented just to add the devices. It will NOT assign partitions to the new device
until after running 'rebalance'. This is so you can make multiple device changes and rebalance them all just once.
Because of this you are getting '1' even after the successful add operation.

As you have mentioned is an easy fix to change exit codes having 3 values to 2 values
We just have to modify,
'0 = ring changed, 1 = ring did not change' exit codes to '0 = success' and leave '2 = error' code as it is.

My question is even after this code change, if you do an add operation the exit code will be success (ring did not change).
However the ring is not yet rebalanced since we haven't called rebalance after add.
Is it fine to exit as 'Success' in add, even if the rebalance is not yet happened?
Similar cases are possible in other methods also.