check for sst_in_progress

PROD-16528

Change-Id: Iacc949fb68e323632e0ed7a60e11c44a9812e724
diff --git a/galera/files/bootstrap.sh b/galera/files/bootstrap.sh
index eb8838d..5e464a6 100644
--- a/galera/files/bootstrap.sh
+++ b/galera/files/bootstrap.sh
@@ -4,6 +4,7 @@
 
 counter=${1:-60}
 retries=0
+sst_in_progress='/var/lib/mysql/sst_in_progress'
 
 while [ $counter -gt 0 ]
 do
@@ -13,6 +14,14 @@
   fi
   counter=$(( counter - 1 ))
   retries=$(( retries + 1 ))
+  {%- if slave %}
+  if [ $retries -gt 20 ]; then
+    if [ ! -e $sst_in_progress ]; then
+        echo "No sst is in progress."
+        break
+    fi
+  fi
+  {%- endif %}
   sleep ${2:-10}
 done
 
diff --git a/galera/master.sls b/galera/master.sls
index a4fa680..b1c45ab 100644
--- a/galera/master.sls
+++ b/galera/master.sls
@@ -130,6 +130,7 @@
   - source: salt://galera/files/bootstrap.sh
   - defaults:
       service: {{ master|yaml }}
+      slave: False
   - template: jinja
 
 {%- if salt['cmd.shell']('test -e /var/lib/mysql/.galera_bootstrap; echo $?') != '0'  %}
diff --git a/galera/slave.sls b/galera/slave.sls
index 2a70672..5637c49 100644
--- a/galera/slave.sls
+++ b/galera/slave.sls
@@ -127,6 +127,7 @@
   - mode: 755
   - defaults:
       service: {{ slave|yaml }}
+      slave: True
   - source: salt://galera/files/bootstrap.sh
   - template: jinja