File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ cleanup () {
104
104
update_restore_status " $1 "
105
105
fi
106
106
107
- if ghe-ssh " $GHE_HOSTNAME " -- ' ghe-config --true app.actions.enabled' ; then
107
+ if $ACTIONS_STOPPED && ghe-ssh " $GHE_HOSTNAME " -- ' ghe-config --true app.actions.enabled' ; then
108
108
echo " Restarting Actions after restore ..."
109
109
# In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the
110
110
# force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists
@@ -161,6 +161,9 @@ hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :)
161
161
# Show usage with no <host>
162
162
[ -z " $GHE_HOSTNAME " ] && print_usage
163
163
164
+ # Flag to indicate if this script has stopped Actions.
165
+ ACTIONS_STOPPED=false
166
+
164
167
# ghe-restore-snapshot-path validates it exists, determines what current is,
165
168
# and if there's any problem, exit for us
166
169
GHE_RESTORE_SNAPSHOT_PATH=" $( ghe-restore-snapshot-path " $snapshot_id " ) "
399
402
400
403
if ghe-ssh " $GHE_HOSTNAME " -- ' ghe-config --true app.actions.enabled' ; then
401
404
echo " Stopping Actions before restoring databases ..."
405
+ # We mark Actions as stopped even if the `ghe-actions-stop`
406
+ # fails to ensure that we cleanly start actions when performing cleanup.
407
+ ACTIONS_STOPPED=true
402
408
ghe-ssh " $GHE_HOSTNAME " -- ' ghe-actions-stop' 1>&3
403
409
404
410
echo " Restoring MSSQL databases ..."
Original file line number Diff line number Diff line change @@ -410,6 +410,25 @@ begin_test "ghe-restore stops and starts Actions"
410
410
echo " $output " | grep -q " ghe-actions-stop .* OK"
411
411
echo " $output " | grep -q " ghe-actions-start .* OK"
412
412
)
413
+ end_test
414
+
415
+ begin_test " ghe-restore does not attempt to start Actions during cleanup if they never have been stopped"
416
+ (
417
+ set -e
418
+ rm -rf " $GHE_REMOTE_ROOT_DIR "
419
+ setup_remote_metadata
420
+ enable_actions
421
+
422
+ setup_maintenance_mode " configured"
423
+ # We are not in maintance mode which means that we don't stop Actions and abort early.
424
+ disable_maintenance_mode
425
+
426
+ ! output=$( ghe-restore -v -f localhost 2>&1 )
427
+
428
+ ! echo " $output " | grep -q " ghe-actions-stop"
429
+ ! echo " $output " | grep -q " ghe-actions-start"
430
+ )
431
+ end_test
413
432
414
433
begin_test " ghe-restore with Actions data"
415
434
(
Original file line number Diff line number Diff line change @@ -120,6 +120,12 @@ setup_maintenance_mode () {
120
120
mkdir -p " $GHE_REMOTE_DATA_USER_DIR /repositories"
121
121
}
122
122
123
+ # Moves the instance out of maintenance mode.
124
+ disable_maintenance_mode () {
125
+ # Remove file used to determine if instance is in maintenance mode.
126
+ rm " $GHE_REMOTE_DATA_DIR /github/current/public/system/maintenance.html"
127
+ }
128
+
123
129
# Mark the beginning of a test. A subshell should immediately follow this
124
130
# statement.
125
131
begin_test () {
You can’t perform that action at this time.
0 commit comments