Skip to content

Commit afa77df

Browse files
authored
Merge pull request #900 from github/backport-3.4.1-restart-cron-on-restore-failure
On restore failure, restart cron on target host
2 parents e6ebcef + ee4a19a commit afa77df

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

bin/ghe-restore

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ while true; do
8686
esac
8787
done
8888

89+
start_cron () {
90+
echo "Starting cron ..."
91+
if $CLUSTER; then
92+
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then
93+
echo "* Warning: Failed to start cron on one or more nodes"
94+
fi
95+
else
96+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then
97+
echo "* Warning: Failed to start cron"
98+
fi
99+
fi
100+
}
101+
89102
cleanup () {
90103
if [ -n "$1" ]; then
91104
update_restore_status "$1"
@@ -103,6 +116,10 @@ cleanup () {
103116
fi
104117
fi
105118

119+
if ! $CRON_RUNNING; then
120+
start_cron
121+
fi
122+
106123
# Cleanup SSH multiplexing
107124
ghe-ssh --clean
108125
}
@@ -249,6 +266,7 @@ update_restore_status () {
249266
fi
250267
}
251268

269+
CRON_RUNNING=true
252270
# Update remote restore state file and setup failure trap
253271
trap "cleanup failed" EXIT
254272
update_restore_status "restoring"
@@ -314,7 +332,7 @@ else
314332
fi
315333
fi
316334
fi
317-
335+
CRON_RUNNING=false
318336

319337
# Restore settings and license if restoring to an unconfigured appliance or when
320338
# specified manually.
@@ -474,16 +492,8 @@ if ! $RESTORE_SETTINGS; then
474492
fi
475493

476494
# Start cron. Timerd will start automatically as part of the config run.
477-
echo "Starting cron ..."
478-
if $CLUSTER; then
479-
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then
480-
echo "* Warning: Failed to start cron on one or more nodes"
481-
fi
482-
else
483-
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then
484-
echo "* Warning: Failed to start cron"
485-
fi
486-
fi
495+
start_cron
496+
CRON_RUNNING=true
487497

488498
# Clean up all stale replicas on configured instances.
489499
if ! $CLUSTER && $instance_configured; then

0 commit comments

Comments
 (0)