Skip to content
This repository was archived by the owner on Feb 27, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@ def describe_queue_state():
except etcd.EtcdKeyNotFound:
# There's no clearwater keys yet
print " No queue exists for {}".format(queue_key)
return
return 2

values = json.loads(result.value)

if values["QUEUED"]:
print " Nodes currently queued:"
for node in values["QUEUED"]:
print " Node ID: {}, Node status: {}".format(node["ID"], node["STATUS"].lower())
return_code = 1
else:
print " No nodes are currently queued"
return_code = 0

if values["ERRORED"]:
print " Nodes in an errored state:"
for node in values["ERRORED"]:
print " Node ID: {}, Node status: {}".format(node["ID"], node["STATUS"].lower())
return_code = 2


if values["COMPLETED"]:
Expand All @@ -49,4 +52,6 @@ def describe_queue_state():
print " Node ID: {}".format(node["ID"])

print "\n"
return return_code

describe_queue_state()
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ then
exit 1
fi

# Return 2 if any error occurs. Else return 1 if any node is queueing, and 0 if
# restart completed.
if [[ $use_single_restart_queue == "Y" ]] ; then
/usr/share/clearwater/clearwater-queue-manager/env/bin/python /usr/share/clearwater/clearwater-queue-manager/scripts/check_queue_state.py "${management_local_ip:-$local_ip}" "$local_site_name" apply_config
else
rc=0
for apply_config_key in $( clearwater-etcdctl ls -p --recursive | grep apply_config_ | sort -n); do
prefix="/clearwater/$local_site_name/configuration/"
# Remove the prefix to get apply_config_<node_type> as etcd-key
apply_config_key=${apply_config_key#$prefix}

/usr/share/clearwater/clearwater-queue-manager/env/bin/python /usr/share/clearwater/clearwater-queue-manager/scripts/check_queue_state.py "${management_local_ip:-$local_ip}" "$local_site_name" "$apply_config_key"
rc=$(($?>rc?$?:rc))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Urgh. This is pretty hard to follow! I suggest you either:

  • Add a comment to explain what this line does
  • Change this to something that's a bit less compact but easier to understand. How about just:
queue_state=$?
if [[ $queue_state > $rc ]]
then
  rc=$queue_state
fi

I think this will be a lot clearer for future code readers to understand.

done
exit $rc
fi