[wip]OPRUN-4727: Add labels to relatedImages in olm.bundle - #2089
hongkailiu wants to merge 2 commits into
Conversation
Add the optional `labels` field to declcfg.RelatedImage so operator authors can classify related images by product feature. The labels are carried through the model, the declcfg<->model conversions, and the gRPC serving path, so they survive `opm render`, `opm serve`, and a render/validate round-trip. `opm validate` checks the label keys and values against the Kubernetes label syntax. The check lives in Bundle.Validate rather than RelatedImage.Validate: the latter is still not called during bundle validation because production catalogs contain related images with an empty image reference, and enabling it wholesale would start rejecting them. The field is optional and additive: bundles without labels serialize and validate exactly as before, and an older opm ignores the field. For dev's purpose before operator-framework/api#524 (OPRUN-4764) gets in, github.com/operator-framework/api is replaced with that pull's branch. The replace directive should be dropped once the pull merges and a release carries RelatedImage.Labels. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Hongkai Liu <hongkailiu@users.noreply.github.com>
|
@hongkailiu: This pull request references OPRUN-4727 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe change adds optional labels to related images, preserves them across CSV, model, and declarative configuration conversions, validates Kubernetes label syntax, and verifies ChangesRelated image labels
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant CSV
participant getRelatedImages
participant ModelRelatedImage
participant DeclcfgRelatedImage
participant OpmRender
CSV->>getRelatedImages: Parse relatedImages labels
getRelatedImages->>ModelRelatedImage: Preserve label maps
ModelRelatedImage->>DeclcfgRelatedImage: Copy labels
OpmRender->>DeclcfgRelatedImage: Render bundle related images
DeclcfgRelatedImage-->>OpmRender: Return labeled and unlabeled entries
Merge Risk: ⚪ Minimal · up to The render test’s expected related-image list matches this invocation path; no actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 11 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Operator authors can label the related images of a bundle, typically to say which product feature each image belongs to. Add a `selectors` field to each operator package of the ImageSetConfiguration so that disconnected users can leave the images of the features they do not use behind. A related image is mirrored when it carries no label at all, or when at least one selector of its package matches its labels. The requirements within a selector are ANDed and the selectors of a package are ORed, following the Kubernetes label selector semantics. A package with no selector mirrors only the images without labels, so catalogs that carry no label are mirrored exactly as before. The selection happens in handleRelatedImages, where the labels of the image and the package of its bundle are both at hand, which also keeps the images left out from reaching the copy image schema map. Every image left out is logged for supportability. All three workflows go through collectOperator, so m2m, m2d and d2m behave alike. Malformed selectors are rejected when the configuration is loaded rather than halfway through a mirror. The labels are read from declcfg.RelatedImage.Labels, which is not released yet, hence the replace directives pointing at the branches of operator-framework/operator-registry#2089 and operator-framework/api#524. The former requires go 1.26.5, which bumps the go directive of this module. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
$ git remote -v
origin https://github.com/operator-framework/operator-sdk.git (fetch)
origin https://github.com/operator-framework/operator-sdk.git (push)
$ git --no-pager log --pretty=oneline -1
299157a814e674f8f40d1b91ee77d64a90e850de (HEAD -> local-test, origin/master, origin/HEAD) Bump actions/setup-go from 6 to 7 (#7115)
$ git --no-pager diff
diff --git a/testdata/go/v4/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml b/testdata/go/v4/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml
index e11f4c61..e8e79f0f 100644
--- a/testdata/go/v4/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml
+++ b/testdata/go/v4/memcached-operator/bundle/manifests/memcached-operator.clusterserviceversion.yaml
@@ -25,6 +25,13 @@ metadata:
name: memcached-operator.v0.0.1
namespace: placeholder
spec:
+ relatedImages:
+ - name: quay.io/redhat-cop/kube-rbac-proxy
+ image: quay.io/redhat-cop/kube-rbac-proxy@sha256:c68135620167c41e3d9f6c1d2ca1eb8fa24312b86186d09b8010656b9d25fb47
+ labels:
+ aaa: "true"
+ - name: quay.io/redhat-cop/namespace-configuration-operator
+ image: quay.io/redhat-cop/namespace-configuration-operator@sha256:49ed7d6155342adaa2b12fd80c6761c3081d8e6149d187cb7ff91a247cdf2e7a
apiservicedefinitions: {}
customresourcedefinitions:
owned:and $ git --no-pager log --pretty=oneline -1
35aa11c2c1f1bb050d5fc96dfb6f07c2475eca41 (HEAD -> OPRUN-4727, hongkailiu/OPRUN-4727) OPRUN-4727: Add labels to relatedImages in olm.bundle
$ make bin/opm
$ ./bin/opm render /Users/hongkliu/repo/operator-framework/operator-sdk/testdata/go/v4/memcached-operator/bundle | jq .relatedImages
[
{
"name": "",
"image": "quay.io/example/memcached-operator:v0.0.1"
},
{
"name": "quay.io/redhat-cop/kube-rbac-proxy",
"image": "quay.io/redhat-cop/kube-rbac-proxy@sha256:c68135620167c41e3d9f6c1d2ca1eb8fa24312b86186d09b8010656b9d25fb47",
"labels": {
"aaa": "true"
}
},
{
"name": "quay.io/redhat-cop/namespace-configuration-operator",
"image": "quay.io/redhat-cop/namespace-configuration-operator@sha256:49ed7d6155342adaa2b12fd80c6761c3081d8e6149d187cb7ff91a247cdf2e7a"
}
] |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2089 +/- ##
==========================================
+ Coverage 59.53% 59.75% +0.22%
==========================================
Files 99 99
Lines 8157 8177 +20
==========================================
+ Hits 4856 4886 +30
+ Misses 2726 2715 -11
- Partials 575 576 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Mechanize the manual check from the pull request: render a bundle directory whose ClusterServiceVersion labels its relatedImages, and assert the labels survive into the olm.bundle blob. The spec execs the opm built by `make build` rather than driving the suite's in-process cobra command, because `opm render` writes to os.Stdout directly and calls log.Fatal on error, so opm.SetOut() would neither capture the output nor survive a failure. The fixture is a minimal registry+v1 bundle with one labeled and one unlabeled related image, so the test also covers that an absent labels field stays absent. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Hongkai Liu <hongkailiu@users.noreply.github.com>
Add the optional
labelsfield to declcfg.RelatedImage so operator authors can classify related images by product feature. The labels are carried through the model, the declcfg<->model conversions, and the gRPC serving path, so they surviveopm render,opm serve, and a render/validate round-trip.opm validatechecks the label keys and values against the Kubernetes label syntax. The check lives in Bundle.Validate rather than RelatedImage.Validate: the latter is still not called during bundle validation because production catalogs contain related images with an empty image reference, and enabling it wholesale would start rejecting them.The field is optional and additive: bundles without labels serialize and validate exactly as before, and an older opm ignores the field.
For dev's purpose before operator-framework/api#524 (OPRUN-4764) gets in, github.com/operator-framework/api is replaced with that pull's branch. The replace directive should be dropped once the pull merges and a release carries RelatedImage.Labels.
Description of the change:
Motivation for the change:
Reviewer Checklist
/docsSummary by CodeRabbit
New Features
Validation