From 31e9cf2a1c5aaf4a5cc8d3772e82ed15f519e643 Mon Sep 17 00:00:00 2001 From: "zhongjun.li" Date: Thu, 8 Aug 2024 11:46:44 +0800 Subject: [PATCH] Optimize clustersynchro manager create db Signed-off-by: zhongjun.li --- charts/clusterpedia/Chart.yaml | 2 +- .../templates/clustersynchro-manager-deployment.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/clusterpedia/Chart.yaml b/charts/clusterpedia/Chart.yaml index bc101a6..993e700 100644 --- a/charts/clusterpedia/Chart.yaml +++ b/charts/clusterpedia/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.2.0 +version: 2.2.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/clusterpedia/templates/clustersynchro-manager-deployment.yaml b/charts/clusterpedia/templates/clustersynchro-manager-deployment.yaml index 8a3c5a7..8adc1bc 100644 --- a/charts/clusterpedia/templates/clustersynchro-manager-deployment.yaml +++ b/charts/clusterpedia/templates/clustersynchro-manager-deployment.yaml @@ -41,7 +41,7 @@ spec: # Load YAML data into a Bash variable source /opt/scripts/parse-yaml.sh; create_variables /etc/clusterpedia/storage/internalstorage-config.yaml; - until psql -U ${user} -h ${host} -p ${port} postgres -c "SELECT 1 FROM pg_database WHERE datname = '{{ include "clusterpedia.storage.database" . }}'" | grep -q 1 || psql -U ${user} -h ${host} -p ${port} postgres -c "CREATE DATABASE {{ include "clusterpedia.storage.database" . }} owner ${user} " -c "GRANT ALL PRIVILEGES ON DATABASE {{ include "clusterpedia.storage.database" . }} to ${user} "; do + until psql -U ${user} -h ${host} -p ${port} postgres -c "SELECT 1 FROM pg_database WHERE datname = ${database}" | grep -q 1 || psql -U ${user} -h ${host} -p ${port} postgres -c "CREATE DATABASE ${database} owner ${user} " -c "GRANT ALL PRIVILEGES ON DATABASE ${database} to ${user}"; do echo waiting for database check && sleep 1; done; echo 'DataBase OK ✓' @@ -51,8 +51,8 @@ spec: source /opt/scripts/parse-yaml.sh; create_variables /etc/clusterpedia/storage/internalstorage-config.yaml; if [ -z $password ]; then password=${DB_PASSWORD}; fi; - until mysql -u${user} -p${password} --host=${host} --port=${port} -e 'CREATE DATABASE IF NOT EXISTS {{ include "clusterpedia.storage.database" . }}'; do - echo waiting for database check && sleep 1; + until mysql -u${user} -p${password} --host=${host} --port=${port} -e "CREATE DATABASE IF NOT EXISTS ${database}"; do + echo waiting for database check && sleep 1; done; echo 'DataBase OK ✓' {{- end }}