Fix: AAF timing issues 35/79135/1
authorroot <kranthi.guttikonda@att.com>
Mon, 25 Feb 2019 22:23:37 +0000 (17:23 -0500)
committerroot <kranthi.guttikonda@att.com>
Mon, 25 Feb 2019 22:23:37 +0000 (17:23 -0500)
We wait until the cassandra DB comes up and listen on TCP 9042
before running any cqlsh commands. Also we increse cqlsh
--request-timeout to 60 seconds and in order to prevent
coordinator write timeouts we increase write_request_
timeout_in_ms to 20 seconds. So that Cassandra DB comes up in
all different setpups without any failures.

Change-Id: Idf2e1080a0ec39d6a594888f13625ef173aa5467
Issue-ID: AAF-773
Signed-off-by: kranthi.guttikonda@att.com
Signed-off-by: root <kranthi.guttikonda@att.com>
auth/auth-cass/cass_init/cmd.sh
auth/auth-cass/cass_init/push.sh

index ba55648..d43e07d 100644 (file)
@@ -92,13 +92,18 @@ function install_cql {
         echo "Docker Installed Basic Cassandra on aaf.cass.  Executing the following "
         echo "NOTE: This creator provided is only a Single Instance. For more complex Cassandra, create independently"
         echo ""
+        until /usr/bin/cqlsh -e 'describe keyspaces';
+        do
+          echo "Cassandra DB is not up Yet!! Trying in 10 seconds"
+          sleep 10
+        done
         echo " cd /opt/app/aaf/cass_init"
         cd /opt/app/aaf/cass_init
         echo " cqlsh -f keyspace.cql"
-        /usr/bin/cqlsh -f keyspace.cql
+        /usr/bin/cqlsh --request-timeout=60 -f keyspace.cql
        status keyspace installed
         echo " cqlsh -f init.cql"
-        /usr/bin/cqlsh -f init.cql
+        /usr/bin/cqlsh --request-timeout=60 -f init.cql
        status data initialized
         echo ""
         echo "The following will give you a temporary identity with which to start working, or emergency"
@@ -149,6 +154,9 @@ case "$1" in
 
     # Startup like normal
     echo "Cassandra Startup"
+    if ! cat /etc/cassandra/cassandra.yaml | grep "write_request_timeout_in_ms: 20000"; then
+      sed -i 's/write_request_timeout_in_ms: 2000/write_request_timeout_in_ms: 20000/' /etc/cassandra/cassandra.yaml
+    fi
     exec /usr/local/bin/docker-entrypoint.sh 
   ;;
 esac
index 9d59bd0..f3e5d80 100644 (file)
@@ -35,7 +35,11 @@ fi
 cd dats
 for T in $(ls *.dat); do
   if [ -s $T ]; then
-    cqlsh -e "COPY authz.${T/.dat/} FROM '$T' WITH DELIMITER='|';"
+    until cqlsh --request-timeout=60 -e "COPY authz.${T/.dat/} FROM '$T' WITH DELIMITER='|';";
+    do
+      echo "Unexpected failure...sleep for 10 seconds and try again"
+      sleep 10
+    done
   fi
 done
 cd $DIR