Skip to content

Improve dockerfile inputs detection#4922

Open
Prucek wants to merge 2 commits intoopenshift:mainfrom
Prucek:fix-dockerfile-inputs
Open

Improve dockerfile inputs detection#4922
Prucek wants to merge 2 commits intoopenshift:mainfrom
Prucek:fix-dockerfile-inputs

Conversation

@Prucek
Copy link
Member

@Prucek Prucek commented Feb 3, 2026

This PR adds:

  • getting the right path when in rehearsal to fix:
{"error":"failed to read Dockerfile at ./Dockerfile: open ./Dockerfile: no such file or directory","image":"leader-elector","level":"debug","msg":"Failed to read Dockerfile for input detection, skipping","time":"2026-01-30T08:13:52Z"}
  • build_root to base_images so that when it is detected in a dockerfile it does not have to be reimported again

@openshift-ci-robot
Copy link
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

@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

Walkthrough

The changes refactor how build root paths are handled for repository-based builds. A new helper function getPath() extracts path calculation logic previously inlined. Two internal functions—detectDockerfileInputs() and readDockerfileForImage()—are updated to accept an explicit path parameter, with all call sites updated accordingly. Dockerfile resolution and base image detection logic are adjusted to use the provided path parameter.

Changes

Cohort / File(s) Summary
Path-aware Dockerfile handling
pkg/defaults/defaults.go
Introduced new getPath() helper function to compute working directory paths. Updated detectDockerfileInputs() and readDockerfileForImage() signatures to accept a path parameter. Modified Dockerfile path construction to join provided path with Dockerfile components. Updated runtimeStepConfigsForBuild() to use the new helper. Enhanced logic to propagate baseImages mapping with root/Alias entries.
Test coverage for path-based Dockerfile resolution
pkg/defaults/defaults_test.go
Added two new test cases to TestStepConfigsForBuild exercising dockerfile-driven image building with input and output step generation. Updated TestReadDockerfileForImage call site to pass path parameter (".").

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci openshift-ci bot requested review from bear-redhat and jmguzik February 3, 2026 08:12
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 3, 2026
Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/defaults/defaults.go (1)

1103-1108: ⚠️ Potential issue | 🔴 Critical

Fix ContextDir path construction to account for computed path parameter.

When image.ContextDir is set, the current code at line 1106 completely replaces the computed path parameter. This causes failures in rehearsal scenarios where path is an absolute directory like /home/prow/go/src/github.com/org/repo. The ContextDir would become a relative path when it should be absolute.

The correct logic should be:

if image.ContextDir != "" {
    dockerfilePath = fmt.Sprintf("%s/%s/%s", path, image.ContextDir, details.path)
}

This treats ContextDir as relative to the computed path, ensuring consistent behavior whether path is "." or an absolute directory.

@hector-vido
Copy link
Contributor

/lgtm
/retest

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
@Prucek
Copy link
Member Author

Prucek commented Feb 3, 2026

/lgtm cancel

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hector-vido

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

@openshift-ci-robot
Copy link
Contributor

Scheduling required tests:
/test e2e

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2026

@Prucek: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/breaking-changes 7eeab25 link false /test breaking-changes

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.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants