Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

chore: upgrade mongo4.4 to mongo5.0.24 #1276

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ services:
command: mongod --nojournal --storageEngine wiredTiger
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.mongo"
hostname: mongo.devstack.edx
image: mongo:${MONGO_VERSION:-4.4.18}
image: mongo:${MONGO_VERSION:-5.0.24}
networks:
default:
aliases:
Expand Down
35 changes: 35 additions & 0 deletions upgrade_mongo_5_0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -eu -o pipefail

# This script will upgrade a devstack that was previosly running Mongo DB 4.4 to MongoDB 5.0.24

. scripts/colors.sh

# Upgrade to mongo 5.0.24
export MONGO_VERSION=5.0.24

echo
echo -e "${GREEN}Restarting Mongo on version ${MONGO_VERSION}${NC}"
make dev.up.mongo
mongo_container="$(make --silent --no-print-directory dev.print-container.mongo)"

echo -e "${GREEN}Waiting for MongoDB...${NC}"
until docker exec "$mongo_container" mongo --eval 'db.serverStatus()' &> /dev/null
do
printf "."
sleep 1
done

echo -e "${GREEN}MongoDB ready.${NC}"
MONGO_VERSION_LIVE=$(docker exec -it "$mongo_container" mongo --quiet --eval "printjson(db.version())")
MONGO_VERSION_COMPAT=$(docker exec -it "$mongo_container" mongo --quiet \
--eval "printjson(db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )['featureCompatibilityVersion'])")
echo -e "${GREEN}Mongo Server version: ${MONGO_VERSION_LIVE}${NC}"
echo -e "${GREEN}Mongo FeatureCompatibilityVersion version: ${MONGO_VERSION_COMPAT}${NC}"

if echo "${MONGO_VERSION_COMPAT}" | grep -q "5\.0" ; then
echo -e "${GREEN}Upgrading FeatureCompatibilityVersion to 5.0${NC}"
docker exec -it "$mongo_container" mongo --eval "db.adminCommand( { setFeatureCompatibilityVersion: \"5.0\" } )"
else
echo -e "${GREEN}FeatureCompatibilityVersion already set to 5.0${NC}"
fi