Skip to content

Commit

Permalink
add ADDITIONAL_OPTION to rollback as well
Browse files Browse the repository at this point in the history
  • Loading branch information
shizunge committed Jun 27, 2023
1 parent 90814ce commit da0c4b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib-gantry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,15 @@ rollback_service() {
local ROLLBACK_OPTIONS="${GANTRY_ROLLBACK_OPTIONS:-""}"
local SERVICE_NAME="${1}"
local DOCKER_CONFIG="${2}"
local ADDITIONAL_OPTION="${3}"
if ! is_true "${ROLLBACK_ON_FAILURE}"; then
return 0
fi
log INFO "Rolling ${SERVICE_NAME} back."
local ROLLBACK_MSG=
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
ROLLBACK_MSG=$(docker ${DOCKER_CONFIG} service update ${ROLLBACK_OPTIONS} --rollback "${SERVICE_NAME}" 2>&1)
ROLLBACK_MSG=$(docker ${DOCKER_CONFIG} service update ${ADDITIONAL_OPTION} ${ROLLBACK_OPTIONS} --rollback "${SERVICE_NAME}" 2>&1)
local RETURN_VALUE=$?
if [ ${RETURN_VALUE} -ne 0 ]; then
log ERROR "Failed to roll back ${SERVICE_NAME}. ${ROLLBACK_MSG}"
Expand Down Expand Up @@ -431,7 +432,7 @@ update_single_service() {
# shellcheck disable=SC2086
if ! UPDATE_MSG=$(timeout "${UPDATE_TIMEOUT_SECONDS}" docker ${DOCKER_CONFIG} service update ${ADDITIONAL_OPTION} ${UPDATE_OPTIONS} --image="${IMAGE}" "${SERVICE_NAME}" 2>&1); then
log ERROR "docker service update failed or timeout. ${UPDATE_MSG}"
rollback_service "${SERVICE_NAME}" "${DOCKER_CONFIG}"
rollback_service "${SERVICE_NAME}" "${DOCKER_CONFIG}" "${ADDITIONAL_OPTION}"
add_service_update_failed "${SERVICE_NAME}"
return 1
fi
Expand Down

0 comments on commit da0c4b0

Please sign in to comment.