Skip to content

Commit ec30722

Browse files
authored
fix(tests): keep two unit tests green after the release image restamp (#5179)
## What this PR does Every PR against `release-1.7` has had a red `Unit & controller tests` check since v1.7.0-rc.3 (seen on #5172, [job](https://github.com/cozystack/cozystack/actions/runs/41162009892/job/124421449910)). The cause is the release build itself: the `Prepare release` commit (0402103) rewrites `packages/*/values.yaml`, and two unit tests read exactly the fields it rewrites. | test | reads | before the release build | after | |---|---|---|---| | `hack/cni-plugins-staging-contract.bats` "the kube-ovn release the CNI plugin pin was checked against is the one vendored" | `.global.images.kubeovn.tag` in `packages/system/kubeovn/values.yaml` | `v1.15.26@sha256:…` | `v1.7.0@sha256:…` | | `packages/system/monitoring/tests/vtraces_collector_test.yaml` "pins the collector image through the cozy-lib.image helper" | `tracingCollector.image` | `docker.io/otel/opentelemetry-collector-contrib:0.136.0@sha256:…` | `ghcr.io/cozystack/cozystack/otelcol-tracing:v0.136.0-cozystack.0@sha256:…` | Changes: - The bats test now takes the vendored kube-ovn release from `appVersion` in `packages/system/kubeovn/charts/kube-ovn/Chart.yaml`. That is the value `packages/system/kubeovn/Makefile` builds the image from, and a release build leaves it alone. The hint printed on a mismatch names the new file. - The helm unittest case no longer names the image at all. It sets `_cluster.images-registry` and asserts that the registry lands in front of the rendered image and that the image stays digest-pinned (the `grafana_upstream_image_plugins_test.yaml` pattern). Removing the `cozy-lib.image` call from the template makes it fail; the old regex did not. Verified locally on this branch: `bats hack/cni-plugins-staging-contract.bats` 10/10, `helm unittest packages/system/monitoring -f tests/vtraces_collector_test.yaml` 28/28. Not a backport: `main` still carries the pre-release pins, so both tests pass there today. The same patch is open against `main` as #5180, so `release-1.8` does not meet the same surprise. Fixes #5178. Refs #5172 (blocked on this check). ### Downstream repositories - [x] No downstream repository is affected by this change ### Release note ```release-note NONE ```
2 parents a32334a + fcc1ada commit ec30722

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

‎hack/cni-plugins-staging-contract.bats‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ extract_has() {
2222
}
2323

2424
DOCKERFILE="$PWD/packages/system/multus/images/multus-cni/Dockerfile"
25-
KUBEOVN_VALUES="$PWD/packages/system/kubeovn/values.yaml"
25+
# The chart's appVersion, not the values.yaml image tag: a release build
26+
# restamps that tag to the Cozystack version (v1.7.0), the chart keeps the
27+
# kube-ovn release it vendors.
28+
KUBEOVN_CHART="$PWD/packages/system/kubeovn/charts/kube-ovn/Chart.yaml"
2629
DOC="$PWD/docs/vm-external-vlan.md"
2730
PLATFORM_VALUES="$PWD/packages/core/platform/values.yaml"
2831
TEMPLATE="$PWD/packages/system/multus/templates/multus-daemonset-thick.yml"
@@ -347,13 +350,12 @@ PATCHFILE="$PWD/packages/system/multus/patches/customize-deployment.patch"
347350
checked=$(sed -n 's|^# kube-ovn-cni-plugins-checked-against: *\([^ ]*\) *$|\1|p' "$DOCKERFILE")
348351
[ -n "$checked" ]
349352

350-
vendored=$(yq -r '.global.images.kubeovn.tag' "$KUBEOVN_VALUES" | sed 's|@.*||')
351-
[ -n "$vendored" ]
352-
[ "$vendored" != "null" ]
353+
vendored=$(awk '$1 == "appVersion:" {gsub(/"/, "", $2); print "v" $2}' "$KUBEOVN_CHART")
354+
[ "$vendored" != "v" ]
353355

354356
if [ "$checked" != "$vendored" ]; then
355357
echo "the multus CNI plugin pin was checked against kube-ovn $checked," >&2
356-
echo "but packages/system/kubeovn/values.yaml now vendors $vendored." >&2
358+
echo "but packages/system/kubeovn/charts/kube-ovn/Chart.yaml now vendors $vendored." >&2
357359
echo >&2
358360
echo "Read CNI_PLUGINS_VERSION in kube-ovn $vendored's base image" >&2
359361
echo "(dist/images/Dockerfile.base). If it still matches the" >&2

‎packages/system/monitoring/tests/vtraces_collector_test.yaml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,18 @@ tests:
473473
path: spec.template.spec.containers[0].securityContext.capabilities.drop
474474
content: ALL
475475

476+
# The image name is not asserted: a release build swaps the upstream
477+
# collector for the first-party otelcol-tracing one and restamps the tag.
478+
# What must hold is that the value goes through cozy-lib.image (the cluster
479+
# images-registry lands in front of it) and stays digest-pinned.
476480
- it: pins the collector image through the cozy-lib.image helper
481+
set:
482+
_cluster:
483+
images-registry: mirror.example.com
477484
documentSelector:
478485
path: kind
479486
value: Deployment
480487
asserts:
481488
- matchRegex:
482489
path: spec.template.spec.containers[0].image
483-
pattern: "opentelemetry-collector-contrib:.*@sha256:"
490+
pattern: '^mirror\.example\.com/.+@sha256:[0-9a-f]{64}$'

0 commit comments

Comments
 (0)