fix: dockerfile registry.ci input detection with baseImages#5215
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
📝 WalkthroughWalkthroughThe PR refactors Dockerfile analysis by simplifying registry reference extraction into a pure function and relocating base image context handling into input detection logic. ExtractRegistryReferences now accepts only Dockerfile bytes; DetectInputsFromDockerfile gains a baseImages map parameter to skip references matching known base images. Call sites and tests are updated accordingly. ChangesBase Image Context in Dockerfile Input Detection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 15 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (15 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/lgtm |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/dockerfile/inputs.go (1)
9-12: ⚡ Quick winUpdate
DetectInputsFromDockerfiledocs to includebaseImages/fromskip semantics.The exported function comment no longer describes the full contract after the new parameter and behavior change.
As per coding guidelines
**/*.go: Go documentation on Classes/Functions/Fields should be 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 `@pkg/dockerfile/inputs.go` around lines 9 - 12, Update the DetectInputsFromDockerfile function comment to document the new parameters and skip semantics: explain that the baseImages map and the from api.PipelineImageStreamTagReference are used to skip adding certain registry references (describe which conditions cause a skip, e.g., when a reference is already present in baseImages or matches from), state that existingInputs influences detection, and clarify that the returned map keys are base image names with ImageStreamTagReference.As containing the original Dockerfile reference; reference the function name DetectInputsFromDockerfile and the parameters baseImages and from in the comment so callers understand the full contract.
🤖 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 `@pkg/dockerfile/inputs.go`:
- Around line 9-12: Update the DetectInputsFromDockerfile function comment to
document the new parameters and skip semantics: explain that the baseImages map
and the from api.PipelineImageStreamTagReference are used to skip adding certain
registry references (describe which conditions cause a skip, e.g., when a
reference is already present in baseImages or matches from), state that
existingInputs influences detection, and clarify that the returned map keys are
base image names with ImageStreamTagReference.As containing the original
Dockerfile reference; reference the function name DetectInputsFromDockerfile and
the parameters baseImages and from in the comment so callers understand the full
contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: ad71ee8a-0ef6-432e-8c1d-ace93f9e5666
📒 Files selected for processing (5)
cmd/registry-replacer/main.gopkg/defaults/defaults.gopkg/dockerfile/extract.gopkg/dockerfile/inputs.gopkg/dockerfile/inputs_test.go
|
/test e2e |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danilo-gemoli, deepsm007 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/override ci/prow/images not related and this PR is critical for CRT |
|
@deepsm007: Overrode contexts on behalf of deepsm007: ci/prow/images 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 kubernetes-sigs/prow repository. |
|
Tests from second stage were triggered manually. Pipeline can be controlled only manually, until HEAD changes. Use command to trigger second stage. |
|
@deepsm007: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Skip Dockerfile registry.ci inputs already covered by
from+baseImages; stop dropping the last unrelatedFROMwhenfromnames a different base.https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/openshift_continuous-release-jobs/1797/pull-ci-openshift-continuous-release-jobs-master-images/2060040001508347904
Summary
This PR fixes Dockerfile registry reference detection in OpenShift CI's pipeline configuration processing, addressing issues with duplicate input detection when base images are explicitly specified.
Problem Fixed
The CI infrastructure was incorrectly detecting and processing Docker registry references from Dockerfile
FROMinstructions that were already declared through thebaseImagesconfiguration. This caused:FROMinstruction in multi-stage builds when the primaryfromconfiguration pointed to a different base imageFROMdirectives that were unrelated to the primary build stageChanges
Core Detection Logic (
pkg/dockerfile/inputs.go):DetectInputsFromDockerfile()with a newbaseImagesparameter to enable skipping of Dockerfile registry references that are already covered by explicitly configured base imagesmatchesFromBaseImage()helper function that compares Dockerfile references against the base images map by namespace, repository, and tag to determine if a reference should be skippedSimplified Registry Extraction (
pkg/dockerfile/extract.go):fromparameter fromExtractRegistryReferences()fromconfigurationUpdated Callers:
pkg/defaults/defaults.go: Now passes thebaseImagesmap when detecting inputs during pipeline configuration processingcmd/registry-replacer/main.go: Simplified to use the new signature ofExtractRegistryReferences()Impact
CI operators and users defining multi-stage container builds will see more accurate image input detection. The fix ensures that:
FROMinstructions in multi-stage builds are properly preserved, regardless of which stages are used as the primary build base