|
|
@ -79,31 +79,45 @@ mongo:image:version() { |
|
|
|
} |
|
|
|
|
|
|
|
mongo:container:version() { |
|
|
|
local container="$1" |
|
|
|
if ! out=$(docker exec -i "$container" mongo --version); then |
|
|
|
local container="$1" version |
|
|
|
if ! out=$(docker exec "$container" mongod --version); then |
|
|
|
err "Couldn't infer container's '$container' mongod's version." |
|
|
|
exit 1 |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
out=${out%%$'\n'*} |
|
|
|
out=${out%%$'\r'*} |
|
|
|
image_version=${out#db version v} |
|
|
|
echo "$image_version" |
|
|
|
version=${out#db version v} |
|
|
|
echo "$version" |
|
|
|
} |
|
|
|
|
|
|
|
mongo:container:mongo () { |
|
|
|
local container="$1" |
|
|
|
|
|
|
|
docker exec -i "$container" mongo 2>&1 |
|
|
|
} |
|
|
|
|
|
|
|
mongo:container:fix_compat() { |
|
|
|
local container="$1" image_version="$2" |
|
|
|
out=$(echo "db.adminCommand( { setFeatureCompatibilityVersion: \"${image_version%.*}\" } )" | |
|
|
|
mongo:container:mongo "$container" 2>&1) |
|
|
|
if [[ "$out" == *"\"ok\" : 1"* ]]; then |
|
|
|
local container="$1" image_version="$2" version |
|
|
|
|
|
|
|
if ! version=$(mongo:container:version "$container"); then |
|
|
|
err "Couldn't get container's mongod version" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
## No need of confirmation for version < 7.0.0 |
|
|
|
if version_gt 7.0.0 "$version"; then |
|
|
|
mongo_cmd="db.adminCommand( { setFeatureCompatibilityVersion: \"${image_version%.*}\" } )" |
|
|
|
else |
|
|
|
mongo_cmd="db.adminCommand( { setFeatureCompatibilityVersion: \"${image_version%.*}\", confirm: true } )" |
|
|
|
fi |
|
|
|
|
|
|
|
out=$(echo "$mongo_cmd" | mongo:container:mongo "$container" 2>&1) |
|
|
|
if [[ "$out" == *"\"ok\" : 1"* ]] || [[ "$out" == *"ok: 1"* ]]; then |
|
|
|
debug "Feature Compatibility set to ${WHITE}${image_version%.*}${NORMAL}" |
|
|
|
else |
|
|
|
err "Failed to set feature compatibility version to ${WHITE}${image_version%.*}${NORMAL}:" |
|
|
|
echo "$out" | prefix " | " >&2 |
|
|
|
printf "%s" "$out" | prefix " | " >&2 |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
} |
|
|
@ -202,13 +216,18 @@ if [ -n "$containers" ]; then |
|
|
|
#err "Running container(s) for $DARKYELLOW$SERVICE_NAME$NORMAL are still running:" |
|
|
|
for container in $containers; do |
|
|
|
debug "Stopping container $container" |
|
|
|
docker stop "$container" >/dev/null || { |
|
|
|
docker:container:stop "$container" >/dev/null || { |
|
|
|
err "Failed to stop container '$container'." |
|
|
|
exit 1 |
|
|
|
} |
|
|
|
docker rm "$container" > /dev/null || { |
|
|
|
err "Couldn't delete container '$container'." |
|
|
|
} |
|
|
|
docker rm "$container" > /dev/null |
|
|
|
|
|
|
|
## Check that the container is actually removed |
|
|
|
if [ -n "$(docker ps -q -f name="$container")" ]; then |
|
|
|
err "Failed to remove container '$container'." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
container_stopped+=("$container") |
|
|
|
done |
|
|
|
fi |
|
|
@ -339,6 +358,7 @@ if [ -z "$unexpected_stop" -a -z "$expected_stop" ]; then |
|
|
|
docker stop "$migration_container" |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$failed" ]; then |
|
|
|
echo "${WHITE}Failing migration logs:${NORMAL}" >&2 |
|
|
|
cat "$MIGRATION_TMPDIR/migration.log" | prefix " ${GRAY}|${NORMAL} " >&2 |
|
|
|