Skip to content

fix: make update-platforms.py safe and self-contained; add catalog checks + CI#146

Open
lfrancke wants to merge 9 commits into
mainfrom
fix/update-platforms-script
Open

fix: make update-platforms.py safe and self-contained; add catalog checks + CI#146
lfrancke wants to merge 9 commits into
mainfrom
fix/update-platforms-script

Conversation

@lfrancke

Copy link
Copy Markdown
Member

What & why

Running scripts/update-platforms.py produced a ~450-line diff and corrupted the IONOS versions. Root causes fixed here, plus the catalog is now safe to regenerate from the script.

Fixes

  • IONOS parsing (data corruption). ionosctl k8s version list --output json returns a JSON-encoded string of a Go slice ("[1.34.2 1.33.3 …]"), not an array. The script json.loads()'d it and iterated it character-by-character, turning digits into fake versions and wiping the IONOS entry (this is why 878c5c1 set versions: [] and had to be reverted). Now parsed into a real list and validated.
  • The script now owns the YAML layout. Output was previously reformatted by whichever yq happened to be installed (mikefarah vs the python/jq wrapper). A _CatalogDumper now emits the canonical style directly (indented sequences, double-quoted numeric versions, no anchors) with no external formatter. Output is deterministic — re-running on an unchanged catalog produces no diff (verified idempotent).
  • No more fabricated cloud entries. Unknown Replicated distributions are no longer auto-created with a hardcoded r1.xlarge (invalid for cloud distros); the script warns and defers to a human.
  • catalog.py robustness. read_platforms() no longer indexes ["platforms"] before its own missing-key guard (it raised KeyError); it now mirrors read_providers().

Additions

  • scripts/check-catalog.py — validates that platforms.yaml and operator-tests.yaml agree (referenced platforms exist, providers are known; warns on unused platforms). CI-ready.
  • .github/workflows/checks.yml — the repo's first PR-triggered CI: ruff over scripts/ + apps/, and the catalog check.
  • Removed the obsolete one-off add-arm-platforms.py.
  • README documents how to run the scripts and that platforms.yaml must not be hand-edited.

Verification

  • IONOS now resolves to real versions (1.34.2 / 1.33.3 / 1.32.7).
  • Full run: diff reduced from 457 → 85 lines, every line a real version bump or the one-time OpenShift anchor→literal expansion.
  • Second run is byte-identical (idempotent). ruff clean; check-catalog.py passes.

Follow-up PRs (security blockers in the test runner, correctness fixes, Harbor GC safety, hardening, hygiene) are tracked separately.

lfrancke added 9 commits July 14, 2026 21:58
The script had two problems that made it unsafe to run, so the catalog
was maintained by hand instead (see the reverted 878c5c1 and the manual
7ce43a2 "do not delete ionos versions").

- IONOS versions were corrupted on every run. `ionosctl k8s version list
  --output json` does not return a JSON array; it returns a JSON-encoded
  string of a Go slice, e.g. "[1.34.2 1.33.3 1.32.7]". The script did
  json.loads() and then iterated the resulting string character by
  character, turning the digits into fake versions (7, 6, 5, ...) and
  wiping the real IONOS entry. Parse the slice literal into a real list
  and validate the result looks like versions.

- The whole file was reformatted on every run because output depended on
  which `yq` happened to be installed (mikefarah vs the python/jq wrapper)
  and PyYAML's raw layout differs from the committed style. The script now
  owns the layout itself via _CatalogDumper (indented block sequences,
  double-quoted numeric versions, no anchors) and no longer shells out to
  yq. Output is deterministic and re-running on an unchanged catalog
  produces no diff.

Also stop auto-creating catalog entries for unknown Replicated
distributions with a hardcoded Replicated instance type (invalid for
cloud distributions); warn and let a human add them with the right spec.

README documents how to run the script and that platforms.yaml must not
be hand-edited.
Regenerated with the fixed script. Changes:
- Kubernetes version bumps across kind, k3s, rke2, EKS, AKS, GKE, OKE.
- IONOS corrected to real versions (1.34.2, 1.33.3, 1.32.7).
- OpenShift version list written literally on both x86 and ARM entries
  (the &id001/*id001 anchor is gone; the script owns the format).
read_platforms indexed ["platforms"] before the guard that was meant to
catch a missing key, so a malformed platforms.yaml raised KeyError
instead of the intended logged failure. It also loaded the file twice.
Mirror read_providers: load once, guard, then assign.
platforms.yaml and operator-tests.yaml are maintained separately and can
drift apart; today that only surfaces mid-test as "platform does not
exist". This CI-friendly check verifies every platform referenced by a
test exists, every platform has a known provider, and warns about
platforms no test uses. Documented in the README.
The "keep at most 5 versions" limit was duplicated (and inconsistently
expressed) in two places. Replace with MAX_VERSIONS_PER_PLATFORM.
No behaviour change.
The repo had no push/PR-triggered CI (all workflows are workflow_dispatch).
Add a lightweight workflow that runs ruff over scripts/ and apps/ and
executes check-catalog.py, so catalog drift and lint regressions are
caught on every pull request.
Match PR #144: top-level permissions: {} with an explicit per-job
contents: read, and persist-credentials: false on checkout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant