Skip to content

Commit

Permalink
CASMTRIAGE-7318 : handle the case where sma 1.9 or sma 1.10 is instal…
Browse files Browse the repository at this point in the history
…led (#5399)
  • Loading branch information
kimjensen-hpe authored Sep 26, 2024
1 parent b5a0d4a commit 68d95b9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions upgrade/scripts/k8s/tds_lower_cpu_requests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,23 @@ fi

kafkaDeployed=$(kubectl get pods -n sma | grep kafka | wc -l)
if [[ $kafkaDeployed -ne 0 ]]; then

# For sma 1.9, the cluster-kafka and cluster-zookeeper resources are based on a statefulset.
# For sma 1.10, the cluster-kafka and cluster-zookeeper resources are based on the strimzipodset.
if kubectl get statefulset cluster-kafka -n sma > /dev/null 2>&1; then
resource='statefulset'
status='.status.updatedReplicas'
else
resource='strimzipodset'
status='.status.readyPods'
fi

if [ ! -z $cluster_kafka_new_cpu_request ]; then
current_req=$(kubectl get kafkas -n sma cluster -o json | jq -r '.spec.kafka.resources.requests.cpu')
echo "Patching cluster-kafka with new cpu request of $cluster_kafka_new_cpu_request (from $current_req)"
kubectl patch kafkas cluster -n sma --type=json -p="[{'op' : 'replace', 'path':'/spec/kafka/resources/requests/cpu', 'value' : \"$cluster_kafka_new_cpu_request\" }]"
sleep 10
until [[ $(kubectl -n sma get strimzipodset cluster-kafka -o json | jq -r '.status.readyPods') -eq 3 ]]; do
until [[ $(kubectl -n sma get "${resource}" cluster-kafka -o json | jq --arg status $status -r "$status") -eq 3 ]]; do
echo "Waiting for cluster-kafka cluster to have three updated replicas..."
sleep 30
done
Expand All @@ -211,7 +222,7 @@ if [[ $kafkaDeployed -ne 0 ]]; then
echo "Patching cluster-zookeeper statefulset with new cpu request of $cluster_zookeeper_new_cpu_request (from $current_req)"
kubectl patch kafkas cluster -n sma --type=json -p="[{'op' : 'replace', 'path':'/spec/zookeeper/resources/requests/cpu', 'value' : \"$cluster_zookeeper_new_cpu_request\" }]"
sleep 10
until [[ $(kubectl -n sma get strimzipodsetstatefulset cluster-zookeeper -o json | jq -r '.status.readyPods') -eq 3 ]]; do
until [[ $(kubectl -n sma get "${resource}" cluster-zookeeper -o json | jq --arg status $status -r "$status") -eq 3 ]]; do
echo "Waiting for cluster-zookeeper cluster to have three updated replicas..."
sleep 30
done
Expand Down

0 comments on commit 68d95b9

Please sign in to comment.