From 83b1599728efc54ebec5ea3f15f2fa5451ecc03b Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Wed, 6 Sep 2023 17:21:59 +1000 Subject: [PATCH 1/8] feat: restructure make file scripts and add ability to load local kubectl-bats image Signed-off-by: Lenin Mehedy --- dev/Makefile | 139 +++++++++++++++++++++++++++--------------- dev/ci/ci-values.yaml | 8 +++ dev/scripts/docker.sh | 23 +++++++ dev/scripts/main.sh | 44 +++++++++++++ 4 files changed, 164 insertions(+), 50 deletions(-) create mode 100644 dev/ci/ci-values.yaml create mode 100644 dev/scripts/docker.sh create mode 100644 dev/scripts/main.sh diff --git a/dev/Makefile b/dev/Makefile index 769ed9b36..e8fa7dc11 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -12,21 +12,24 @@ SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit setup \ setup-cluster \ deploy-chart \ + destroy-chart \ helm-test \ deploy-network \ destroy-test-container \ destroy-network test - # Setup variables SCRIPTS_DIR=$(PWD)/scripts CHART_DIR=$(PWD)/../charts/hedera-network SCRIPT_NAME=direct-install.sh TMP_DIR=${SCRIPTS_DIR}/../temp +CHART_VALUES_FILES= # extra values + # scripts TELEMETRY_SCRIPT="telemetry.sh" GATEWAY_API_SCRIPT="gateway.sh" +DOCKER_SCRIPT="docker.sh" .PHONY: all all: setup setup-cluster reset @@ -40,67 +43,52 @@ setup: setup-cluster: kind create cluster -n fst +.PHONY: destroy-cluster +destroy-cluster: + kind delete cluster -n fst + +.PHONY: install-chart +install-chart: + source "${SCRIPTS_DIR}/main.sh" && install_chart "${SCRIPT_NAME}" + +.PHONY: uninstall-chart +uninstall-chart: + source "${SCRIPTS_DIR}/main.sh" && uninstall_chart + .PHONY: update-helm-dependencies update-helm-dependencies: helm dependency update ../charts/hedera-network .PHONY: deploy-chart -deploy-chart: deploy-minio-operator-if-required deploy-prometheus-operator deploy-gateway-api - echo ">> Deploying helm chart..." && \ - echo "" && \ - if [ "${SCRIPT_NAME}" = "nmt-install.sh" ]; then \ - helm install fst ../charts/hedera-network --set defaults.root.image.repository=hashgraph/full-stack-testing/ubi8-init-dind ; \ - else \ - helm install fst ../charts/hedera-network ; \ - fi \ - -.PHONY: helm-test -helm-test: - echo "" && \ - echo ">> Running helm test..." && \ - echo "" && \ - # We have to specify the specific test name here, otherwise it executes all tests from the subcharts as well. - # I had to remove --logs, because --logs ignores filter and tries to get logs for all test pods - # - Error: unable to get pod logs for fst-graphql-test: pods "fst-graphql-test" not found - helm test fst --filter 'name=network-test' && \ - EXIT_CODE=$$? && \ - kubectl logs network-test && \ - exit $${EXIT_CODE} +deploy-chart: + $(MAKE) update-helm-dependencies + $(MAKE) deploy-minio-operator-if-required + $(MAKE) deploy-prometheus-operator + $(MAKE) deploy-gateway-api + $(MAKE) install-chart + +.PHONY: destroy-chart +destroy-chart: + -$(MAKE) uninstall-chart + -$(MAKE) destroy-gateway-api + -$(MAKE) destroy-prometheus-operator + -$(MAKE) undeploy-minio-operator .PHONY: deploy-network deploy-network: deploy-chart echo "" && \ - echo ">> Pod Information...." && \ - echo "" && \ - kubectl get pods -o wide && \ - echo "" && \ echo ">> Service Information...." && \ echo "" && \ - kubectl get svc -o wide - -.PHONY: destroy-test-container -destroy-test-container: + kubectl get svc -o wide && \ echo "" && \ - echo ">> Deleting test container..." && \ - kubectl delete pod network-test || true - -.PHONY: destroy-network -destroy-network: destroy-test-container + echo ">> Pod Information...." && \ echo "" && \ - echo ">> Uninstalling helm chart..." && \ - helm uninstall fst && \ - sleep 10 + kubectl get pods -o wide && \ + echo ">> Waiting for network-node pods to be active (first deployment takes ~10m)...." && \ + kubectl wait --for=jsonpath='{.status.phase}'=Running pod -l fullstack.hedera.com/type=network-node --timeout=900s -.PHONY: test -test: - # Enable cleanup_test function so that even if test fails, we cleanup the cluster. - # We are only enabling this in this make target, however if necessary, similar pattern can be used in other targets. - # Ref: https://stackoverflow.com/questions/28597794/how-can-i-clean-up-after-an-error-in-a-makefile - function cleanup_test { - $(MAKE) destroy-network - } - trap cleanup_test EXIT # always destroy-network on exit - $(MAKE) setup deploy-minio-operator-if-required update-helm-dependencies deploy-network helm-test setup-nodes start-nodes +.PHONY: destroy-network +destroy-network: destroy-test-container destroy-chart .PHONY: setup-nodes setup-nodes: setup @@ -184,8 +172,8 @@ destroy-prometheus: deploy-minio-operator: @echo ">> Deploying minio operator..."; \ helm install --repo https://operator.min.io/ --namespace=minio-operator --create-namespace --version 5.0.7 minio-operator operator && \ - echo ">> Waiting for minio operator to be ready..." && \ - kubectl --namespace=minio-operator wait --for=condition=available --timeout=600s deployment.apps/minio-operator && \ + echo ">> Waiting for minio operator to be available (timeout 300s)..." && \ + kubectl --namespace=minio-operator wait --for=condition=Available --timeout=300s deployment.apps/minio-operator && \ sleep 5 .PHONY: is-minio-operator-installed @@ -203,3 +191,54 @@ deploy-minio-operator-if-required: undeploy-minio-operator: echo ">> Deploying minio operator..." && \ helm delete --namespace=minio-operator minio-operator + + +######################################### Helm Chart Test ################################# +.PHONY: helm-test +helm-test: + echo "" && \ + echo ">> Running helm test...(first run takes ~2m)" && \ + echo "" && \ + # We have to specify the specific test name here, otherwise it executes all tests from the subcharts as well. + # I had to remove --logs, because --logs ignores filter and tries to get logs for all test pods + # - Error: unable to get pod logs for fst-graphql-test: pods "fst-graphql-test" not found + helm test fst --filter 'name=network-test' && \ + EXIT_CODE=$$? && \ + kubectl logs network-test && \ + exit $${EXIT_CODE} + +.PHONY: destroy-test-container +destroy-test-container: + echo "" && \ + echo ">> Deleting test container..." && \ + kubectl delete pod network-test || true + +######################################### CI ################################# +.PHONY: local-kubectl-bats +local-kubectl-bats: + source "${SCRIPTS_DIR}/${DOCKER_SCRIPT}" && build_kubectl_bats && load_kubectl_bats_image + +.PHONY: deploy-all +deploy-all: + # Enable cleanup_test function so that even if test fails, we cleanup the cluster. + # We are only enabling this in this make target, however if necessary, similar pattern can be used in other targets. + # Ref: https://stackoverflow.com/questions/28597794/how-can-i-clean-up-after-an-error-in-a-makefile + function cleanup_test { + $(MAKE) destroy-network + } + trap cleanup_test EXIT # always destroy-network on exit + $(MAKE) setup + $(MAKE) deploy-network + $(MAKE) helm-test + $(MAKE) setup-nodes + $(MAKE) start-nodes + +.PHONY: destroy-all +destroy-all: + -$(MAKE) destroy-network + -$(MAKE) undeploy-minio-operator + -$(MAKE) destroy-prometheus-operator + +.PHONY: ci-test +ci-test: local-kubectl-bats + $(MAKE) deploy-all CHART_VALUES_FILES="--values ci/ci-values.yaml" diff --git a/dev/ci/ci-values.yaml b/dev/ci/ci-values.yaml new file mode 100644 index 000000000..2448729a5 --- /dev/null +++ b/dev/ci/ci-values.yaml @@ -0,0 +1,8 @@ +# helm test container +tester: + image: + registry: "docker.fst.local" + repository: "kubectl-bats" + tag: "local" + pullPolicy: "Never" + resources: {} \ No newline at end of file diff --git a/dev/scripts/docker.sh b/dev/scripts/docker.sh new file mode 100644 index 000000000..c7c89a96d --- /dev/null +++ b/dev/scripts/docker.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +readonly SCRIPT_DIR +readonly DOCKERFILE_DIR="${SCRIPT_DIR}/../../docker" +readonly LOCAL_DOCKER_REGISTRY="docker.fst.local" # same as in dev/ci/ci-values.yaml +readonly LOCAL_DOCKER_IMAGE_TAG="local" +readonly KUBECTL_BATS_IMAGE="${LOCAL_DOCKER_REGISTRY}/kubectl-bats:${LOCAL_DOCKER_IMAGE_TAG}" +readonly FST_CLUSTER_NAME="fst" + +function build_kubectl_bats() { + echo "" + echo "Building kubectl-bats image" + echo "-----------------------------------------------------------------------------------------------------" + cd "${DOCKERFILE_DIR}/kubectl-bats" && docker build -t "${KUBECTL_BATS_IMAGE}" . +} + +function load_kubectl_bats_image() { + echo "" + echo "Loading kubectl-bats image into local kind cluster" + echo "-----------------------------------------------------------------------------------------------------" + kind load docker-image ${KUBECTL_BATS_IMAGE} -n "${FST_CLUSTER_NAME}" +} \ No newline at end of file diff --git a/dev/scripts/main.sh b/dev/scripts/main.sh new file mode 100644 index 000000000..014affc15 --- /dev/null +++ b/dev/scripts/main.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +readonly SCRIPT_DIR +CHART_DIR="${SCRIPT_DIR}/../../charts/hedera-network" + +function install_chart() { + local node_setup_script=$1 + + echo "" + echo "Installing helm chart... " + echo "SCRIPT_NAME: ${node_setup_script}" + echo "Values: -f ${CHART_DIR}/values.yaml --values ${CHART_VALUES_FILES}" + echo "-----------------------------------------------------------------------------------------------------" + if [ "${node_setup_script}" = "nmt-install.sh" ]; then + nmt_install + else + direct_install + fi +} + +function uninstall_chart() { + echo "" + echo "Uninstalling helm chart... " + echo "-----------------------------------------------------------------------------------------------------" + helm uninstall fst + sleep 10 +} + +function nmt_install() { + if [[ -z "${CHART_VALUES_FILES}" ]]; then + helm install fst "${CHART_DIR}" --set defaults.root.image.repository=hashgraph/full-stack-testing/ubi8-init-dind + else + helm install fst "${CHART_DIR}" -f "${CHART_DIR}/values.yaml" --values "${CHART_VALUES_FILES}" --set defaults.root.image.repository=hashgraph/full-stack-testing/ubi8-init-dind + fi +} + +function direct_install() { + if [[ -z "${CHART_VALUES_FILES}" ]]; then + helm install fst "${CHART_DIR}" + else + helm install fst "${CHART_DIR}" -f "${CHART_DIR}/values.yaml" --values "${CHART_VALUES_FILES}" + fi +} From 1081d5abb4a40f64b4cd3793d5cf0166c0fd05ee Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Wed, 6 Sep 2023 19:32:33 +1000 Subject: [PATCH 2/8] ci: enable ci-test to use locally built kubectl-bats image Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 4 ++-- dev/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 0d48bf642..95408ee2b 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -147,13 +147,13 @@ jobs: - name: Helm Chart Test (Direct Install) working-directory: dev if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }} - run: make test SCRIPT_NAME=direct-install.sh + run: make ci-test SCRIPT_NAME=direct-install.sh # This step tests the Helm chart NMT mode of operation which uses the ubi8-init-dind image. - name: Helm Chart Test (NMT Install) working-directory: dev if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }} - run: make test SCRIPT_NAME=nmt-install.sh + run: make ci-test SCRIPT_NAME=nmt-install.sh - name: Compile id: gradle-build diff --git a/dev/Makefile b/dev/Makefile index e8fa7dc11..f8b8ea51a 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -241,4 +241,4 @@ destroy-all: .PHONY: ci-test ci-test: local-kubectl-bats - $(MAKE) deploy-all CHART_VALUES_FILES="--values ci/ci-values.yaml" + $(MAKE) deploy-all CHART_VALUES_FILES="$(PWD)/ci/ci-values.yaml" From 56415f0e0a10eeda2a7597cb2da266618daeb68d Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 7 Sep 2023 06:57:28 +1000 Subject: [PATCH 3/8] ci: setup cluster before running ci-test Signed-off-by: Lenin Mehedy --- dev/Makefile | 7 ++++--- dev/scripts/docker.sh | 13 +++++-------- dev/scripts/main.sh | 13 +++++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/dev/Makefile b/dev/Makefile index f8b8ea51a..a5f891340 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -19,6 +19,7 @@ SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit destroy-network test # Setup variables +CLUSTER_NAME="fst" SCRIPTS_DIR=$(PWD)/scripts CHART_DIR=$(PWD)/../charts/hedera-network SCRIPT_NAME=direct-install.sh @@ -41,7 +42,7 @@ setup: .PHONY: setup-cluster setup-cluster: - kind create cluster -n fst + source "${SCRIPTS_DIR}/main.sh" && setup_cluster "${CLUSTER_NAME}" .PHONY: destroy-cluster destroy-cluster: @@ -216,7 +217,7 @@ destroy-test-container: ######################################### CI ################################# .PHONY: local-kubectl-bats local-kubectl-bats: - source "${SCRIPTS_DIR}/${DOCKER_SCRIPT}" && build_kubectl_bats && load_kubectl_bats_image + source "${SCRIPTS_DIR}/${DOCKER_SCRIPT}" && build_kubectl_bats "${CLUSTER_NAME}" .PHONY: deploy-all deploy-all: @@ -240,5 +241,5 @@ destroy-all: -$(MAKE) destroy-prometheus-operator .PHONY: ci-test -ci-test: local-kubectl-bats +ci-test: setup-cluster local-kubectl-bats $(MAKE) deploy-all CHART_VALUES_FILES="$(PWD)/ci/ci-values.yaml" diff --git a/dev/scripts/docker.sh b/dev/scripts/docker.sh index c7c89a96d..d4db8d3d6 100644 --- a/dev/scripts/docker.sh +++ b/dev/scripts/docker.sh @@ -6,18 +6,15 @@ readonly DOCKERFILE_DIR="${SCRIPT_DIR}/../../docker" readonly LOCAL_DOCKER_REGISTRY="docker.fst.local" # same as in dev/ci/ci-values.yaml readonly LOCAL_DOCKER_IMAGE_TAG="local" readonly KUBECTL_BATS_IMAGE="${LOCAL_DOCKER_REGISTRY}/kubectl-bats:${LOCAL_DOCKER_IMAGE_TAG}" -readonly FST_CLUSTER_NAME="fst" function build_kubectl_bats() { + local cluster_name=$1 + local cluster_name=$1 + [[ -z "${cluster_name}" ]] && echo "ERROR: Cluster name is required" && return 1 + echo "" echo "Building kubectl-bats image" echo "-----------------------------------------------------------------------------------------------------" cd "${DOCKERFILE_DIR}/kubectl-bats" && docker build -t "${KUBECTL_BATS_IMAGE}" . -} - -function load_kubectl_bats_image() { - echo "" - echo "Loading kubectl-bats image into local kind cluster" - echo "-----------------------------------------------------------------------------------------------------" - kind load docker-image ${KUBECTL_BATS_IMAGE} -n "${FST_CLUSTER_NAME}" + kind load docker-image ${KUBECTL_BATS_IMAGE} -n "${cluster_name}" } \ No newline at end of file diff --git a/dev/scripts/main.sh b/dev/scripts/main.sh index 014affc15..997194a45 100644 --- a/dev/scripts/main.sh +++ b/dev/scripts/main.sh @@ -4,6 +4,19 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" readonly SCRIPT_DIR CHART_DIR="${SCRIPT_DIR}/../../charts/hedera-network" +function setup_cluster() { + local cluster_name=$1 + [[ -z "${cluster_name}" ]] && echo "ERROR: Cluster name is required" && return 1 + + local count=$(kind get clusters -q | grep -c "${cluster_name}") + if [[ $count -eq 0 ]]; then + echo "Creating cluster ${cluster_name}" + kind create cluster -n "${cluster_name}" + else + echo "Cluster '${cluster_name}' found" + fi +} + function install_chart() { local node_setup_script=$1 From c5d77509b9baeceaa344d4be95e81119a246045e Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 7 Sep 2023 07:13:46 +1000 Subject: [PATCH 4/8] ci: setup cluster earlier in the pipeline Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 2 +- dev/Makefile | 6 +++++- dev/scripts/main.sh | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 95408ee2b..916677e27 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -116,7 +116,7 @@ jobs: working-directory: dev if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }} run: | - make deploy-prometheus-operator + make setup-cluster deploy-prometheus-operator # Technically, this step is not required for the unit tests to run, but it is useful for debugging setup issues. - name: Kubernetes Cluster Info diff --git a/dev/Makefile b/dev/Makefile index a5f891340..7672ca6bd 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -15,8 +15,12 @@ SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit destroy-chart \ helm-test \ deploy-network \ + destroy-network \ destroy-test-container \ - destroy-network test + deploy-all \ + destroy-all \ + local-kubectl-bats \ + ci-test # Setup variables CLUSTER_NAME="fst" diff --git a/dev/scripts/main.sh b/dev/scripts/main.sh index 997194a45..429f6f389 100644 --- a/dev/scripts/main.sh +++ b/dev/scripts/main.sh @@ -10,7 +10,7 @@ function setup_cluster() { local count=$(kind get clusters -q | grep -c "${cluster_name}") if [[ $count -eq 0 ]]; then - echo "Creating cluster ${cluster_name}" + echo "Cluster '${cluster_name}' not found" kind create cluster -n "${cluster_name}" else echo "Cluster '${cluster_name}' found" From 6488c578afcf48ee47feebe004cd7b8a5316960f Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 7 Sep 2023 07:36:43 +1000 Subject: [PATCH 5/8] ci: set kubectl context to newly created cluster with default namespace Signed-off-by: Lenin Mehedy --- dev/Makefile | 2 +- dev/scripts/main.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dev/Makefile b/dev/Makefile index 7672ca6bd..c47ff1646 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -23,7 +23,7 @@ SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit ci-test # Setup variables -CLUSTER_NAME="fst" +CLUSTER_NAME="${CLUSTER_NAME:-fst}" SCRIPTS_DIR=$(PWD)/scripts CHART_DIR=$(PWD)/../charts/hedera-network SCRIPT_NAME=direct-install.sh diff --git a/dev/scripts/main.sh b/dev/scripts/main.sh index 429f6f389..19773aef3 100644 --- a/dev/scripts/main.sh +++ b/dev/scripts/main.sh @@ -15,6 +15,10 @@ function setup_cluster() { else echo "Cluster '${cluster_name}' found" fi + + kubectl config use-context "kind-${cluster_name}" + kubectl config set-context --current --namespace=default + kubectl config get-contexts } function install_chart() { From 09bfd86235a9a97f47b31e864b6d81636cd96e56 Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 7 Sep 2023 07:50:29 +1000 Subject: [PATCH 6/8] ci: set cluster name from env variable Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 1 - dev/Makefile | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 916677e27..6e0621a5c 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -122,7 +122,6 @@ jobs: - name: Kubernetes Cluster Info if: ${{ inputs.enable-unit-tests && !cancelled() }} run: | - kubectl config set-context --current --namespace=default kubectl config get-contexts kubectl get crd diff --git a/dev/Makefile b/dev/Makefile index c47ff1646..e804fda54 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -23,7 +23,7 @@ SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit ci-test # Setup variables -CLUSTER_NAME="${CLUSTER_NAME:-fst}" +CLUSTER_NAME ?="fst" SCRIPTS_DIR=$(PWD)/scripts CHART_DIR=$(PWD)/../charts/hedera-network SCRIPT_NAME=direct-install.sh @@ -46,6 +46,7 @@ setup: .PHONY: setup-cluster setup-cluster: + echo "Cluster name: ${CLUSTER_NAME}" && \ source "${SCRIPTS_DIR}/main.sh" && setup_cluster "${CLUSTER_NAME}" .PHONY: destroy-cluster From 679b4e43acbe7be58577bc8890a1793d443d9b0b Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 7 Sep 2023 07:58:26 +1000 Subject: [PATCH 7/8] ci: attempt to debug Signed-off-by: Lenin Mehedy --- dev/scripts/telemetry.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/scripts/telemetry.sh b/dev/scripts/telemetry.sh index 82121b54d..e13070045 100644 --- a/dev/scripts/telemetry.sh +++ b/dev/scripts/telemetry.sh @@ -32,10 +32,11 @@ function deploy-prometheus-operator() { echo "Deploying prometheus operator" echo "PROMETHEUS_OPERATOR_YAML: ${PROMETHEUS_OPERATOR_YAML}" echo "-----------------------------------------------------------------------------------------------------" - local crd_count=$(kubectl get crd | grep "monitoring.coreos.com" | wc -l) + local crd_count=$(kubectl get crd | grep -c "monitoring.coreos.com" ) if [[ $crd_count -ne 10 ]]; then kubectl create -f "${PROMETHEUS_OPERATOR_YAML}" - kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator -n default + kubectl get pods + kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator --timeout 300s else echo "Prometheus operator CRD is already installed" echo "" From ca9dd542f86cda15364df44f6d874125c659c5dc Mon Sep 17 00:00:00 2001 From: Lenin Mehedy Date: Thu, 7 Sep 2023 09:38:08 +1000 Subject: [PATCH 8/8] ci: attempt fix Signed-off-by: Lenin Mehedy --- .github/workflows/zxc-compile-code.yaml | 3 ++- dev/scripts/main.sh | 2 +- dev/scripts/telemetry.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index 6e0621a5c..0285d6da9 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -102,6 +102,7 @@ jobs: uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0 if: ${{ inputs.enable-unit-tests && !cancelled() }} with: + cluster_name: fst version: v0.19.0 verbosity: 3 wait: 120s @@ -116,7 +117,7 @@ jobs: working-directory: dev if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }} run: | - make setup-cluster deploy-prometheus-operator + make deploy-prometheus-operator # Technically, this step is not required for the unit tests to run, but it is useful for debugging setup issues. - name: Kubernetes Cluster Info diff --git a/dev/scripts/main.sh b/dev/scripts/main.sh index 19773aef3..f4866ac5f 100644 --- a/dev/scripts/main.sh +++ b/dev/scripts/main.sh @@ -8,7 +8,7 @@ function setup_cluster() { local cluster_name=$1 [[ -z "${cluster_name}" ]] && echo "ERROR: Cluster name is required" && return 1 - local count=$(kind get clusters -q | grep -c "${cluster_name}") + local count=$(kind get clusters -q | grep -c -sw "${cluster_name}") if [[ $count -eq 0 ]]; then echo "Cluster '${cluster_name}' not found" kind create cluster -n "${cluster_name}" diff --git a/dev/scripts/telemetry.sh b/dev/scripts/telemetry.sh index e13070045..5fd765c5e 100644 --- a/dev/scripts/telemetry.sh +++ b/dev/scripts/telemetry.sh @@ -35,8 +35,8 @@ function deploy-prometheus-operator() { local crd_count=$(kubectl get crd | grep -c "monitoring.coreos.com" ) if [[ $crd_count -ne 10 ]]; then kubectl create -f "${PROMETHEUS_OPERATOR_YAML}" - kubectl get pods - kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator --timeout 300s + kubectl get pods --all-namespaces + kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator --timeout 300s --all-namespaces else echo "Prometheus operator CRD is already installed" echo ""