Move NONRTRIC charts to separate build process 89/13289/7
authoraravind.est <aravindhan.a@est.tech>
Fri, 30 Aug 2024 14:40:56 +0000 (15:40 +0100)
committeraravind.est <aravindhan.a@est.tech>
Mon, 2 Sep 2024 16:13:27 +0000 (17:13 +0100)
NONRTRIC helm build process uses helm v3
ric charts verify excluded the NONRTRIC charts

Issue-ID: CCSDk-4033
Change-Id: Iec4f4da1f26d8a8108b7be7e5a8d4c9916a457d1
Signed-off-by: aravind.est <aravindhan.a@est.tech>
bin/build-nonrtric-base [new file with mode: 0755]
bin/deploy-nonrtric
bin/verify-nonrtric-charts [new file with mode: 0755]
bin/verify-ric-charts
ci/Dockerfile-nonrtric-install [new file with mode: 0644]

diff --git a/bin/build-nonrtric-base b/bin/build-nonrtric-base
new file mode 100755 (executable)
index 0000000..00dd64e
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/bash
+################################################################################
+#   Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.       #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
+
+#Check for helm3
+IS_HELM3=$(helm version -c --short|grep -e "^v3")
+
+CM_VERSION="v0.16.2"
+CM_PORT="8879"
+CM_BASE_URL="http://127.0.0.1:$CM_PORT"
+CM_CHART_GET_URL="$CM_BASE_URL/charts"
+CM_CHART_POST_URL="$CM_BASE_URL/charts/api/charts"
+
+if ! command -v chartmuseum &> /dev/null
+then
+  pushd /tmp
+  echo "Installing ChartMuseum binary..."
+  wget https://get.helm.sh/chartmuseum-$CM_VERSION-linux-amd64.tar.gz
+  tar xvfz chartmuseum-$CM_VERSION-linux-amd64.tar.gz
+  sudo mv /tmp/linux-amd64/chartmuseum /usr/local/bin/chartmuseum
+  popd
+else
+  echo "ChartMuseum is already installed."
+fi
+
+# Package common templates and serve it using Helm local repo
+HELM_LOCAL_REPO="./chartstorage"
+rm $HELM_LOCAL_REPO/*
+
+#Start Chart Museum server if there isn't one
+CHART_MUSEUM_PID=$(lsof -i :"$CM_PORT" | grep "chartmus" | grep -v "grep" | awk '{print $2}')
+if [ -z "$CHART_MUSEUM_PID" ]; then
+  echo "Starting ChartMuseum on port $CM_PORT..."
+  nohup chartmuseum --port=$CM_PORT --storage="local" --context-path=/charts --storage-local-rootdir=$HELM_LOCAL_REPO >/dev/null 2>&1 &
+  echo $! > $ROOT_DIR/CM_PID.txt
+else
+  echo "ChartMuseum is already running..."
+fi
+
+# Check if ChartMuseum  is ready to serve request
+command="curl --silent --output /dev/null  $CM_BASE_URL"
+for i in $(seq 1 5)
+do $command && s=0 && break || s=$? && echo "Failed to establish a connection with the ChartMuseum server. Retrying after 5s" && sleep 5;
+done
+
+if [ $s -gt 0 ]
+then
+        echo "Cmd to test ChartMuseum failed with ($s): $command"
+        exit $s
+fi
+
+helm repo remove local
+helm repo add local $CM_CHART_GET_URL
+
+echo -e "\nPackaging NONRTRIC common [nonrtric-common]"
+NONRTRIC_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
+helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
+curl --data-binary @/tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $CM_CHART_POST_URL
index 6228d88..ccc9dde 100755 (executable)
@@ -89,61 +89,7 @@ ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
 echo "** $ROOT_DIR"
 rm $ROOT_DIR/../nonrtric/helm/*/charts/*.tgz
 
-#ChartMuseum configuration
-CM_VERSION="v0.16.1"
-CM_PORT="8879"
-CM_BASE_URL="http://127.0.0.1:$CM_PORT"
-CM_CHART_GET_URL="$CM_BASE_URL/charts"
-CM_CHART_POST_URL="$CM_BASE_URL/charts/api/charts"
-
-#Check for helm3
-IS_HELM3=$(helm version -c --short|grep -e "^v3")
-
-if ! command -v chartmuseum &> /dev/null
-then
-  pushd /tmp
-  echo "Installing ChartMuseum binary..."
-  wget https://get.helm.sh/chartmuseum-$CM_VERSION-linux-amd64.tar.gz
-  tar xvfz chartmuseum-$CM_VERSION-linux-amd64.tar.gz
-  sudo mv /tmp/linux-amd64/chartmuseum /usr/local/bin/chartmuseum
-  popd
-else
-  echo "ChartMuseum is already installed."
-fi
-
-# Package common templates and serve it using Helm local repo
-HELM_LOCAL_REPO="./chartstorage"
-rm $HELM_LOCAL_REPO/*
-
-#Start Chart Museum server if there isn't one
-CHART_MUSEUM_PID=$(lsof -i :"$CM_PORT" | grep "chartmus" | grep -v "grep" | awk '{print $2}')
-if [ -z "$CHART_MUSEUM_PID" ]; then
-  echo "Starting ChartMuseum on port $CM_PORT..."
-  nohup chartmuseum --port=$CM_PORT --storage="local" --context-path=/charts --storage-local-rootdir=$HELM_LOCAL_REPO >/dev/null 2>&1 &
-  echo $! > $ROOT_DIR/CM_PID.txt
-else
-  echo "ChartMuseum is already running..."
-fi
-
-# Check if ChartMuseum  is ready to serve request
-command="curl --silent --output /dev/null  $CM_BASE_URL"
-for i in $(seq 1 5)
-do $command && s=0 && break || s=$? && echo "Failed to establish a connection with the ChartMuseum server. Retrying after 5s" && sleep 5;
-done
-
-if [ $s -gt 0 ]
-then
-        echo "Cmd to test ChartMuseum failed with ($s): $command"
-        exit $s
-fi
-
-helm repo remove local
-helm repo add local $CM_CHART_GET_URL
-
-echo -e "\nPackaging NONRTRIC common [nonrtric-common]"
-NONRTRIC_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
-curl --data-binary @/tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $CM_CHART_POST_URL
+source $ROOT_DIR/build-nonrtric-base
 
 charts_already_exists=()
 
diff --git a/bin/verify-nonrtric-charts b/bin/verify-nonrtric-charts
new file mode 100755 (executable)
index 0000000..c454792
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+################################################################################
+#   Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.       #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+OVERRIDEYAML=$1
+
+ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
+
+source $ROOT_DIR/build-nonrtric-base
+
+echo "Create array of helm charts"
+CHART_ARRAY=()
+while IFS= read -r -d $'\0'; do
+    echo -e "File - $REPLY \n"
+    CHART_ARRAY+=("$REPLY")
+done < <(find $ROOT_DIR/../nonrtric -maxdepth 5 -name Chart.yaml -printf '%h\0')
+
+echo "***************************************"
+echo "Remove nonrtric parent chart from linting as its a conceptual visualization of Nonrtric components. This chart doesn't contain any templates & it's primarily
+used for grouping of all Nonrtric components in deployment"
+
+for dir in "${CHART_ARRAY[@]}"
+do
+    if [[ $dir == *"/helm/nonrtric"* ]]; then
+        echo "Skip Nonrtric Parent chart"
+    else
+    echo "Update chart dependency for directory $dir"
+    helm dep up $dir
+    # Lint clearly marks errors; e.g., [ERROR]
+    if [ -z $OVERRIDEYAML ]; then
+        helm lint $dir > /tmp/output 2>&1
+    else
+        helm lint -f $OVERRIDEYAML $dir> /tmp/output 2>&1
+    fi
+    echo "***************************************************************************************************************"
+    cat /tmp/output
+
+    egrep -q '^Error: [0-9]* chart\(s\) linted, [0-9]* chart\(s\) failed' /tmp/output && exit 1
+    echo "***************************************************************************************************************"
+
+    if [ -z $OVERRIDEYAML ]; then
+        helm template $dir > /tmp/output 2>&1
+    else
+       helm template -f $OVERRIDEYAML $dir > /tmp/output 2>&1
+    fi
+    echo "***************************************************************************************************************"
+    cat /tmp/output
+   sleep 1
+    egrep -n '%!.\(.*=.*\)' /tmp/output && echo "Error: Type mismatch." && exit 1
+    echo "***************************************************************************************************************"
+    fi
+done
index 53cc831..51e9b58 100755 (executable)
@@ -2,6 +2,7 @@
 ##############################################################################
 #
 #   Copyright (c) 2019 AT&T Intellectual Property.
+#   Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
 #
 #   Licensed under the Apache License, Version 2.0 (the "License");
 #   you may not use this file except in compliance with the License.
@@ -58,13 +59,9 @@ AUX_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/aux-
 helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/aux-common
 cp /tmp/aux-common-$AUX_COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
-NONRTRIC_COMMON_CHART_VERSION=$(cat $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common/Chart.yaml | grep version | awk '{print $2}')
-helm package -d /tmp $ROOT_DIR/../ric-common/Common-Template/helm/nonrtric-common
-cp /tmp/nonrtric-common-$NONRTRIC_COMMON_CHART_VERSION.tgz $HELM_LOCAL_REPO
 
 
-
-helm repo index $HELM_HOME/repository/local/
+helm repo index $HELM_LOCAL_REPO
 
 echo "Make sure that helm local repo is added"
 helm repo remove local
@@ -75,7 +72,7 @@ echo "Create array of helm charts"
 CHART_ARRAY=()
 while IFS= read -r -d $'\0'; do
     CHART_ARRAY+=("$REPLY")
-done < <(find $ROOT_DIR/../ -maxdepth 5 -name Chart.yaml -printf '%h\0')
+done < <(find $ROOT_DIR/../ -not -path "$ROOT_DIR/../nonrtric/*" -maxdepth 5 -name Chart.yaml -printf '%h\0')
 
 echo "***************************************"
 echo "Remove nonrtric parent chart from linting as its a conceptual visualization of Nonrtric components. This chart doesn't contain any templates & it's primarily
diff --git a/ci/Dockerfile-nonrtric-install b/ci/Dockerfile-nonrtric-install
new file mode 100644 (file)
index 0000000..ae6a9fd
--- /dev/null
@@ -0,0 +1,27 @@
+################################################################################
+#   Copyright (c) 2019 AT&T Intellectual Property.                             #
+#   Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.       #
+#                                                                              #
+#   Licensed under the Apache License, Version 2.0 (the "License");            #
+#   you may not use this file except in compliance with the License.           #
+#   You may obtain a copy of the License at                                    #
+#                                                                              #
+#       http://www.apache.org/licenses/LICENSE-2.0                             #
+#                                                                              #
+#   Unless required by applicable law or agreed to in writing, software        #
+#   distributed under the License is distributed on an "AS IS" BASIS,          #
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
+#   See the License for the specific language governing permissions and        #
+#   limitations under the License.                                             #
+################################################################################
+
+FROM ubuntu:24.04
+RUN apt-get update && apt-get -y install curl ca-certificates wget curl lsof sudo
+ARG HELMVERSION=v3.15.4
+# often times out during LF jenkins build
+RUN wget https://get.helm.sh/helm-${HELMVERSION}-linux-amd64.tar.gz && tar -xvf ../helm-${HELMVERSION}-linux-amd64.tar.gz && mv linux-amd64/helm /usr/local/bin/helm
+ARG TGT=/tmp/it-dep
+COPY . $TGT
+# Remove the smo-install as this one will be verified in another verify job
+RUN rm -rf $TGT/smo-install
+RUN $TGT/bin/verify-nonrtric-charts