ci: cache kubeconform schemas instead of re-fetching every run - #22
Merged
Conversation
-schema-location default isn't bundled/offline - it's a remote URL pattern (raw.githubusercontent.com/yannh/kubernetes-json-schema), fetched fresh per resource kind on every single CI run, no caching. That's dozens of requests per run against a shared, heavily-used GitHub Actions IP range, and it's been hitting HTTP 429 rate limits often enough to fail both the helm and argocd-validate jobs outright. kubeconform has a -cache flag built in for exactly this. Paired with actions/cache to persist the directory across runs, schemas only need to be fetched from the network once (per kubernetes-version), not on every PR.
Helm template diffdiff -u --recursive --label base --label head base head
--- base
+++ head
@@ -218,7 +218,7 @@
app.kubernetes.io/managed-by: Helm
type: Opaque
data:
- SECRET_KEY_BASE: cXBFVUJwOWVMb0RKVWtqQ3JrUWZZV1REN3pyTXBEaml1RmtWaW10R3JlQ1BxQ1BRNGplNnFrSUlaVXZLOEdzWUF0N0tBeDJ6eXE3d3lMVERMMDhlWDFqZDZy
+ SECRET_KEY_BASE: UFVDWUtuZEtKME1XUU1Idk9JMTQ3OFIxdGV1dWRwWTNzVXVrM01PN1plam0wTTFmbUE4OUNHV0JwajFvd2F1SVVJN0toTGRMSG5tenVGTEplWHdBVENwbXEz
TOTP_VAULT_KEY: ZHN4dmJuM2p4RGQxNmF6MlFwc1g1QjhPK2xseGpRMlNKRTJpNUJ6eDM4ST0=
DATABASE_URL: cG9zdGdyZXM6Ly9wb3N0Z3Jlczpwb3N0Z3Jlc0BwbGF1c2libGUtYW5hbHl0aWNzLXBvc3RncmVzcWw6NTQzMi9wbGF1c2libGVfZGI=
CLICKHOUSE_DATABASE_URL: aHR0cDovL2NsaWNraG91c2U6cGFzc3dvcmRAcGxhdXNpYmxlLWFuYWx5dGljcy1jbGlja2hvdXNlOjgxMjMvcGxhdXNpYmxlX2V2ZW50c19kYg== |
…he hit actions/cache only creates the restored directory on a hit. On the first run for a given key it's a miss, so the dir never exists and -cache fails immediately with 'no such file or directory'.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the CI workflow to reduce kubeconform schema fetch failures (HTTP 429 rate limiting) by persisting kubeconform’s downloaded JSON schemas across workflow runs using kubeconform -cache plus actions/cache.
Changes:
- Add
actions/cachesteps to persist/tmp/kubeconform-cacheacross runs. - Create the cache directory before running kubeconform in both
helmandargocd-validatejobs. - Add
-cache /tmp/kubeconform-cacheto kubeconform invocations to reuse previously fetched schemas.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+37
to
+41
| - name: Cache kubeconform schemas | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | ||
| with: | ||
| path: /tmp/kubeconform-cache | ||
| key: kubeconform-schemas-v1.36.0 |
Comment on lines
+94
to
+98
| - name: Cache kubeconform schemas | ||
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | ||
| with: | ||
| path: /tmp/kubeconform-cache | ||
| key: kubeconform-schemas-v1.36.0 |
actions/cache caches are immutable per key - the fixed key only ever captured whatever schemas the first run needed, so any resource kind added later would hit the network on every run forever without ever getting persisted, contradicting the whole point of caching them. A per-run key (github.run_id) plus a restore-keys prefix lets each run start from the most recent cache and save its own snapshot forward, so the cache can actually grow as new resource kinds show up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while debugging PR #21's CI failures - both the
helmandargocd-validatejobs were failing withgiving up after 3 attempt(s)fetching schemas fromraw.githubusercontent.com/yannh/kubernetes-json-schema. Confirmed directly (curl against the exact failing URLs returned HTTP 429) - GitHub Actions' shared runner IP range is rate-limited there, and it's independent of anything in these PRs' actual changes.-schema-location defaultisn't bundled/offline like the name suggests - it's a remote URL pattern, fetched fresh per resource kind on every single run with zero caching. A chart like cert-manager alone needs ~15 distinct schema files (ServiceAccount, ClusterRole, Deployment, Job, webhooks, etc.), andargocd-validatefetches more per ApplicationSet. That's a lot of requests per PR, against an IP range shared with every other repo's CI on GitHub.Fix:
kubeconform -cache <dir>, paired withactions/cacheto persist that directory across runs. Schemas only need to come from the network once perkubernetes-version(1.36.0 here) - every run after that reuses the cache.