Skip to content

Commit

Permalink
[gantry] Do not add --with-registry-auth to rollback cmd.
Browse files Browse the repository at this point in the history
--with-registry-auth cannot be combined with --rollback.
shizunge committed Sep 28, 2024
1 parent 657a0e3 commit 9c048d0
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/lib-gantry.sh
Original file line number Diff line number Diff line change
@@ -821,10 +821,8 @@ _get_service_rollback_additional_options() {
local SERVICE_NAME="${1}"
local DOCKER_CONFIG="${2}"
local OPTIONS=
# Add `--with-registry-auth` if needed.
local WITH_REGISTRY_AUTH=
WITH_REGISTRY_AUTH="$(_get_with_registry_auth "${DOCKER_CONFIG}")"
[ -n "${WITH_REGISTRY_AUTH}" ] && OPTIONS="${OPTIONS} ${WITH_REGISTRY_AUTH}"
# Place holder function. Nothing to do here yet.
# --with-registry-auth cannot be combined with --rollback.
echo "${OPTIONS}"
}

10 changes: 6 additions & 4 deletions tests/gantry_rollback_spec.sh
Original file line number Diff line number Diff line change
@@ -76,7 +76,8 @@ Describe 'rollback'
# Assume service update won't be done within TIMEOUT second.
export GANTRY_UPDATE_TIMEOUT_SECONDS="${TIMEOUT}"
# Rollback would fail due to the incorrect option.
export GANTRY_ROLLBACK_OPTIONS="--incorrect-option"
# --with-registry-auth cannot be combined with --rollback.
export GANTRY_ROLLBACK_OPTIONS="--with-registry-auth"
run_gantry "${TEST_NAME}"
}
BeforeEach "common_setup_timeout ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME} ${TIMEOUT}"
@@ -94,7 +95,7 @@ Describe 'rollback'
The stderr should satisfy spec_expect_message "${NUM_SERVICES_UPDATING}"
The stderr should satisfy spec_expect_no_message "${UPDATED}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_no_message "${NO_UPDATES}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${ADDING_OPTIONS}.*--incorrect-option.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${ADDING_OPTIONS}.*--with-registry-auth.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${ROLLING_BACK}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${FAILED_TO_ROLLBACK}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_no_message "${ROLLED_BACK}.*${SERVICE_NAME}"
@@ -218,7 +219,8 @@ Describe 'rollback'
local LABEL_AND_VALUE="gantry.update.timeout_seconds=${TIMEOUT}"
docker service update --quiet --label-add "${LABEL_AND_VALUE}" "${SERVICE_NAME}"
# Rollback would fail due to the incorrect option.
LABEL_AND_VALUE="gantry.rollback.options=--incorrect-option"
# --with-registry-auth cannot be combined with --rollback.
LABEL_AND_VALUE="gantry.rollback.options=--with-registry-auth"
docker service update --quiet --label-add "${LABEL_AND_VALUE}" "${SERVICE_NAME}"
run_gantry "${TEST_NAME}"
}
@@ -237,7 +239,7 @@ Describe 'rollback'
The stderr should satisfy spec_expect_message "${NUM_SERVICES_UPDATING}"
The stderr should satisfy spec_expect_no_message "${UPDATED}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_no_message "${NO_UPDATES}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${ADDING_OPTIONS}.*--incorrect-option.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${ADDING_OPTIONS}.*--with-registry-auth.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${ROLLING_BACK}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_message "${FAILED_TO_ROLLBACK}.*${SERVICE_NAME}"
The stderr should satisfy spec_expect_no_message "${ROLLED_BACK}.*${SERVICE_NAME}"

0 comments on commit 9c048d0

Please sign in to comment.