Skip to content

Commit

Permalink
Merge pull request #409 from github/lildude/cleanup-configured-only
Browse files Browse the repository at this point in the history
Only perform stale node cleanup when restoring to configured instances
  • Loading branch information
lildude authored May 30, 2018
2 parents 20b437e + 346065e commit 315bec8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bin/ghe-restore
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ else
fi
fi

# Clean up all stale replicas
if ! $CLUSTER; then
# Clean up all stale replicas on configured instances.
if ! $CLUSTER && $instance_configured; then
restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid)
other_nodes=$(echo "
set -o pipefail; \
Expand Down
15 changes: 15 additions & 0 deletions test/test-ghe-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ begin_test "ghe-restore into configured vm"
# verify connect to right host
grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out"

# verify stale servers were cleared
grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out"

# Verify all the data we've restored is as expected
verify_all_restored_data
)
Expand Down Expand Up @@ -140,6 +143,12 @@ begin_test "ghe-restore -c into unconfigured vm"
# verify connect to right host
grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out"

# verify attempt to clear stale servers was not made
grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && {
echo "ghe-cluster-cleanup-node should not run on unconfigured nodes."
exit 1
}

# Verify all the data we've restored is as expected
verify_all_restored_data
)
Expand Down Expand Up @@ -168,6 +177,12 @@ begin_test "ghe-restore into unconfigured vm"
# verify connect to right host
grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out"

# verify attempt to clear stale servers was not made
grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && {
echo "ghe-cluster-cleanup-node should not run on unconfigured nodes."
exit 1
}

# Verify all the data we've restored is as expected
verify_all_restored_data
)
Expand Down
2 changes: 0 additions & 2 deletions test/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,6 @@ verify_all_restored_data() {
grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out"
# verify all ES data was transferred from live directory to the temporary restore directory
diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore"
# verify stale servers were cleared
grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out"
else
grep -q "fake audit log last yr last mth" "$TRASHDIR/restore-out"
grep -q "fake audit log this yr this mth" "$TRASHDIR/restore-out"
Expand Down

0 comments on commit 315bec8

Please sign in to comment.