diff options
| author | Serguei Bezverkhi <sbezverk@cisco.com> | 2016-09-14 17:22:26 -0400 |
|---|---|---|
| committer | Serguei Bezverkhi <sbezverk@cisco.com> | 2016-09-14 17:22:26 -0400 |
| commit | cafdbb35d916fbc2ba59191f182ed946abd4cf2e (patch) | |
| tree | 6babb15c5acde50d2b12551ccff6c4e067cc0fca /docker | |
| parent | 37ec5ecb52733e743797a87a3fd08be9781630a2 (diff) | |
| download | kolla-cafdbb35d916fbc2ba59191f182ed946abd4cf2e.tar.gz kolla-cafdbb35d916fbc2ba59191f182ed946abd4cf2e.zip | |
Mariadb bootstrap - no need to check for cluster ready in Kube
The change c7c87909 has introduced an unconditional check
for wsrep cluster during bootstrap process whether is ready or not
and if it is not, bootstrap fails.
In kubernetes environment wsrep driver is set to none, cluster will
NEVER reach ready state hence causing kubernetes mariadb bootstrap job
failure.
Closes-Bug: #1623662
Change-Id: I0e6fc098861b7eeab544229d0b04a78fa498ddb9
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/mariadb/extend_start.sh | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/docker/mariadb/extend_start.sh b/docker/mariadb/extend_start.sh index f3346d08c..d0a42825e 100644 --- a/docker/mariadb/extend_start.sh +++ b/docker/mariadb/extend_start.sh @@ -16,34 +16,26 @@ function bootstrap_db { exit 1 fi done - CLUSTER_READY=$(mysql -u root --exec="SHOW STATUS LIKE 'wsrep_cluster_status'" | grep Primary) - TIMEOUT=${DB_MAX_TIMEOUT:-60} - while [[ -z "${CLUSTER_READY}" ]]; do - if [[ ${TIMEOUT} -gt 0 ]]; then - let TIMEOUT-=1 - sleep 1 - else - exit 1 - fi - done - +# NOTE(sbezverk): Currently kolla-kubernetes does not use Galera and disables wsrep driver. +# This check will run only for non kolla-kubernetes bootstrap deployments. + if [[ ! "${!KOLLA_KUBERNETES[@]}" ]]; then + CLUSTER_READY=$(mysql -u root --exec="SHOW STATUS LIKE 'wsrep_cluster_status'" | grep Primary) + TIMEOUT=${DB_MAX_TIMEOUT:-60} + while [[ -z "${CLUSTER_READY}" ]]; do + if [[ ${TIMEOUT} -gt 0 ]]; then + let TIMEOUT-=1 + sleep 1 + else + exit 1 + fi + done + fi sudo -E kolla_security_reset mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;" mysql -u root --password="${DB_ROOT_PASSWORD}" -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '${DB_ROOT_PASSWORD}' WITH GRANT OPTION;" mysqladmin -uroot -p"${DB_ROOT_PASSWORD}" shutdown } -function kolla_kubernetes { - KUBE_TOKEN=$(</var/run/secrets/kubernetes.io/serviceaccount/token) - bootstrap_url=$(curl -sSk -H "Authorization: Bearer $KUBE_TOKEN" https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCPORT/api/v1/namespaces/default/pods | grep /api/v1/namespaces/default/pods/mariadb-bootstrap | cut -d '"' -f 4) || true - MARIADB_BOOTSTRAPPED=$(curl -sSk -H "Authorization: Bearer $KUBE_TOKEN" https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCPORT$bootstrap_url | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["status"]["phase"]') || MARIADB_BOOTSTRAPPED='Succeeded' - - if [[ "$MARIADB_BOOTSTRAPPED" != "Succeeded" ]]; then - echo "Mariadb bootstrapping isn't complete" - exit 1 - fi -} - # Only update permissions if permissions need to be updated if [[ $(stat -c %U:%G /var/lib/mysql) != "mysql:mysql" ]]; then sudo chown mysql: /var/lib/mysql @@ -67,10 +59,3 @@ fi if [[ "${!BOOTSTRAP_ARGS[@]}" ]]; then ARGS="${BOOTSTRAP_ARGS}" fi - -#***** KOLLA-KUBERNETES ***** -# TODO: Add a kolla_kubernetes script at build time when templating is complete -if [[ "${!KOLLA_KUBERNETES[@]}" ]]; then - kolla_kubernetes -fi -#***** KOLLA-KUBERNETES ***** |
