Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

OCIRepository: pick the Helm chart layer automatically when the first layer is a provenance file

Đang mở Phù hợp với người mới
#2,198 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
backend, infrastructure

Hướng nghiên cứu

Bắt đầu tại internal/controller/ocirepository_controller.go, ở selectLayer, đặc biệt là nhánh default, và đọc các bài kiểm thử chọn layer hiện có. Thêm một test artifact có layer provenance ở vị trí đầu tiên và xác nhận rằng layer nội dung chart được chọn khi không có selector nào được đặt. Hoàn thành khi hành vi mặc định xử lý thứ tự đó và các selector layer tường minh vẫn được ưu tiên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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]:

https://github.com/fluxcd/source-controller/blob/effd29b2da5be2ffc4fa99d99a4b2e87f08e5e84/internal/controller/ocirepository_controller.go#L594-L632

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 type application/vnd.cncf.helm.chart.provenance.v1.prov (registry.ProvLayerMediaType in 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+json and their layers are never .prov.
  • An explicit layerSelector keeps 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.

Ngôn ngữ chính
Go
Star
285
Fork
259
Merge trung bình
2 ngày 14 giờ
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fluxcd/source-controller

Tất cả issue của fluxcd/source-controller

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.