Skip to content

Commit d36a2b5

Browse files
authored
Merge pull request #274 from github/snh/cluster-restore-status
Set restore status on all cluster nodes
2 parents d70094d + c06a069 commit d36a2b5

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

bin/ghe-restore

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,6 @@ GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy")
7777
# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION.
7878
ghe_remote_version_required "$GHE_HOSTNAME"
7979

80-
# Keep other processes on the VM in the loop about the restore status.
81-
#
82-
# Other processes will look for these states:
83-
# "restoring" - restore is currently in progress
84-
# "failed" - restore has failed
85-
# "complete" - restore has completed successfully
86-
update_restore_status () {
87-
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
88-
echo "$1" |
89-
ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' 2>/dev/null"
90-
fi
91-
}
92-
9380
# Figure out if this instance has been configured or is entirely new.
9481
instance_configured=false
9582
if ghe-ssh "$GHE_HOSTNAME" -- \
@@ -167,6 +154,24 @@ fi
167154
echo "Starting restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT"
168155
ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNAPSHOT ..."
169156

157+
# Keep other processes on the VM or cluster in the loop about the restore status.
158+
#
159+
# Other processes will look for these states:
160+
# "restoring" - restore is currently in progress
161+
# "failed" - restore has failed
162+
# "complete" - restore has completed successfully
163+
update_restore_status () {
164+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
165+
if $cluster; then
166+
echo "ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" |
167+
ghe-ssh "$GHE_HOSTNAME" /bin/bash
168+
else
169+
echo "$1" |
170+
ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null"
171+
fi
172+
fi
173+
}
174+
170175
# Update remote restore state file and setup failure trap
171176
trap "update_restore_status failed" EXIT
172177
update_restore_status "restoring"

0 commit comments

Comments
 (0)