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

Postflight script times out if it can not connect #2547

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions deploy/db/scripts/run-postflight-job.k8s.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
#!/bin/bash
set -e
echo "=== Stratos Postlight Job ==="
echo "Running postflight job"
MYSQL_CMD="mysql -u $DB_ADMIN_USER -h $DB_HOST -P $DB_PORT -p$DB_ADMIN_PASSWORD -e"

# mysql commands will timeout after 5 seconds
MYSQL_CMD="mysql -u $DB_ADMIN_USER -h $DB_HOST -P $DB_PORT -p$DB_ADMIN_PASSWORD --connect_timeout 5 -e"

echo "Checking if DB Server is ready"
dbServerVersion=$(${MYSQL_CMD} "SELECT VERSION();" --skip-column-names)
if [ $? -eq 1 ]; then
echo "Failed to connect to database server - it is not ready yet .. bailing for now..."
exit 1
fi

echo "Database Server is ready"
echo $dbServerVersion

set -e

echo "Checking if DB exists..."
stratosDbExists=$(${MYSQL_CMD} "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_DATABASE_NAME';")
DBCONF_KEY=mariadb-k8s
Expand Down