suleydaman
suleydaman

Reputation: 483

Why is this script doing nothing after the for loop?

I have this bash script. It uses cqlsh to wait for a cassandra schema to be set up. The arguments to the script are the cassandra db keyspaces. Essentially it is checking that there is at least 1 entry in the schema_updates table. This table records all database migrations. If there is any entry in this table, it means that the keyspace that table is now available.

The issue is that none of the commands after the for loop are being executed when I use this script as a docker-compose entrypoint. It works fine if I just call it up directly.

I don't think the problem has anything to do with cassandra or the cassandra query. I have tested each line individually, I have run the the whole script on my local, I have gone into the container started up by the docker-compose file to start the script manually and it works exactly as expected in all three cases.

 #!/usr/bin/env bash

 for keyspace in "$@";
 do
      KEYSPACEFOUND=1
      until [[ $KEYSPACEFOUND = 0 ]];
      do
          cqlsh -u cassuser -p casspwd cassandra -e "select filename from $keyspace.schema_updates limit 1" 2>/dev/null | grep "(1 rows)" >/dev/null 2>&1
          let KEYSPACEFOUND=$?

      done
 done
 echo "All keyspaces are available"
 exec ./bin/applicationStartScript

Upvotes: 0

Views: 79

Answers (1)

suleydaman
suleydaman

Reputation: 483

It turns out that one of the arguments I was passing to the script was not a valid keyspace. This meant that the until loop would never terminate and therefore neither would the for loop.

Upvotes: 1

Related Questions