Skip to content

Commit

Permalink
Optimize clustersynchro manager create db
Browse files Browse the repository at this point in the history
  • Loading branch information
learner0810 committed Aug 8, 2024
1 parent 90b2fff commit 267a43a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ✓'
Expand All @@ -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 }}
Expand Down

0 comments on commit 267a43a

Please sign in to comment.