From dce9b1813841ff5e6463b628481d5b56c087bdd5 Mon Sep 17 00:00:00 2001 From: "aravind.est" Date: Fri, 25 Oct 2024 10:42:27 +0100 Subject: [PATCH] SMO-TEIV: Check secret existence before copy Secrets existence check added before copying it to smo namespace Issue-ID: SMO-154 Change-Id: I3849c574c699040d3ad411e208d0b1ea6172f16a Signed-off-by: aravind.est --- smo-install/scripts/sub-scripts/install-smo.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smo-install/scripts/sub-scripts/install-smo.sh b/smo-install/scripts/sub-scripts/install-smo.sh index 04a4665b..4f4187ff 100755 --- a/smo-install/scripts/sub-scripts/install-smo.sh +++ b/smo-install/scripts/sub-scripts/install-smo.sh @@ -23,6 +23,17 @@ OVERRIDEYAML=$1 helm install --debug oran-smo local/smo --namespace smo -f $OVERRIDEYAML +check_for_secrets() { + try=0 + retries=60 + until (kubectl get secret -n onap | grep -P "\b$1\b") >/dev/null 2>&1; do + try=$(($try + 1)) + [ $try -gt $retries ] && exit 1 + echo "$1 not found. Retry $try/$retries" + sleep 10 + done + echo "$1 found" +} # Copying kafka secrets from onap namespace # SMO installation uses ONAP strimzi kafka # All KafkaUser and KafkaTopic resources should be created as part of ONAP namespace @@ -30,5 +41,6 @@ helm install --debug oran-smo local/smo --namespace smo -f $OVERRIDEYAML # Once the secrets are created, it should be copied to the SMO namespace while IFS= read -r secret; do echo "Copying $secret from onap namespace..." + check_for_secrets $secret kubectl get secret $secret -n onap -o json | jq 'del(.metadata["namespace","creationTimestamp","resourceVersion","selfLink","uid","ownerReferences"])' | kubectl apply -n smo -f - done < <(yq r -d0 $OVERRIDEYAML smo.secrets[*]) \ No newline at end of file -- 2.16.6