Skip to content

Commit 7bce84d

Browse files
fix(kubernetes)!: remove the talos fields the chart does not read
The kubernetes chart declared talos.schematicID, imageFactoryURL, installerRepository and registryMirrors, and no template of it reads them. Workers are KubernetesNodes pools since the split and take these from their own talos values, so an operator who set them on the cluster got no error and no effect. Only talos.version, which the support-matrix check reads, stays. The fields leave the API schema, hence the "!". Stored specs that still carry the keys keep rendering: the values schema does not close the object and the API does not validate spec against it. Readers outside the chart moved with it. The e2e install read talos.schematicID from this chart's values.yaml in a best-effort block that only warns, so removing the field would have stopped the image cache being seeded without failing anything; it now reads the pool chart, as the proxmox template script already does. The e2e no longer writes a talos block into the Kubernetes CR, the spec test checks the pool chart for the key it emits, the release checklist diffs the pool chart's pins as well, and the README points at the pool's own talos. The null-normalization Go tests used talos.registryMirrors as their free-form fixture; they use addons.cilium.valuesOverride, which has the same shape. Assisted-By: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent 4087218 commit 7bce84d

15 files changed

Lines changed: 99 additions & 111 deletions

File tree

‎api/apps/v1alpha1/kubernetes/types.go‎

Lines changed: 2 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎api/apps/v1alpha1/kubernetes/zz_generated.deepcopy.go‎

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/release.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ git diff --name-only $PREV..$NEW -- 'packages/*/charts/*/Chart.yaml' 'packages/*
546546
done
547547

548548
# B. Out-of-Chart.yaml pins (Talos, tenant K8s, vendored images)
549-
for path in packages/core/talos/images/talos/profiles/installer.yaml packages/core/installer/values.yaml packages/apps/kubernetes/values.yaml; do
549+
for path in packages/core/talos/images/talos/profiles/installer.yaml packages/core/installer/values.yaml packages/apps/kubernetes/values.yaml packages/apps/kubernetes-nodes/values.yaml; do
550550
git diff $PREV..$NEW -- "$path" | head -40
551551
done
552552
git diff --name-only $PREV..$NEW -- 'images/*/Dockerfile'

‎hack/check-worker-image-catalog-defaults.bats‎

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,39 @@ NODES_SCHEMA="$REPO_ROOT/packages/apps/kubernetes-nodes/values.schema.json"
152152
# -----------------------------------------------------------------------------
153153
# Third guard, and the premise the first one rests on. The catalog is keyed off
154154
# the kubernetes-nodes chart's `talos` defaults, but the parent kubernetes chart
155-
# carries its own copy of the same block since the Phase 2 split, and its own
156-
# values.yaml says to keep the two in sync. Nothing enforced that: the pool
157-
# chart's `make update` copies files/versions.yaml and images/kubectl.tag from
158-
# the parent and not the talos block, so a one-sided bump leaves the parent's
159-
# support-matrix guard reasoning about one Talos release while every worker boots
160-
# another — and the catalog check above would go on passing, because it only ever
161-
# reads one of the two files.
155+
# carries its own `talos.version` since the Phase 2 split, and its own values.yaml
156+
# says to keep the two in sync. Nothing enforced that: the pool chart's
157+
# `make update` copies files/versions.yaml and images/kubectl.tag from the parent
158+
# and not the talos block, so a one-sided bump leaves the parent's support-matrix
159+
# guard reasoning about one Talos release while every worker boots another — and
160+
# the catalog check above would go on passing, because it only ever reads one of
161+
# the two files. The version is the only Talos field the parent still declares.
162162

163163
PARENT_VALUES="$REPO_ROOT/packages/apps/kubernetes/values.yaml"
164164

165-
@test "the parent kubernetes chart and kubernetes-nodes agree on their Talos defaults" {
166-
for key in version schematicID imageFactoryURL installerRepository registryMirrors; do
167-
parent=$(yq ".talos.${key}" "$PARENT_VALUES")
168-
pool=$(yq ".talos.${key}" "$APP_VALUES")
169-
if [ "$parent" != "$pool" ]; then
170-
echo "talos.${key} differs between the two charts:" >&2
171-
echo " packages/apps/kubernetes/values.yaml: $parent" >&2
172-
echo " packages/apps/kubernetes-nodes/values.yaml: $pool" >&2
173-
echo "both are declared 'keep in sync' and a worker pool follows the second while the parent's support-matrix guard reads the first" >&2
165+
@test "the parent kubernetes chart and kubernetes-nodes agree on their Talos version" {
166+
parent=$(yq '.talos.version' "$PARENT_VALUES")
167+
pool=$(yq '.talos.version' "$APP_VALUES")
168+
if [ "$parent" != "$pool" ]; then
169+
echo "talos.version differs between the two charts:" >&2
170+
echo " packages/apps/kubernetes/values.yaml: $parent" >&2
171+
echo " packages/apps/kubernetes-nodes/values.yaml: $pool" >&2
172+
echo "both are declared 'keep in sync' and a worker pool follows the second while the parent's support-matrix guard reads the first" >&2
173+
return 1
174+
fi
175+
}
176+
177+
# A field the parent chart declares but no parent template reads is a setting that
178+
# does nothing: workers are KubernetesNodes pools since the Phase 2 split, and the
179+
# pool chart reads its own `talos`. The parent once carried the pool's image and
180+
# mirror fields for years after that, and an operator who set them got no error.
181+
@test "every talos field the parent kubernetes chart declares is read by one of its templates" {
182+
keys=$(yq '.talos | keys | .[]' "$PARENT_VALUES")
183+
[ -n "$keys" ] || { echo "packages/apps/kubernetes/values.yaml declares no talos block, or yq could not read it" >&2; return 1; }
184+
for key in $keys; do
185+
if ! grep -rqE "\.Values\.talos\.${key}([^A-Za-z0-9_]|\$)" "$REPO_ROOT/packages/apps/kubernetes/templates"; then
186+
echo "talos.${key} is declared in packages/apps/kubernetes/values.yaml but no template under packages/apps/kubernetes/templates reads .Values.talos.${key}" >&2
187+
echo "an operator who sets it gets no effect and no error; remove the field, or read it" >&2
174188
return 1
175189
fi
176190
done

‎hack/e2e-chainsaw/_lib/run-kubernetes.sh‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cozy_e2e_storage_class() {
1818
esac
1919
}
2020

21-
# talos_spec_block: emit the tenant Kubernetes CR `spec.talos` block with the Talos
21+
# talos_spec_block: emit the tenant KubernetesNodes CR `spec.talos` block with the Talos
2222
# OS image cache (imageFactoryURL) when the in-sandbox cache is up. Prints nothing
2323
# when it falls back to the public default, so the chart default applies.
2424
# Indented for insertion directly under `spec:` in the heredoc below.
@@ -5702,8 +5702,9 @@ YAML
57025702

57035703
# Point worker DataVolume imports at the in-sandbox Talos OS image cache when it
57045704
# is up, falling back to the public factory otherwise. Worker image pulls use
5705-
# the chart's public-registry default. Emitted right under spec: as
5706-
# `talos: { imageFactoryURL: ... }`, or nothing when the default applies.
5705+
# the chart's public-registry default. Emitted right under spec: of the
5706+
# KubernetesNodes pool below as `talos: { imageFactoryURL: ... }`, or nothing
5707+
# when the default applies. The Kubernetes CR takes no worker image field.
57075708
local talos_block
57085709
talos_block=$(talos_spec_block)
57095710

@@ -5714,7 +5715,6 @@ metadata:
57145715
name: "${test_name}"
57155716
namespace: tenant-test
57165717
spec:
5717-
${talos_block}
57185718
${oidc_block}
57195719
addons:
57205720
certManager:

‎hack/e2e-install-cozystack.bats‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
# Best-effort: never fail the suite on the band-aid. Remove once tenant workers
5050
# no longer bulk-pull the OS image from the public internet in CI.
5151
local sid ver
52-
sid=$(yq '.talos.schematicID' packages/apps/kubernetes/values.yaml 2>/dev/null)
53-
ver=$(yq '.talos.version' packages/apps/kubernetes/values.yaml 2>/dev/null)
52+
sid=$(yq '.talos.schematicID' packages/apps/kubernetes-nodes/values.yaml 2>/dev/null)
53+
ver=$(yq '.talos.version' packages/apps/kubernetes-nodes/values.yaml 2>/dev/null)
5454
if [ -z "$sid" ] || [ "$sid" = "null" ] || [ -z "$ver" ] || [ "$ver" = "null" ]; then
55-
echo "WARNING: could not read talos.schematicID/version from values.yaml — skipping mirror (fallback to public factory)"
55+
echo "WARNING: could not read talos.schematicID/version from packages/apps/kubernetes-nodes/values.yaml — skipping mirror (fallback to public factory)"
5656
return 0
5757
fi
5858
# The CiliumClusterwideNetworkPolicy in the manifest is intentionally NOT applied

‎hack/e2e-talos-image-cache.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# This Deployment fetches the image ONCE at e2e-install time with an aggressive
1515
# curl retry loop (decoupling the one flaky external fetch from the many
1616
# per-worker imports), then serves it locally over plain HTTP with range support.
17-
# Tenant `Kubernetes` CRs point `spec.talos.imageFactoryURL` at this Service
17+
# Tenant `KubernetesNodes` CRs point `spec.talos.imageFactoryURL` at this Service
1818
# (see hack/e2e-chainsaw/_lib/run-kubernetes.sh) so every worker imports from the
1919
# warm local copy instead of the public internet. Tenant namespaces run under a
2020
# default-deny Cilium egress installed by the tenant chart, whose allow rules cover
@@ -28,7 +28,7 @@
2828
# mirror can only help, never make CI worse.
2929
#
3030
# The __SCHEMATIC_ID__ / __TALOS_VERSION__ placeholders are substituted at apply
31-
# time by hack/e2e-install-cozystack.bats from packages/apps/kubernetes/values.yaml.
31+
# time by hack/e2e-install-cozystack.bats from packages/apps/kubernetes-nodes/values.yaml.
3232
#
3333
# CI band-aid, not a product artifact. The durable fix is the overridable
3434
# `talos.imageFactoryURL` chart value this manifest exercises; a self-hosted

‎hack/run-kubernetes-talos-spec_test.bats‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -----------------------------------------------------------------------------
33
# Unit tests for talos_spec_block in hack/e2e-chainsaw/_lib/run-kubernetes.sh
44
#
5-
# It is the composition point for the tenant Kubernetes CR's `spec.talos`: the
5+
# It is the composition point for the tenant KubernetesNodes CR's `spec.talos`: the
66
# Talos OS image cache contributes imageFactoryURL when available. The result is
77
# spliced into an unquoted heredoc directly under `spec:`, so an indentation slip
88
# does not fail this function -- it produces a CR the API rejects, and every
@@ -32,7 +32,7 @@ load test_helper
3232
# Splice a talos_spec_block result under `spec:` of a minimal CR and print the
3333
# document, so yq can be asked what the tenant apiserver would see.
3434
spec_doc() {
35-
printf 'apiVersion: apps.cozystack.io/v1alpha1\nkind: Kubernetes\nmetadata:\n name: t\nspec:\n%s\n host: ""\n' "$1"
35+
printf 'apiVersion: apps.cozystack.io/v1alpha1\nkind: KubernetesNodes\nmetadata:\n name: t\nspec:\n%s\n cluster: t\n' "$1"
3636
}
3737

3838
@test "no Talos image cache renders nothing, so the chart default applies" {
@@ -59,6 +59,6 @@ spec_doc() {
5959
# talos_spec_block writes imageFactoryURL by hand. If the chart ever renames
6060
# it, the CR would be rejected only at e2e time, and this file is the cheapest
6161
# place to notice.
62-
yq -e '.talos | has("imageFactoryURL")' packages/apps/kubernetes/values.yaml >/dev/null \
63-
|| { echo "packages/apps/kubernetes/values.yaml has no talos.imageFactoryURL; talos_spec_block would emit a key the chart rejects" >&2; exit 1; }
62+
yq -e '.talos | has("imageFactoryURL")' packages/apps/kubernetes-nodes/values.yaml >/dev/null \
63+
|| { echo "packages/apps/kubernetes-nodes/values.yaml has no talos.imageFactoryURL; talos_spec_block would emit a key the pool chart ignores" >&2; exit 1; }
6464
}

0 commit comments

Comments
 (0)