Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add phase to wait for Cassandra to be ready before scale down #2625

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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