Skip to content

promoted-image-governor openshift mapping pullspec styles#5184

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
deepsm007:governor-openshift-mapping-pullspec
May 18, 2026
Merged

promoted-image-governor openshift mapping pullspec styles#5184
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
deepsm007:governor-openshift-mapping-pullspec

Conversation

@deepsm007
Copy link
Copy Markdown
Contributor

@deepsm007 deepsm007 commented May 14, 2026

/cc @openshift/test-platform

promoted-image-governor: Use quay-proxy-style source pullspecs in mapping generation and tighten error wrapping

Component affected:

  • promoted-image-governor — the CLI that generates OpenShift image mapping files used for mirroring images (used by CI and release workflows).

What changed (practical impact for CI users/operators):

  • generateMappings now computes source pullspecs using the quay-proxy helper (api.QuayImageReference) instead of composing a legacy registry/path string. Generated mapping keys in tests now use quay-proxy./openshift/... as the "src" prefix. This means the mapping generator will emit source pullspecs that route through the CI quay-proxy/cache in the updated cases, aligning generated mappings with the proxied pull-through style used by CI.
  • mirroredTagsByReleaseController now wraps client.Get errors with %w when returning errors, improving error propagation so callers can inspect underlying errors.
  • No exported/public API surface changes were introduced.

Why this matters:

  • Mapping files produced by this tool will reference source images via the quay-proxy style where applicable, which routes pulls through the CI pull-through cache — useful for environments that rely on the CI proxy/cache. Operators should expect generated mapping keys and source pullspecs to reflect the proxied format in the updated code paths/tests.
  • Improved error wrapping makes diagnosing client.Get failures easier for callers of mirroredTagsByReleaseController.

Tests and validation:

  • Tests were updated to expect the proxied quay-proxy source pullspec prefix in generated mappings.
  • A redundant init() test registration block was removed.

Files with key changes:

  • cmd/promoted-image-governor/main.go — mapping generation now uses quay-proxy helper for source pullspecs and improved error wrapping in mirroredTagsByReleaseController.
  • cmd/promoted-image-governor/main_test.go — updated expected mappings to use quay-proxy source pullspecs and test cleanup.

No configuration schema additions (e.g., no new source_pullspec_style field) or other user-facing flags were added in this change.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci Bot requested a review from a team May 14, 2026 23:30
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 8816fc8a-fa23-4bf0-8354-3cb7b8fbe5cf

📥 Commits

Reviewing files that changed from the base of the PR and between 32195e7 and 152394e.

📒 Files selected for processing (2)
  • cmd/promoted-image-governor/main.go
  • cmd/promoted-image-governor/main_test.go

📝 Walkthrough

Walkthrough

Wraps client Get errors with %w and replaces legacy fmt-based source pullspec construction by calling api.QuayImageReference using mappingConfig.SourceNamespace and the promoted tag. Tests updated to expect quay-proxy-style source pullspecs and a duplicated init() was removed.

Changes

Pullspec and tests updates

Layer / File(s) Summary
Implementation: error wrapping and source ref generation
cmd/promoted-image-governor/main.go
Wrap client.Get errors with %w; generateMappings now computes source pullspec via api.QuayImageReference using mappingConfig.SourceNamespace and the promoted tag instead of fmt.Sprintf legacy formatting.
Tests: expected pullspecs and cleanup
cmd/promoted-image-governor/main_test.go
TestGenerateMappings expected mapping keys and duplicate-destination error messages updated to use quay-proxy.<source-registry-domain>/openshift/ci:... source pullspecs; removed duplicated init() function.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Go Error Handling ⚠️ Warning Two error handling violations found: (1) loadMappingConfig line 143 doesn't wrap os.ReadFile error with %w; (2) deleteTagsOnBuildFarm line 368 omits error wrapping for client.Delete failure. Add %w wrapping: line 143 should use fmt.Errorf("failed to read file: %w", err); line 368 should include error in message with %w.
Test Coverage For New Features ⚠️ Warning mirroredTagsByReleaseController lacks test coverage for the error wrapping change. generateMappings is properly tested with updated expectations, but the error handling modification is untested. Add a unit test for mirroredTagsByReleaseController that verifies error wrapping behavior when client.Get fails, or document why error-handling-only changes don't require test coverage.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: updates to pullspec styles in the promoted-image-governor's OpenShift mapping logic, moving from legacy fmt.Sprintf to api.QuayImageReference.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All 8 test case names in main_test.go are static and descriptive. No dynamic content (UUIDs, timestamps, pod/node names, IPs) found. Tests use Go table-driven pattern, not Ginkgo.
Test Structure And Quality ✅ Passed The check requires reviewing Ginkgo tests. The modified test file uses standard Go testing package, not Ginkgo. No Ginkgo tests are present in this PR.
Microshift Test Compatibility ✅ Passed No Ginkgo e2e tests are added. PR modifies promoted-image-governor tool and its standard Go unit tests (testing.T). Custom check for MicroShift test compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests are present in this PR. Changes are to cmd/promoted-image-governor/ containing standard Go unit tests, not Ginkgo e2e tests. Check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The PR modifies a CLI tool, not a deployment manifest or operator. No scheduling constraints, affinity rules, or topology assumptions are introduced. Check not applicable.
Ote Binary Stdout Contract ✅ Passed PR introduces no new stdout writes. Changes only include error wrapping, pullspec refactoring, and test updates. Pre-existing tabwriter calls to os.Stdout remain unchanged.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR modifies only unit tests using Go's standard testing framework, not Ginkgo e2e tests. The custom check is not applicable to non-Ginkgo tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
cmd/promoted-image-governor/main.go (1)

