Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up stale HA nodes on restore #396

Merged
merged 12 commits into from May 21, 2018
10 changes: 7 additions & 3 deletions bin/ghe-restore
Expand Up @@ -343,10 +343,14 @@ fi

# Clean up all stale replicas
if ! $CLUSTER; then
inactive_nodes=$(echo "ghe-spokes server show inactive --json | jq -r '.[] | select(.host | contains(\"git-server\")).host' | sed 's/^git-server-//g'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash)
if [ -n "$inactive_nodes" ]; then
restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid)
other_nodes=$(echo "ghe-spokes server show --json | jq -r '.[] | select(.host | contains(\"git-server\")).host' | sed 's/^git-server-//g'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash)
Copy link
Member

@snh snh May 14, 2018

Choose a reason for hiding this comment

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

To reduce lines of code by 3, could we just add a | grep -F -x -v \"$restored_uuid\" to the end of the large collection of piped commands here? Or would this reduce the readability too much?

if [ -n "$other_nodes" ]; then
echo "Cleaning up stale nodes ..."
for uuid in $inactive_nodes; do
for uuid in $other_nodes; do
if [ "$uuid" = "$restored_uuid" ]; then
continue
fi
ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3
done
fi
Expand Down