OCIRepository: pick the Helm chart layer automatically when the first layer is a provenance file
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go
- Domain
- backend, infrastructure
Research direction
Start in internal/controller/ocirepository_controller.go at selectLayer, especially the default branch, and read the existing layer selection tests. Add a test artifact with the provenance layer first and confirm the chart content layer is selected when no selector is set. Done means the default handles that order while explicit layer selectors retain precedence.
Written by the indexing model from the issue text.
Description
How we ran into it
We were bootstrapping a new cluster and reused the CloudNativePG setup from another cluster that has been running for two months: an OCIRepository for oci://ghcr.io/cloudnative-pg/charts/cloudnative-pg pinned to 0.29.0 plus a HelmRelease with chartRef. The only change was a patch bump of the tag to 0.29.1. The source immediately went to:
failed to extract layer contents from artifact: requires gzip-compressed body: gzip: invalid header
Both versions are signed and carry the same two layers. The only difference is their order:
0.29.0
application/vnd.cncf.helm.chart.content.v1.tar+gzip 201392
application/vnd.cncf.helm.chart.provenance.v1.prov 1625
0.29.1
application/vnd.cncf.helm.chart.provenance.v1.prov 1625
application/vnd.cncf.helm.chart.content.v1.tar+gzip 205129
So a patch release of an upstream chart broke a config that had been working for two months, and nothing on our side changed.
Current behaviour
Without spec.layerSelector, selectLayer always takes layers[0]:
When layers[0] is the .prov layer, extraction always fails. The documented fix is to set layerSelector.mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip, and that does fix it. Still, it keeps coming up as a bug report, because signed charts (Helm 4, cosign v3) put the provenance layer first and the error doesn't point to the cause:
- #1847: dynatrace-operator 1.6.0
- #1932: traefik 37.2.0
- fluxcd/flux2#5788: cloudnative-pg/plugin-barman-cloud
In fluxcd/flux2#5788 the answer to "why isn't this the default?" was that defaults can't change in GA software and that OCIRepository is meant for any artifact type, first of all Flux's own. I agree with both points. I think the change below doesn't conflict with either of them.
Proposal
Only touch the default: branch, i.e. the case where no layer selector is set:
- if
layers[0]has media typeapplication/vnd.cncf.helm.chart.provenance.v1.prov(registry.ProvLayerMediaTypein Helm), - then pick the first layer with
application/vnd.cncf.helm.chart.content.v1.tar+gzip(registry.ChartLayerMediaType) instead, - and leave the operation at the default (
extract), same as today.
Alternatively, the check could key off the manifest config media type application/vnd.cncf.helm.config.v1+json. Either is fine with me; the provenance check is the narrower one.
Why this is safe for existing users
- Charts that work today have the chart layer first. They hit exactly the same layer with the same operation, so artifact, revision and digest are identical. Nothing changes for them.
- Charts with the provenance layer first fail with a hard error today. That is the only case whose behaviour changes, and it changes from "always broken" to "works". It's hard to imagine anyone relying on that error.
- Flux artifacts and any other non-Helm artifacts are untouched: their config is
application/vnd.cncf.flux.config.v1+jsonand their layers are never.prov. - An explicit
layerSelectorkeeps full precedence, as today.
It is a trivial change: a few lines in selectLayer plus a test with a provenance-first artifact. No API change, no new field, no change to existing artifacts. I'm happy to send the PR if the maintainers agree with the approach.
Out of scope
The _ ↔ + tag mapping for ref.semver (convertOCIToSemVerTag) is also tied to layerSelector.mediaType, and it runs before the manifest is fetched, so autodetection can't cover it. Users with semver ranges over tags like 1.2.3_build.1 would still need the explicit selector. I'd keep that out of this issue on purpose.
- Dominant language
- Go
- Stars
- 285
- Forks
- 259
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fluxcd/source-controller
-
Improve documentation on debugging the controller locallyMay be free again @Bryandero98 claimed this 37 days ago, and no pull request is open. Openarea/docs good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
fluxcd/source-controller#666 · 2 comments ·
Maintainers usually reply within 1 day
-
area/oci enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
fluxcd/source-controller#2180 ·
Maintainers usually reply within 1 day
-
`OCIRepository`/cosign verification: support TSA-only trusted roots (no transparency log) for private Sigstore instances like GitHub Artifact AttestationsPossibly taken @stealthybox claimed this 150 days ago. Openarea/oci area/security enhancement
Difficulty 4/5 3-5 days Newbie friendliness 68/100
fluxcd/source-controller#2167 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fluxcd/source-controller#2150 ·
Maintainers usually reply within 1 day
-
GitRepository `.spec.ref.commit` + `.spec.ref.branch` does not shallow clone, contrary to the docsOpen
Difficulty 5/5 Over a week Newbie friendliness 42/100
fluxcd/source-controller#2146 · 2 comments ·
Maintainers usually reply within 1 day
All issues in fluxcd/source-controller
Similar issues
-
compress: block buffers get re-zeroed on every call, and the zeroing is immediately overwrittenOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ch-go#1218 ·
Maintainers usually reply within 13 days
-
effort:s impact:low raised-by:reviewer risk:low
Difficulty 1/5 Under an hour Newbie friendliness 84/100
medici-finance/assay#4251 · 1 comment ·
Maintainers usually reply within 1 day
-
automation models
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
golang-migrate/migrate#1457 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day