Merge pull request #927 from github/jcambass/2022-06-15/only_restart_actions_if_stopped
Only Start Actions if they have been Stopped
This commit is contained in:
Коммит
11143678e5
|
@ -104,7 +104,7 @@ cleanup () {
|
||||||
update_restore_status "$1"
|
update_restore_status "$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
|
if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
|
||||||
echo "Restarting Actions after restore ..."
|
echo "Restarting Actions after restore ..."
|
||||||
# In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the
|
# In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the
|
||||||
# force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists
|
# 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 :)
|
||||||
# Show usage with no <host>
|
# Show usage with no <host>
|
||||||
[ -z "$GHE_HOSTNAME" ] && print_usage
|
[ -z "$GHE_HOSTNAME" ] && print_usage
|
||||||
|
|
||||||
|
# Flag to indicate if this script has stopped Actions.
|
||||||
|
ACTIONS_STOPPED=false
|
||||||
|
|
||||||
# ghe-restore-snapshot-path validates it exists, determines what current is,
|
# ghe-restore-snapshot-path validates it exists, determines what current is,
|
||||||
# and if there's any problem, exit for us
|
# and if there's any problem, exit for us
|
||||||
GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")"
|
GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")"
|
||||||
|
@ -399,6 +402,9 @@ fi
|
||||||
|
|
||||||
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
|
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
|
||||||
echo "Stopping Actions before restoring databases ..."
|
echo "Stopping Actions before restoring databases ..."
|
||||||
|
# We mark Actions as stopped even if the `ghe-actions-stop`
|
||||||
|
# fails to ensure that we cleanly start actions when performing cleanup.
|
||||||
|
ACTIONS_STOPPED=true
|
||||||
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3
|
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3
|
||||||
|
|
||||||
echo "Restoring MSSQL databases ..."
|
echo "Restoring MSSQL databases ..."
|
||||||
|
|
|
@ -410,6 +410,25 @@ begin_test "ghe-restore stops and starts Actions"
|
||||||
echo "$output" | grep -q "ghe-actions-stop .* OK"
|
echo "$output" | grep -q "ghe-actions-stop .* OK"
|
||||||
echo "$output" | grep -q "ghe-actions-start .* OK"
|
echo "$output" | grep -q "ghe-actions-start .* OK"
|
||||||
)
|
)
|
||||||
|
end_test
|
||||||
|
|
||||||
|
begin_test "ghe-restore does not attempt to start Actions during cleanup if they never have been stopped"
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
rm -rf "$GHE_REMOTE_ROOT_DIR"
|
||||||
|
setup_remote_metadata
|
||||||
|
enable_actions
|
||||||
|
|
||||||
|
setup_maintenance_mode "configured"
|
||||||
|
# We are not in maintance mode which means that we don't stop Actions and abort early.
|
||||||
|
disable_maintenance_mode
|
||||||
|
|
||||||
|
! output=$(ghe-restore -v -f localhost 2>&1)
|
||||||
|
|
||||||
|
! echo "$output" | grep -q "ghe-actions-stop"
|
||||||
|
! echo "$output" | grep -q "ghe-actions-start"
|
||||||
|
)
|
||||||
|
end_test
|
||||||
|
|
||||||
begin_test "ghe-restore with Actions data"
|
begin_test "ghe-restore with Actions data"
|
||||||
(
|
(
|
||||||
|
|
|
@ -120,6 +120,12 @@ setup_maintenance_mode () {
|
||||||
mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories"
|
mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Moves the instance out of maintenance mode.
|
||||||
|
disable_maintenance_mode () {
|
||||||
|
# Remove file used to determine if instance is in maintenance mode.
|
||||||
|
rm "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html"
|
||||||
|
}
|
||||||
|
|
||||||
# Mark the beginning of a test. A subshell should immediately follow this
|
# Mark the beginning of a test. A subshell should immediately follow this
|
||||||
# statement.
|
# statement.
|
||||||
begin_test () {
|
begin_test () {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче