From 68d95b9d753595a0f0539bb9e21858044595649d Mon Sep 17 00:00:00 2001 From: kimjensen-hpe <77168453+kimjensen-hpe@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:45:46 -0600 Subject: [PATCH] CASMTRIAGE-7318 : handle the case where sma 1.9 or sma 1.10 is installed (#5399) --- upgrade/scripts/k8s/tds_lower_cpu_requests.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/upgrade/scripts/k8s/tds_lower_cpu_requests.sh b/upgrade/scripts/k8s/tds_lower_cpu_requests.sh index a9c989dd67ab..27e897ec89b2 100755 --- a/upgrade/scripts/k8s/tds_lower_cpu_requests.sh +++ b/upgrade/scripts/k8s/tds_lower_cpu_requests.sh @@ -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 @@ -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