Ask Your Question

swift-ring-builder exit status confusing

asked 2011-08-19 23:35:04 -0500

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- 1000.0 Device z2-"" 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.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2011-08-29 18:58:27 -0500

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.

edit flag offensive delete link more

answered 2011-08-25 20:21:55 -0500

gholt gravatar image

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.

edit flag offensive delete link more

answered 2011-09-20 16:27:11 -0500

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.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2011-08-19 23:35:04 -0500

Seen: 91 times

Last updated: Sep 20 '11