Repository navigation
Fetch cached OCI charts without contacting the registry - #307
Conversation
abrisco
left a comment
There was a problem hiding this comment.
Thanks! This looks good but I was wondering, would it make sense to save the data to facts if a sha256 isn't provided to further reduce fetches and to kinda auto-fix gaps?
|
@abrisco thanks. I'd lean towards doing that as a stacked PR as seems like a larger change.
|
A Helm chart's OCI layer is the chart .tgz, so when `sha256` is set its blob is `blobs/sha256:<sha256>`. Try that blob first without a token, so a chart in the repository cache needs no token, manifest or blob request. On a miss, fall back to the token, manifest and blob requests as before. CI fetched every OCI test chart from its registry on each job, and the concurrent anonymous requests tripped ECR's rate limit (429). Also fail with the "is not a Helm chart package" message, rather than a key error, for a manifest without a `config` field.
4d30912 to
b8a2d8f
Compare
CI often fails with
GET returned 429 Too Many Requestsfrompublic.ecr.aws, fetching the Karpenter chart fortests/with_external_deps.Every job sends
helm_import's OCI requests to the registry, even with the repository cache restored. Fetching anoci://chart makes three requests: a token, the manifest by tag, and the chart blob. Only the blob has a checksum, so it is the only one the repository cache can serve. Eleven jobs start together and make the same anonymous requests, which is enough to trip ECR's rate limit.Change
A Helm chart's OCI layer is the chart
.tgz, so whensha256is set its blob isblobs/sha256:<sha256>.helm_import_repositorynow tries that blob first, without a token. If the repository cache has it, the fetch makes no request to the registry. Otherwise it falls back to the token, manifest and blob requests as before. A chart withoutsha256is fetched as before.All four OCI test charts already set
sha256, so the test dependencies do not change. Their blobs have always had checksums, so the CI repository cache already holds them. In this PR's CI run, none of the 13 jobs printed a failed download: a cache miss on ECR, Docker Hub or GHCR would print a401warning, so those three charts came from the cache. Quay serves the blob without a token, so the log cannot show this for cert-manager.On a cache miss the first blob request has no token, and a registry that needs one answers
401. Bazel prints oneWARNING: Download from ... failedline for it, then the fetch continues as before. ECR, Docker Hub and GHCR do this; Quay serves the blob without a token.A manifest without a
configfield, such as an index, now fails with the existing "is not a Helm chart package" message instead of a key error.Testing
--repository_disable_downloadand--repo_contents_cache=(so the rule runs on Bazel 9),bazel fetch --repo=succeeds for all four on Bazel 9.3.0, and for Karpenter and Grafana on 7.7.1. The same fetch onmainfails at the token request inimport_authn.bzl.bazel test //...and--config=stricton macOS with Bazel 9.3.0 and 7.7.1: 65 pass, 3 skipped (the Linux-onlywith_image_deps_imgtests).429from any registry.