Skip to content

Commit

Permalink
Add scripts execution check in jobs (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
VyacheslavSemin authored Jul 16, 2024
1 parent 991a661 commit f5e894e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions templates/configmaps/pre-delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ data:
if [ $? -ne 0 ]; then
echo -e "\e[0;31m DB is not available \e[0m"
exit 1
else
echo -e "\e[0;32m Successful connection to the DB \e[0m"
fi
{{- if not .Values.persistence.storageS3 }}
FILES_DIR=/var/lib/{{ .Values.product.name }}/documentserver/App_Data/cache/files/
Expand Down Expand Up @@ -67,6 +69,7 @@ data:
--port={{ .Values.connections.dbPort }} \
--user={{ .Values.connections.dbUser }} \
--dbname={{ .Values.connections.dbName }} \
--variable=ON_ERROR_STOP=ON \
--file=/scripts/{{ .Values.delete.existingConfigmap.tblRemove.keyName }}
{{- else if or (eq .Values.connections.dbType "mysql") (eq .Values.connections.dbType "mariadb") }}
mysql -h {{ .Values.connections.dbHost }} \
Expand All @@ -75,5 +78,8 @@ data:
-p$DB_PWD \
{{ .Values.connections.dbName }} < /scripts/{{ .Values.delete.existingConfigmap.tblRemove.keyName }}
{{- end }}
if [ $? -ne 0 ]; then
echo -e "\e[0;31m The DATABASE cleanup script could not be executed. Skipping... \e[0m"
fi
echo work done
{{- end }}
7 changes: 7 additions & 0 deletions templates/configmaps/pre-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data:
if [ $? -ne 0 ]; then
echo -e "\e[0;31m DB is not available \e[0m"
exit 1
else
echo -e "\e[0;32m Successful connection to the database \e[0m"
fi
if [[ "$PRIVATE_CLUSTER" != "true" ]]; then
wget -O /scripts/{{ .Values.install.existingConfigmap.tblCreate.keyName }} \
Expand All @@ -47,6 +49,7 @@ data:
--port={{ .Values.connections.dbPort }} \
--user={{ .Values.connections.dbUser }} \
--dbname={{ .Values.connections.dbName }} \
--variable=ON_ERROR_STOP=ON \
--file=/scripts/{{ .Values.install.existingConfigmap.tblCreate.keyName }}
{{- else if or (eq .Values.connections.dbType "mysql") (eq .Values.connections.dbType "mariadb") }}
mysql -h {{ .Values.connections.dbHost }} \
Expand All @@ -55,5 +58,9 @@ data:
-p$DB_PWD \
{{ .Values.connections.dbName }} < /scripts/{{ .Values.install.existingConfigmap.tblCreate.keyName }}
{{- end }}
if [ $? -ne 0 ]; then
echo -e "\e[0;31m The DATABASE initialization script could not be executed \e[0m"
exit 1
fi
echo work done
{{- end }}
8 changes: 8 additions & 0 deletions templates/configmaps/pre-rollback.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data:
if [ $? -ne 0 ]; then
echo -e "\e[0;31m DB is not available \e[0m"
exit 1
else
echo -e "\e[0;32m Successful connection to the DB \e[0m"
fi
{{- if not .Values.persistence.storageS3 }}
FILES_DIR=/var/lib/{{ .Values.product.name }}/documentserver/App_Data/cache/files/
Expand Down Expand Up @@ -72,11 +74,13 @@ data:
--port={{ .Values.connections.dbPort }} \
--user={{ .Values.connections.dbUser }} \
--dbname={{ .Values.connections.dbName }} \
--variable=ON_ERROR_STOP=ON \
--file=/scripts/{{ .Values.rollback.existingConfigmap.tblRemove.keyName }}
PGPASSWORD=$DB_PWD psql --host={{ .Values.connections.dbHost }} \
--port={{ .Values.connections.dbPort }} \
--user={{ .Values.connections.dbUser }} \
--dbname={{ .Values.connections.dbName }} \
--variable=ON_ERROR_STOP=ON \
--file=/scripts/{{ .Values.rollback.existingConfigmap.tblCreate.keyName }}
{{- else if or (eq .Values.connections.dbType "mysql") (eq .Values.connections.dbType "mariadb") }}
mysql -h {{ .Values.connections.dbHost }} \
Expand All @@ -90,5 +94,9 @@ data:
-p$DB_PWD \
{{ .Values.connections.dbName }} < /scripts/{{ .Values.rollback.existingConfigmap.tblCreate.keyName }}
{{- end }}
if [ $? -ne 0 ]; then
echo -e "\e[0;31m The DATABASE preparation scripts could not be executed \e[0m"
exit 1
fi
echo work done
{{- end }}
8 changes: 8 additions & 0 deletions templates/configmaps/pre-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ data:
if [ $? -ne 0 ]; then
echo -e "\e[0;31m DB is not available \e[0m"
exit 1
else
echo -e "\e[0;32m Successful connection to the DB \e[0m"
fi
if [[ "$PRIVATE_CLUSTER" != "true" ]]; then
wget -O /scripts/{{ .Values.upgrade.existingConfigmap.tblRemove.keyName }} \
Expand All @@ -58,11 +60,13 @@ data:
--port={{ .Values.connections.dbPort }} \
--user={{ .Values.connections.dbUser }} \
--dbname={{ .Values.connections.dbName }} \
--variable=ON_ERROR_STOP=ON \
--file=/scripts/{{ .Values.upgrade.existingConfigmap.tblRemove.keyName }}
PGPASSWORD=$DB_PWD psql --host={{ .Values.connections.dbHost }} \
--port={{ .Values.connections.dbPort }} \
--user={{ .Values.connections.dbUser }} \
--dbname={{ .Values.connections.dbName }} \
--variable=ON_ERROR_STOP=ON \
--file=/scripts/{{ .Values.upgrade.existingConfigmap.tblCreate.keyName }}
{{- else if or (eq .Values.connections.dbType "mysql") (eq .Values.connections.dbType "mariadb") }}
mysql -h {{ .Values.connections.dbHost }} \
Expand All @@ -76,6 +80,10 @@ data:
-p$DB_PWD \
{{ .Values.connections.dbName }} < /scripts/{{ .Values.upgrade.existingConfigmap.tblCreate.keyName }}
{{- end }}
if [ $? -ne 0 ]; then
echo -e "\e[0;31m The DATABASE preparation scripts could not be executed \e[0m"
exit 1
fi
echo work done
fi
{{- end }}

0 comments on commit f5e894e

Please sign in to comment.