diff --git a/examples/cassandra/cassandra-blueprint.yaml b/examples/cassandra/cassandra-blueprint.yaml index 0afb576a35..b924ae7162 100644 --- a/examples/cassandra/cassandra-blueprint.yaml +++ b/examples/cassandra/cassandra-blueprint.yaml @@ -91,6 +91,34 @@ actions: inputArtifactNames: - params phases: + - func: KubeExec + name: waitForConnectionReady + args: + namespace: "{{ .StatefulSet.Namespace }}" + pod: "{{ index .StatefulSet.Pods 0 }}" + command: + - bash + - -o + - pipefail + - -c + - | + timeout=300 + while true + do + VAR=$((cqlsh -u cassandra -p $CASSANDRA_PASSWORD -e "DESCRIBE keyspaces;" --request-timeout=300) 2>&1) + if [[ $VAR != *"Unable to connect to any servers"* ]] + then + break + fi + if [[ $timeout -le 0 ]] + then + echo "Timed out waiting for cqlsh to configure.." + exit 1 + fi + sleep 2 + timeout=$((timeout-2)) + done + nodetool scrub - func: ScaleWorkload name: shutdownPod args: diff --git a/pkg/app/cassandra.go b/pkg/app/cassandra.go index 5c41e20994..1d0ec78337 100644 --- a/pkg/app/cassandra.go +++ b/pkg/app/cassandra.go @@ -57,11 +57,11 @@ func NewCassandraInstance(name string) App { Chart: "cassandra", RepoName: helm.BitnamiRepoName, Values: map[string]string{ - "image.registry": "ghcr.io", - "image.repository": "kanisterio/cassandra", - "image.tag": "v9.99.9-dev", - "image.pullPolicy": "Always", - "cluster.replicaCount": "1", + "image.registry": "ghcr.io", + "image.repository": "kanisterio/cassandra", + "image.tag": "v9.99.9-dev", + "image.pullPolicy": "Always", + "replicaCount": "1", }, }, } @@ -206,7 +206,7 @@ func (cas *CassandraInstance) Reset(ctx context.Context) error { func (cas *CassandraInstance) Initialize(ctx context.Context) error { // create the keyspace createKS := []string{"sh", "-c", fmt.Sprintf("cqlsh -u cassandra -p $CASSANDRA_PASSWORD -e \"create keyspace "+ - "restaurants with replication = {'class':'SimpleStrategy', 'replication_factor': 3};\" --request-timeout=%s", cqlTimeout)} + "restaurants with replication = {'class':'SimpleStrategy', 'replication_factor': 1};\" --request-timeout=%s", cqlTimeout)} _, stderr, err := cas.execCommand(ctx, createKS) if err != nil { return errors.Wrapf(err, "Error %s while creating the keyspace for application.", stderr)