230-236: ⚡ Quick win

Add field-level docs for SourcePullspecStyle accepted values and default behavior.

OpenshiftMappingConfig.SourcePullspecStyle is exported but undocumented. A short field comment with allowed values will prevent config misuse.

As per coding guidelines "**/*.go: Ensure Go documentation on functions, classes, and fields are written properly".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/promoted-image-governor/main.go` around lines 230 - 236, Add a Go doc
comment for the exported field SourcePullspecStyle on the OpenshiftMappingConfig
struct describing the accepted string values (e.g., "legacy", "ocp", or whatever
the code expects), the semantics of each value, and the default behavior when
the field is empty/omitted; place the comment immediately above the
SourcePullspecStyle field so godoc/tools pick it up and users of
OpenshiftMappingConfig can see the allowed values and default.
cmd/promoted-image-governor/main_test.go (1)

244-262: ⚡ Quick win

Add a compatibility test for empty style fallback to quay-proxy.

Please add one case where SourcePullspecStyle is empty and SourceRegistry == api.QCIAPPCIDomain, asserting the same quay-proxy source format. This locks the intended backward-compatible behavior for existing mapping consumers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/promoted-image-governor/main_test.go` around lines 244 - 262, Add a new
table test entry in main_test.go mirroring the "source_pullspec_style
quay-proxy" case but with OpenshiftMappingConfig.SourcePullspecStyle set to an
empty string and SourceRegistry set to api.QCIAPPCIDomain; keep promotedTags and
Images the same and assert the expected mapping (the "mapping_origin_4_8" key
mapping to "quay-proxy.ci.openshift.org/openshift/ci:origin_4.8_bar" ->
"quay.io/openshift/origin-bar:4.8") so the test verifies that an empty
SourcePullspecStyle falls back to quay-proxy behavior for api.QCIAPPCIDomain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/promoted-image-governor/main.go`:
- Around line 238-250: The openshiftMappingSourcePullSpec currently silently
falls back for unknown mappingConfig.SourcePullspecStyle values; change it to
validate allowed styles and surface an error: update
openshiftMappingSourcePullSpec to return (string, error), check
mappingConfig.SourcePullspecStyle (normalized) against the allowed set
("registry-path"/"registry_path", "quay-proxy"/"quay_proxy", or empty only when
mappingConfig.SourceRegistry == api.QCIAPPCIDomain), return a descriptive error
(e.g., fmt.Errorf) if the style is unrecognized, and adjust all callers to
handle the returned error; preserve existing formatting logic using
mappingConfig.SourceRegistry/SourceNamespace and api.QuayImageReference when the
style is valid.

---

Nitpick comments:
In `@cmd/promoted-image-governor/main_test.go`:
- Around line 244-262: Add a new table test entry in main_test.go mirroring the
"source_pullspec_style quay-proxy" case but with
OpenshiftMappingConfig.SourcePullspecStyle set to an empty string and
SourceRegistry set to api.QCIAPPCIDomain; keep promotedTags and Images the same
and assert the expected mapping (the "mapping_origin_4_8" key mapping to
"quay-proxy.ci.openshift.org/openshift/ci:origin_4.8_bar" ->
"quay.io/openshift/origin-bar:4.8") so the test verifies that an empty
SourcePullspecStyle falls back to quay-proxy behavior for api.QCIAPPCIDomain.

In `@cmd/promoted-image-governor/main.go`:
- Around line 230-236: Add a Go doc comment for the exported field
SourcePullspecStyle on the OpenshiftMappingConfig struct describing the accepted
string values (e.g., "legacy", "ocp", or whatever the code expects), the
semantics of each value, and the default behavior when the field is
empty/omitted; place the comment immediately above the SourcePullspecStyle field
so godoc/tools pick it up and users of OpenshiftMappingConfig can see the
allowed values and default.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: a12b125b-c478-4776-991c-f243792c4cc0

📥 Commits

Reviewing files that changed from the base of the PR and between f86d520 and ffb587c.

📒 Files selected for processing (2)
  • cmd/promoted-image-governor/main.go
  • cmd/promoted-image-governor/main_test.go

Comment thread cmd/promoted-image-governor/main.go Outdated
@deepsm007 deepsm007 force-pushed the governor-openshift-mapping-pullspec branch from f26d18e to 32195e7 Compare May 14, 2026 23:43
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
cmd/promoted-image-governor/main_test.go (1)

378-380: ⚡ Quick win

Assert the validation reason, not only error presence.

This currently passes on any loadMappingConfig failure. Assert that the error is specifically about source_pullspec_style so the test protects the intended contract.

Suggested tightening
 import (
 	"context"
 	"fmt"
 	"os"
 	"path/filepath"
 	"regexp"
+	"strings"
 	"testing"
@@
-	if _, err := loadMappingConfig(path); err == nil {
-		t.Fatal("expected error")
+	if _, err := loadMappingConfig(path); err == nil || !strings.Contains(err.Error(), "source_pullspec_style") {
+		t.Fatalf("expected source_pullspec_style validation error, got: %v", err)
 	}

As per coding guidelines, "Ensure error messages are informative enough for developers to understand the error".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/promoted-image-governor/main_test.go` around lines 378 - 380, The test
currently only checks that loadMappingConfig(path) returns an error; instead
assert the error message specifically indicates a validation failure for the
source_pullspec_style field. Update the test around the loadMappingConfig call
to verify err != nil and that err.Error() contains (or matches) a message
referencing "source_pullspec_style" (or the exact validation text your loader
emits), using the test helper/assert function you prefer so this test fails only
when the source_pullspec_style contract is broken.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cmd/promoted-image-governor/main_test.go`:
- Around line 378-380: The test currently only checks that
loadMappingConfig(path) returns an error; instead assert the error message
specifically indicates a validation failure for the source_pullspec_style field.
Update the test around the loadMappingConfig call to verify err != nil and that
err.Error() contains (or matches) a message referencing "source_pullspec_style"
(or the exact validation text your loader emits), using the test helper/assert
function you prefer so this test fails only when the source_pullspec_style
contract is broken.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: dc42f89d-d435-42a7-92c7-82baa7a9bdf9

📥 Commits

Reviewing files that changed from the base of the PR and between ffb587c and 32195e7.

📒 Files selected for processing (2)
  • cmd/promoted-image-governor/main.go
  • cmd/promoted-image-governor/main_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmd/promoted-image-governor/main.go

Comment thread cmd/promoted-image-governor/main.go Outdated
@deepsm007 deepsm007 force-pushed the governor-openshift-mapping-pullspec branch from 32195e7 to 152394e Compare May 18, 2026 01:06
@deepsm007
Copy link
Copy Markdown
Contributor Author

/test checkconfig

fatal: unable to access 'https://github.com/openshift/release.git/': Could not resolve host: github.com

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Pipeline controller notification

No second-stage tests were triggered for this PR.

This can happen when:

  • The changed files don't match any pipeline_run_if_changed patterns
  • All files match pipeline_skip_if_only_changed patterns
  • No pipeline-controlled jobs are defined for the main branch

Use /test ? to see all available tests.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 18, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 18, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepsm007, Prucek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepsm007
Copy link
Copy Markdown
Contributor Author

/retest-required

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 18, 2026

@deepsm007: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit e3ac258 into openshift:main May 18, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants