mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-09 05:25:14 +09:00
Pinning the frozen source to a digest written into the migration picks one release for every cluster, and v1.6.0 is not even the last one that ships http-cache: v1.6.1 through v1.6.3 and v1.7.0-alpha.1 all do, and 1.6 patch releases may keep doing so. A cluster on any of those would be rolled back to an older chart by the upgrade that was meant to leave its instances alone, and an air-gapped mirror resolves the constant only if someone mirrored that exact manifest. The hook runs before the upgrade re-points cozystack-packages, so the live object still names the release the instances render from, in whatever registry the operator serves it from and with whatever pull secret and verification they configured. Reading the digest off it makes the freeze a no-op by construction and needs no knowledge of which tag was last. spec.ref.digest is used when the installer pinned one; a tag or semver ref goes through status.artifact.revision, whose digest half is the manifest digest. status.artifact.digest is the checksum of the downloaded tarball and cannot stand in. A source with neither has nothing to freeze on and the migration stops there. The copy also carries the no-delete label the platform chart puts on the original, because it is the only chart source those instances have left. The tenant grant travels with the freeze as well. cozy:tenant:admin:base enumerates the apps.cozystack.io resources a tenant owner may write, and an application that has left the catalog has no business in that list: the next sweep over it takes the entry as dead config, and the failure is silent and remote, a Forbidden for the one person who still needs to remove what they have. The chart drops httpcaches, and a cluster that freezes gets a ClusterRole under the tenant admin aggregation label instead, applied before the upgrade drops the rule so the access never lapses and carrying the verb set the chart had so nothing changes for the owner. A cluster with no instance is granted nothing. The Package delete on the no-instance path has to block. The operator reconciles off an informer cache, so a reconcile in flight against the pre-delete entry re-creates the release it owns, and with it the ApplicationDefinition and the Helm storage the following lines remove. Returning immediately made the ordering a property of the command log rather than of the cluster. The preset check's SIGPIPE note named http-cache-rd as its example of a large enum, and that chart goes away here; kubernetes-rd carries the same enums. Numbered 58 rather than 57: main already carries a migration 57, the SeaweedFS volume-size-limit one, and its targetVersion is already 58. The whole shape of this retirement was worked out here rather than anywhere reusable, so docs/deprecating-applications.md writes it down as a procedure: how to pick between migrating onto a successor and freezing, what the prune takes with it, and what the migration owes a cluster on each branch. The next application to go should not have to rediscover it. Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
73 lines
3.0 KiB
Bash
Executable File
73 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Verify every ApplicationDefinition in packages/system/*-rd/cozyrds/*.yaml
|
|
# that defines a resourcesPreset enum carries the full set of 40
|
|
# instance-type names plus the 7 legacy aliases. Catches the regression
|
|
# where one chart's Makefile forgets to invoke hack/update-crd.sh and the
|
|
# RD schema drifts from the chart's values.schema.json.
|
|
set -euo pipefail
|
|
|
|
EXPECTED=(
|
|
t1.nano t1.micro t1.small t1.medium t1.large t1.xlarge t1.2xlarge t1.4xlarge
|
|
c1.nano c1.micro c1.small c1.medium c1.large c1.xlarge c1.2xlarge c1.4xlarge
|
|
s1.nano s1.micro s1.small s1.medium s1.large s1.xlarge s1.2xlarge s1.4xlarge
|
|
u1.nano u1.micro u1.small u1.medium u1.large u1.xlarge u1.2xlarge u1.4xlarge
|
|
m1.nano m1.micro m1.small m1.medium m1.large m1.xlarge m1.2xlarge m1.4xlarge
|
|
nano micro small medium large xlarge 2xlarge
|
|
)
|
|
|
|
fail=0
|
|
for f in packages/system/*-rd/cozyrds/*.yaml; do
|
|
schema=$(yq -r '.spec.application.openAPISchema // ""' "$f")
|
|
if [ -z "$schema" ]; then
|
|
continue
|
|
fi
|
|
# Pull every resourcesPreset enum out of the schema. Key on the JSON
|
|
# path ending in "resourcesPreset" rather than a description heuristic,
|
|
# so an unrelated field with "preset" in its description does not match.
|
|
enums=$(printf '%s' "$schema" | jq -r '
|
|
[paths(type == "object" and has("enum")) as $p
|
|
| select($p[-1] == "resourcesPreset")
|
|
| getpath($p).enum[]]
|
|
| .[]
|
|
' 2>/dev/null || true)
|
|
if [ -z "$enums" ]; then
|
|
continue
|
|
fi
|
|
missing=()
|
|
for want in "${EXPECTED[@]}"; do
|
|
# -F: literal match so the `.` in t1.nano does not match any character.
|
|
# here-string, not a pipe: a `printf ... | grep -q` pipeline SIGPIPEs the
|
|
# printf when grep matches early and exits, and under `set -o pipefail` that
|
|
# 141 makes the whole pipeline read as failure — a false "missing" for a
|
|
# preset that is present (hit on the larger enums, e.g. kubernetes-rd).
|
|
if ! grep -Fqx -- "$want" <<<"$enums"; then
|
|
missing+=("$want")
|
|
fi
|
|
done
|
|
if [ ${#missing[@]} -gt 0 ]; then
|
|
echo "FAIL: $f resourcesPreset enum missing: ${missing[*]}" >&2
|
|
fail=1
|
|
fi
|
|
done
|
|
|
|
if [ "$fail" -ne 0 ]; then
|
|
echo "Some RD schemas are out of sync with the canonical preset set." >&2
|
|
echo "Run 'make generate' inside the affected chart directory." >&2
|
|
exit 1
|
|
fi
|
|
echo "All RD schemas carry the full 47-preset enum."
|
|
|
|
# Also reject hardcoded legacy preset literals in chart template files.
|
|
# New code should use instance-type names; legacy aliases exist only for
|
|
# user-supplied values in existing HelmRelease and app CR specs.
|
|
echo "Checking chart templates for hardcoded legacy preset literals..."
|
|
legacy_hits=$(grep -rEn 'defaultingSanitize.*\(list "(nano|micro|small|medium|large|xlarge|2xlarge)"' \
|
|
packages/apps packages/extra packages/system 2>/dev/null || true)
|
|
if [ -n "$legacy_hits" ]; then
|
|
echo "FAIL: hardcoded legacy preset literals in chart templates:" >&2
|
|
echo "$legacy_hits" >&2
|
|
echo "Replace with the instance-type form from docs/operations/resource-presets.md." >&2
|
|
exit 1
|
|
fi
|
|
echo "No hardcoded legacy preset literals in chart templates."
|