diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86d1c0a..e5a8b02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: name: docker (build and push) runs-on: ubuntu-latest needs: [go] - # if: github.event_name != 'pull_request' permissions: contents: read @@ -82,10 +81,10 @@ jobs: images: ghcr.io/${{ github.repository }} tags: | type=raw,value=latest,enable={{is_default_branch}} - type=sha,format=short,prefix=0.1.0- + type=sha,format=short,prefix=0.1.0-c type=ref,event=tag - - name: Build and push + - name: Build and push docker image uses: docker/build-push-action@v6 with: context: . @@ -159,13 +158,23 @@ jobs: mkdir -p dist helm package helm \ --destination dist \ - --version "${{ steps.ver.outputs.version }}" \ - --app-version "${{ steps.ver.outputs.version }}" + --version "${{ needs.docker.outputs.docker_image_tag }}" \ + --app-version "${{ needs.docker.outputs.docker_image_tag }}" - name: Push chart to GHCR (OCI) shell: bash run: | set -euo pipefail OWNER_LC="$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')" - CHART_TGZ="$(ls -1 dist/cacheppuccino-*.tgz | head -n 1)" - helm push "${CHART_TGZ}" "oci://ghcr.io/${OWNER_LC}" + OCI_REPO="oci://ghcr.io/${OWNER_LC}" + PACKAGE_FILE="$(ls -1 dist/cacheppuccino-*.tgz | head -n 1)" + IMAGE="${{ needs.docker.outputs.docker_image_tag }}" + + # Add GitHub Actions summary + echo "# Helm Chart" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```yaml' >> $GITHUB_STEP_SUMMARY + helm push "$PACKAGE_FILE" "$OCI_REPO" 2>> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "> [!Important]" >> $GITHUB_STEP_SUMMARY + echo "> NOTE: Tagged Docker image & Helm chart version: **$IMAGE**" >> $GITHUB_STEP_SUMMARY diff --git a/helm/README.md b/helm/README.md new file mode 100644 index 0000000..a9c465d --- /dev/null +++ b/helm/README.md @@ -0,0 +1,12 @@ +## Strategy + Azure storage + +### Why these errors happen (short) +- `FailedAttachVolume` / `FailedVolumeAttach`: usually occurs when the PVC is backed by ReadWriteOnce (RWO) storage and Kubernetes attempts to start a new Pod before the old Pod has fully released/detached the volume.Because the same volume can’t be attached to two Pods/nodes at once, the attach step fails and the rollout can get stuck. +- `database is locked` (SQLite): after switching the PVC `storageClass` to `azurefile-csi`, the app started hitting SQLite lock errors. + +We observed these issues during rollouts on Azure when multiple Pods briefly overlapped. + +### Current approach (what we use) +We use `strategy.type: Recreate` so upgrades run only one Pod at a time: +- switched back to the default storage class +- `Recreate` avoids parallel Pod overlap, which prevents volume attach conflicts and reduces the chance of SQLite locking problems diff --git a/helm/snapshots/alpha-1.yaml b/helm/snapshots/alpha-1.yaml index e75d743..dd1e840 100644 --- a/helm/snapshots/alpha-1.yaml +++ b/helm/snapshots/alpha-1.yaml @@ -103,6 +103,8 @@ metadata: app.kubernetes.io/managed-by: Helm spec: replicas: 1 + strategy: + type: Recreate selector: matchLabels: app.kubernetes.io/name: cacheppuccino-helm diff --git a/helm/snapshots/staging.yaml b/helm/snapshots/staging.yaml index 567d36d..f96afcc 100644 --- a/helm/snapshots/staging.yaml +++ b/helm/snapshots/staging.yaml @@ -46,9 +46,8 @@ metadata: app.kubernetes.io/version: "0.1.0" app.kubernetes.io/managed-by: Helm spec: - storageClassName: "azurefile-csi" accessModes: - - ReadWriteMany + - ReadWriteOnce resources: requests: storage: "512Mi" @@ -90,6 +89,8 @@ metadata: app.kubernetes.io/managed-by: Helm spec: replicas: 1 + strategy: + type: Recreate selector: matchLabels: app.kubernetes.io/name: cacheppuccino-helm diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index de78dbd..1d6912f 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -9,6 +9,8 @@ metadata: {{- include "cacheppuccino.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} + strategy: + type: Recreate selector: matchLabels: {{- include "cacheppuccino.selectorLabels" . | nindent 6 }} diff --git a/helm/templates/pvc.yaml b/helm/templates/pvc.yaml index 19ad433..b116344 100644 --- a/helm/templates/pvc.yaml +++ b/helm/templates/pvc.yaml @@ -10,7 +10,7 @@ spec: storageClassName: {{ .Values.sqlite.pvc.storageClassName | quote }} {{- end }} accessModes: - {{- toYaml .Values.sqlite.pvc.accessModes | nindent 4 }} + - ReadWriteOnce resources: requests: storage: {{ .Values.sqlite.pvc.size | quote }} diff --git a/helm/values/go-deploy.yaml b/helm/values/go-deploy.yaml index 5178980..38bbdc8 100644 --- a/helm/values/go-deploy.yaml +++ b/helm/values/go-deploy.yaml @@ -11,9 +11,6 @@ ingress: sqlite: pvc: size: 512Mi - storageClassName: azurefile-csi - accessModes: - - ReadWriteMany serviceAccount: create: true