Files
cozystack/hack/proxmox-csi-driver-pin_test.bats
T
Marian Koreniuk 780b068df0 fix(kubernetes, proxmox-csi): pin the Proxmox CSI driver images by digest
The CSI controller in the management cluster was referenced by the bare
tag ghcr.io/sergelogvinov/proxmox-csi-controller:v0.20.0, and the node
plugin in the tenant by the vendored chart's default, its appVersion as
a bare tag. That registry is the one whose proxmox-cloud-controller-
manager:v0.15.0 was re-pushed to a build that panics, so a tag there is
not a statement of what runs.

Both now carry the v0.20.0 digest: the controller through
images/proxmox-csi-controller.tag, like the cloud-controller-manager, and
the node plugin through repository and tag in the proxmox-csi values,
which also makes it visible to hack/lib/image-refs.sh and therefore to
the release multi-arch gate. Both digests are indexes for linux/amd64
and linux/arm64.

Pinning takes the version out of the vendored chart's hands: a chart
bump would bring a new appVersion while both pins kept naming the old
release, and the controller and the node plugin would drift apart from
the templates and from each other without anything noticing.
hack/proxmox-csi-driver-pin_test.bats fails unless the chart's
appVersion and both pins name the same release.

The sig-storage sidecars stay on tags, as they do for the KubeVirt CSI
driver: registry.k8s.io publishes them through image promotion, which
does not overwrite a tag.

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
2026-10-28 18:38:35 +01:00

45 lines
2.0 KiB
Bash

#!/usr/bin/env bats
# Upstream releases the Proxmox CSI controller and node plugin together, and
# its chart renders both from one appVersion. Here they run in two places and
# are pinned in two packages: the controller in the management cluster
# (packages/apps/kubernetes, an images/.tag file) and the node plugin in the
# tenant (packages/system/proxmox-csi, a values override on the vendored
# chart). Both are pinned by digest because tags in that registry have been
# re-pushed, and the pin is what takes the version out of the chart's hands:
# `make update` with a new CHART_VERSION brings new templates and a new
# appVersion while both pins keep naming the old build, and nothing else
# notices.
#
# This asserts the chart's appVersion and both pins name the same release.
load test_helper
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
@test "the Proxmox CSI controller and node plugin pin the vendored chart's release" {
chart="$REPO_ROOT/packages/system/proxmox-csi/charts/proxmox-csi-plugin/Chart.yaml"
values="$REPO_ROOT/packages/system/proxmox-csi/values.yaml"
tagfile="$REPO_ROOT/packages/apps/kubernetes/images/proxmox-csi-controller.tag"
app_version=$(yq -r '.appVersion' "$chart")
node_tag=$(yq -r '."proxmox-csi-plugin".node.plugin.image.tag' "$values")
controller_ref=$(tr -d '[:space:]' < "$tagfile")
[ -n "$app_version" ] && [ "$app_version" != null ] || {
echo "no appVersion in $chart" >&2
return 1
}
[ "${node_tag%%@*}" = "$app_version" ] || {
echo "node plugin tag '$node_tag' is not the chart appVersion $app_version" >&2
echo "set proxmox-csi-plugin.node.plugin.image.tag in packages/system/proxmox-csi/values.yaml" >&2
return 1
}
[ "${controller_ref%%@*}" = "ghcr.io/sergelogvinov/proxmox-csi-controller:$app_version" ] || {
echo "controller ref '$controller_ref' is not proxmox-csi-controller:$app_version" >&2
echo "update packages/apps/kubernetes/images/proxmox-csi-controller.tag" >&2
return 1
}
}