From 18f9e00810eb644328e96c6d26265a51c793168b Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Wed, 6 Nov 2024 18:59:07 -0700 Subject: [PATCH 1/2] feat(marketplace): also annotate nodes on upgrade to support shim upgrade Signed-off-by: Vaughn Dice --- .../templates/kwasm-annotate-nodes-job.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml b/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml index 3c8c978..f9e3e77 100644 --- a/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml +++ b/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml @@ -3,7 +3,7 @@ kind: Job metadata: name: "{{ .Release.Name }}-kwasm-annotate-nodes" annotations: - "helm.sh/hook": post-install + "helm.sh/hook": post-install,post-upgrade "helm.sh/hook-weight": "-4" "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: @@ -15,8 +15,13 @@ spec: containers: - name: kubectl image: {{ printf "%s/%s:%s" .Values.global.azure.images.kubectl.registry .Values.global.azure.images.kubectl.image .Values.global.azure.images.kubectl.tag }} - command: ["kubectl"] - args: ["annotate", "node", "--all", "kwasm.sh/kwasm-node=true"] + command: ["/bin/sh", "-c"] + args: + - |- + echo "Annotating node with kwasm.sh/kwasm-node=false to reset installation of the shim for upgrade scenarios" + kubectl annotate node --all kwasm.sh/kwasm-node=false --overwrite + echo "Annotating node with kwasm.sh/kwasm-node=true to (re-)trigger installation of the shim" + kubectl annotate node --all kwasm.sh/kwasm-node=true --overwrite restartPolicy: OnFailure --- apiVersion: v1 From 9d5481601f34fd2df21dafd771e4d4fa76e37b7c Mon Sep 17 00:00:00 2001 From: Vaughn Dice Date: Wed, 6 Nov 2024 20:04:37 -0700 Subject: [PATCH 2/2] ci(.github): add upgrade/shim re-install check to smoke-test Signed-off-by: Vaughn Dice --- .github/workflows/marketplace-smoke-test.yaml | 23 +++++++++++++++++++ .../templates/kwasm-annotate-nodes-job.yaml | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/marketplace-smoke-test.yaml b/.github/workflows/marketplace-smoke-test.yaml index 3996fb0..df5ee21 100644 --- a/.github/workflows/marketplace-smoke-test.yaml +++ b/.github/workflows/marketplace-smoke-test.yaml @@ -24,6 +24,8 @@ jobs: - name: create kind cluster uses: helm/kind-action@v1 + ## Install SpinKube and verify Spin App runs + - name: helm install spinkube run: | helm install spinkube \ @@ -56,6 +58,25 @@ jobs: - name: Verify curl run: curl localhost:8083/hello + ## Upgrade release and verify shim is re-installed + + - name: delete any lingering kwasm jobs + run: kubectl -n spinkube delete job -l kwasm.sh/job=true + + - name: helm upgrade spinkube and watch for annotate and install job completions + run: | + helm upgrade spinkube \ + --wait \ + --namespace spinkube \ + --debug \ + marketplace/charts/spinkube-azure-marketplace & + timeout 30s bash -c 'until [[ "$(kubectl -n spinkube get job -l job-name=spinkube-kwasm-annotate-nodes -o json | jq '.items[].spec.completions')" == "1" ]]; do sleep 2; done' + timeout 30s bash -c 'until [[ "$(kubectl -n spinkube get job -l kwasm.sh/job=true -o json | jq '.items[].spec.completions')" == "1" ]]; do sleep 2; done' + + ## Delete release + + # First, verify deletion is blocked when Spin App resources exist + - name: helm delete spinkube run: | if helm delete spinkube --timeout 1m --namespace spinkube; then @@ -80,6 +101,8 @@ jobs: - name: Delete Spin App run: kubectl delete spinapp simple-spinapp + # Now verify deletion proceeds and no resources remain + - name: helm delete spinkube run: helm delete spinkube --timeout 1m --namespace spinkube diff --git a/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml b/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml index f9e3e77..119c4e7 100644 --- a/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml +++ b/marketplace/charts/spinkube-azure-marketplace/templates/kwasm-annotate-nodes-job.yaml @@ -18,9 +18,9 @@ spec: command: ["/bin/sh", "-c"] args: - |- - echo "Annotating node with kwasm.sh/kwasm-node=false to reset installation of the shim for upgrade scenarios" + echo "Annotating nodes with kwasm.sh/kwasm-node=false to reset installation of the shim for upgrade scenarios" kubectl annotate node --all kwasm.sh/kwasm-node=false --overwrite - echo "Annotating node with kwasm.sh/kwasm-node=true to (re-)trigger installation of the shim" + echo "Annotating nodes with kwasm.sh/kwasm-node=true to (re-)trigger installation of the shim" kubectl annotate node --all kwasm.sh/kwasm-node=true --overwrite restartPolicy: OnFailure ---