Skip to content

Commit

Permalink
Add phase to wait for Cassandra to be ready before scale down (#2625)
Browse files Browse the repository at this point in the history
* Add wait for ready logic in cassandra BP

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Set replication factor to 1

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Add wait for cassandra conn ready logic

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Update helm value replicaCount

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

* Add nodetool scrub step in waitforready

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>

---------

Signed-off-by: Prasad Ghangal <prasad.ganghal@veeam.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
PrasadG193 and mergify[bot] authored Jan 25, 2024
1 parent 0cebc07 commit 6293ba1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
28 changes: 28 additions & 0 deletions examples/cassandra/cassandra-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions pkg/app/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6293ba1

Please sign in to comment.