From 85e6b5fc48d7f42d1a1ed3d0c69b327bc5d84670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 25 Oct 2023 13:56:14 +0200 Subject: [PATCH] Change 'cluster.neo4j.sh' commands to 'maintenance on' and 'maintenance off' --- deployment/scripts/cluster.backup.sh | 10 +++--- deployment/scripts/cluster.neo4j.sh | 48 ++++++++++++++++------------ 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/deployment/scripts/cluster.backup.sh b/deployment/scripts/cluster.backup.sh index 2ca7bd206..9503061cf 100755 --- a/deployment/scripts/cluster.backup.sh +++ b/deployment/scripts/cluster.backup.sh @@ -18,9 +18,8 @@ BACKUP_FOLDER=${BACKUP_FOLDER:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/ # create backup fodler mkdir -p ${BACKUP_FOLDER} -# maintenance mode on -# set Neo4j in offline mode (maintenance) -${SCRIPT_DIR}/cluster.neo4j.sh off +# cluster maintenance mode on && Neo4j maintenance mode on +${SCRIPT_DIR}/cluster.neo4j.sh maintenance on # database backup kubectl --kubeconfig=${KUBECONFIG} -n default exec -it \ @@ -33,6 +32,5 @@ kubectl --kubeconfig=${KUBECONFIG} cp \ kubectl --kubeconfig=${KUBECONFIG} cp \ default/$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend |awk '{ print $1 }'):/app/public/uploads $BACKUP_FOLDER/public-uploads -# set Neo4j in online mode -# maintenance mode off -${SCRIPT_DIR}/cluster.neo4j.sh on \ No newline at end of file +# Neo4j maintenance mode off && cluster maintenance mode off +${SCRIPT_DIR}/cluster.neo4j.sh maintenance off \ No newline at end of file diff --git a/deployment/scripts/cluster.neo4j.sh b/deployment/scripts/cluster.neo4j.sh index f886b0916..41ebe4227 100755 --- a/deployment/scripts/cluster.neo4j.sh +++ b/deployment/scripts/cluster.neo4j.sh @@ -14,32 +14,40 @@ fi KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml} case $1 in - off) - # maintenance mode on - ${SCRIPT_DIR}/cluster.maintenance.sh on + maintenance) + case $2 in + on) + # maintenance mode on + ${SCRIPT_DIR}/cluster.maintenance.sh on - # set Neo4j in offline mode (maintenance) - kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ - | jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \ - | kubectl --kubeconfig=${KUBECONFIG} apply -f - + # set Neo4j in offline mode (maintenance) + kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ + | jq '.spec.template.spec.containers[] += {"command": ["tail", "-f", "/dev/null"]}' \ + | kubectl --kubeconfig=${KUBECONFIG} apply -f - - # wait for the container to restart - sleep 60 - ;; - on) - # set Neo4j in online mode - kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ - | jq 'del(.spec.template.spec.containers[].command)' \ - | kubectl --kubeconfig=${KUBECONFIG} apply -f - + # wait for the container to restart + sleep 60 + ;; + off) + # set Neo4j in online mode + kubectl --kubeconfig=${KUBECONFIG} get deployment ocelot-neo4j -o json \ + | jq 'del(.spec.template.spec.containers[].command)' \ + | kubectl --kubeconfig=${KUBECONFIG} apply -f - - # wait for the container to restart - sleep 60 + # wait for the container to restart + sleep 60 - # maintenance mode off - ${SCRIPT_DIR}/cluster.maintenance.sh off + # maintenance mode off + ${SCRIPT_DIR}/cluster.maintenance.sh off + ;; + *) + echo -e "Run this script with first argument either 'off' or 'on'" + exit + ;; + esac ;; *) - echo -e "Run this script with first argument either 'off' or 'on'" + echo -e "Run this script with first argument 'maintenance'" exit ;; esac