Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocrvs 8043 #1215

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
4 changes: 1 addition & 3 deletions infrastructure/clear-all-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,5 @@ docker run --rm --network=$NETWORK --entrypoint=/bin/sh minio/mc -c "\
mc rb myminio/ocrvs && \
mc mb myminio/ocrvs"

# Delete all data from metabase
#-----------------------------
docker exec $(docker ps | grep opencrvs_dashboards | awk '{print $1}' | head -n 1) /bin/sh -c "rm -rf /data/metabase/*"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of restarting metabase during deploy, let's do it in the "clear-all-data" phase as that would incline more with their respective objectives


19 changes: 2 additions & 17 deletions infrastructure/deployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,15 @@ docker_stack_deploy() {
docker stack deploy --prune -c '$(split_and_join " " " -c " "$(to_remote_paths $COMPOSE_FILES_USED)")' --with-registry-auth opencrvs'
}

get_opencrvs_version() {
PREVIOUS_VERSION=$(configured_ssh "docker service ls | grep opencrvs_base | cut -d ':' -f 2")
echo "Previous opencrvs version: $PREVIOUS_VERSION"
echo "Current opencrvs version: $VERSION"
}

reset_metabase() {
echo "Reseting metabase"
configured_ssh "docker exec \$(docker ps | grep opencrvs_dashboards | awk '{print \$1}' | head -n 1) /bin/sh -c \"rm /data/metabase/metabase.mv.db\" && \
docker service scale opencrvs_dashboards=0 && \
configured_ssh "docker service scale opencrvs_dashboards=0 && \
docker service scale opencrvs_dashboards=1"
}

validate_options

get_opencrvs_version

# Create new passwords for all MongoDB users created in
# infrastructure/mongodb/docker-entrypoint-initdb.d/create-mongo-users.sh
#
Expand Down Expand Up @@ -436,14 +428,7 @@ EMAIL_PAYLOAD='{
"to": "{{ALERT_EMAIL}}"
}'

VERSION=$(echo "$VERSION" | xargs)
PREVIOUS_VERSION=$(echo "$PREVIOUS_VERSION" | xargs)

if [[ "$VERSION" == "$PREVIOUS_VERSION" ]]; then
echo "No reset needed for Metabase."
else
reset_metabase
fi
reset_metabase

configured_ssh "docker run --rm --network=opencrvs_overlay_net appropriate/curl \
-X POST 'http://countryconfig:3040/email' \
Expand Down
1 change: 0 additions & 1 deletion infrastructure/docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,6 @@ services:

dashboards:
volumes:
- /data/metabase:/data/metabase
# Exceed Docker config file 500 kb file limit, thus a volume mount
- /opt/opencrvs/infrastructure/metabase/metabase.init.db.sql:/metabase.init.db.sql
networks:
Expand Down
9 changes: 3 additions & 6 deletions infrastructure/server-setup/tasks/data-partition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,11 @@
path: /data/metabase
register: metabase_data

- name: 'Create metabase data directory'
- name: 'Delete metabase data directory if exists'
file:
path: /data/metabase
state: directory
group: 1000
owner: 1000
mode: g+rwx
when: not metabase_data.stat.exists
state: absent
when: metabase_data.stat.exists

- name: Check metabase data backup directory
stat:
Expand Down
Loading