Skip to content

fix microshift could not determine rhel version from upstream#2494

Open
fgallott wants to merge 1 commit intoopenshift-eng:mainfrom
fgallott:fix-build-microshift-bootc
Open

fix microshift could not determine rhel version from upstream#2494
fgallott wants to merge 1 commit intoopenshift-eng:mainfrom
fgallott:fix-build-microshift-bootc

Conversation

@fgallott
Copy link
Contributor

working build

[2026-02-13T12:46:30.915Z] 2026-02-13 12:46:29,293 artcommonlib INFO [containers/microshift-bootc] [microshift-bootc] Upstream Dockerfile last FROM has unresolved ARG references (":"), applying content.source.modifications and re-parsing
[2026-02-13T12:46:30.916Z] 2026-02-13 12:46:29,294 artcommonlib INFO [containers/microshift-bootc] [microshift-bootc] Resolved pullspec after applying modifications: "registry.redhat.io/rhel9-eus/rhel-9.6-bootc:9.6"

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 13, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joepvd for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Walkthrough

The PR enhances upstream image resolution by adding fallback mechanisms for RHEL version extraction from registry paths and implementing a Dockerfile modifications resolver that applies content.source.modifications to unresolved image references before re-parsing.

Changes

Cohort / File(s) Summary
Upstream Resolution Logic
doozer/doozerlib/image.py
Adds fallback RHEL version extraction from registry paths when not found in pullspec tag. Introduces _resolve_pullspec_with_modifications() helper method to apply content.source.modifications to unresolved Dockerfile ARG references and re-parse for valid pullspecs. Integrates resolution logic into upstream determination flow with updated error handling and logging.
Test Coverage
doozer/tests/test_image.py
Adds comprehensive unit tests for image upstream resolution including: RHEL version detection from registry paths, Dockerfile ARG resolution with and without modifications, alternative upstream config application under various match/no-match scenarios, and modified Dockerfile re-parsing behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 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
Copy link
Contributor

openshift-ci bot commented Feb 13, 2026

@fgallott: 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/security 13dcde4 link false /test security

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.

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In `@doozer/tests/test_image.py`:
- Around line 857-898: The test_docstring for
test_determine_upstream_builder_info_unresolved_args_no_modifications is
incorrect: update the docstring to state that an IOError is expected when
upstream Dockerfile has unresolved ARG references and there are no
content.source.modifications (i.e., metadata._apply_alternative_upstream_config
should raise IOError rather than returning None for rhel_version); modify the
docstring text to reflect the expected exception and the scenario involving
unresolved ARGs and lack of modifications so it matches the assertion in the
test.

Comment on lines +857 to +898
def test_determine_upstream_builder_info_unresolved_args_no_modifications(
self, mock_joinpath, mock_open, mock_source_resolver
):
"""
Test that when upstream Dockerfile has unresolved ARG references and there are no
content.source.modifications, the method returns None for rhel_version gracefully.
"""
extract_builder_info_from_pullspec.cache_clear()
metadata = self._create_image_metadata('openshift/test_no_mods')

metadata.config = Model(
{
'name': 'openshift/test_no_mods',
'distgit': {'branch': 'rhaos-4.18-rhel-9'},
'content': {
'source': {
'git': {'url': 'git@github.com:openshift-priv/test.git'},
},
},
}
)

metadata.branch_el_target = MagicMock(return_value=9)

mock_source_resolution = MagicMock()
metadata.runtime.source_resolver.resolve_source = MagicMock(return_value=mock_source_resolution)
mock_source_dir = MagicMock()
mock_source_resolver.get_source_dir = MagicMock(return_value=mock_source_dir)
mock_joinpath.return_value = MagicMock()

dockerfile_content = "ARG BASE_IMAGE_URL\nARG BASE_IMAGE_TAG\nFROM ${BASE_IMAGE_URL}:${BASE_IMAGE_TAG}\n"
mock_open.return_value.__enter__.return_value.read.return_value = dockerfile_content

with patch('doozerlib.image.DockerfileParser') as mock_dfp_cls:
mock_dfp_instance = MagicMock()
mock_dfp_instance.parent_images = [':']
mock_dfp_cls.return_value = mock_dfp_instance

# Should raise IOError because rhel_version could not be determined
with self.assertRaises(IOError):
metadata._apply_alternative_upstream_config()

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Docstring contradicts expected behavior.
The test expects an IOError, but the docstring says it returns None for rhel_version. Please align the docstring with the assertion.

✏️ Suggested docstring fix
-        Test that when upstream Dockerfile has unresolved ARG references and there are no
-        content.source.modifications, the method returns None for rhel_version gracefully.
+        Test that when upstream Dockerfile has unresolved ARG references and there are no
+        content.source.modifications, the method raises IOError.
🤖 Prompt for AI Agents
In `@doozer/tests/test_image.py` around lines 857 - 898, The test_docstring for
test_determine_upstream_builder_info_unresolved_args_no_modifications is
incorrect: update the docstring to state that an IOError is expected when
upstream Dockerfile has unresolved ARG references and there are no
content.source.modifications (i.e., metadata._apply_alternative_upstream_config
should raise IOError rather than returning None for rhel_version); modify the
docstring text to reflect the expected exception and the scenario involving
unresolved ARGs and lack of modifications so it matches the assertion in the
test.

return None

pullspec = parent_images[-1]
if not pullspec or "${" in pullspec or pullspec == ":":
Copy link
Contributor

Choose a reason for hiding this comment

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

Not strictly needed, but defining something like is_pullspec_unresolved(pullspec: str) would make the code more readable and maintainable (also seen at line 899)

@locriandev
Copy link
Contributor

/lgtm

Left an optional comment

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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