Skip to content

USHIFT-6788: explicitly process bootc templates#6486

Merged
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
copejon:ushift-6788
Apr 16, 2026
Merged

USHIFT-6788: explicitly process bootc templates#6486
openshift-merge-bot[bot] merged 3 commits into
openshift:mainfrom
copejon:ushift-6788

Conversation

@copejon
Copy link
Copy Markdown
Contributor

@copejon copejon commented Apr 9, 2026

Summary

  • Adds explicit processing for shared bootc templates from image-blueprints-bootc/templates/ directory
  • Templates are processed after package-specific templates but before mirror registry
  • Respects existing FORCE_REBUILD logic to skip already-processed templates

Fixes: USHIFT-6788

Test plan

  • Verify bootc image build processes templates from the shared templates directory
  • Verify existing template processing behavior is unchanged
  • Verify FORCE_REBUILD flag works correctly for shared templates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved template processing in the build pipeline for more reliable and efficient image generation.
    • Added support for processing shared template directories so common templates are applied consistently across builds.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

Walkthrough

Added an internal helper process_template_files(tpldir, dry_run) to render *.template files into BOOTC_IMAGE_DIR. process_group() delegates template rendering to that helper. main() was updated to additionally render templates from ../image-blueprints-bootc/templates (passing args.dry_run) after processing package-specific templates and before invoking mirror_registry.sh.

Changes

Cohort / File(s) Summary
Build bootc images templating
test/bin/pyutils/build_bootc_images.py
Added process_template_files(tpldir, dry_run) to iterate and render *.template files into BOOTC_IMAGE_DIR; refactored process_group() to call the helper; updated main() to render shared ../image-blueprints-bootc/templates (passes args.dry_run) between package template processing and mirror_registry.sh.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main change: adding explicit processing for bootc templates from a shared directory.
Stable And Deterministic Test Names ✅ Passed PR modifies only a Python build utility script with no Ginkgo test files or test name declarations.
Test Structure And Quality ✅ Passed Custom check for Ginkgo test code is not applicable to Python utility script modifications.
Microshift Test Compatibility ✅ Passed PR modifies Python build utility script only; custom check applies only to new Ginkgo e2e tests, which are absent.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies only a Python utility script, not Ginkgo e2e tests, so SNO compatibility check does not apply.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies a Python build automation script for bootc image processing with no Kubernetes manifests, operator changes, or controller code affecting runtime scheduling.
Ote Binary Stdout Contract ✅ Passed This PR modifies only a Python utility script, not a Go OTE binary. The check is specific to Go test binaries with Ginkgo framework integration and is not applicable here.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only Python build utility script, no Ginkgo e2e tests or Go test files present. IPv6 and disconnected network compatibility check does not apply.

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

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

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.

❤️ Share

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

@openshift-ci openshift-ci Bot requested review from eslutsky and kasturinarra April 9, 2026 18:19
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 9, 2026
Comment thread test/bin/pyutils/build_bootc_images.py Outdated
ofile = os.path.join(BOOTC_IMAGE_DIR, ifile)
ifile = os.path.join(ipkgdir, ifile)
run_template_cmd(ifile, ofile, args.dry_run)
# Process shared bootc templates (USHIFT-6788)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the issue ID from the comment. We do not usually do this unless it's a TODO item.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment has not been addressed.

Comment thread test/bin/pyutils/build_bootc_images.py Outdated
run_template_cmd(ifile, ofile, args.dry_run)
# Process shared bootc templates (USHIFT-6788)
tpldir = f"{SCRIPTDIR}/../image-blueprints-bootc/templates"
if os.path.isdir(tpldir):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This code is almost a duplicate of a block from process_group function.
Let's refactor it into process_template_files and call from both places?

@copejon copejon changed the title test: explicitly process bootc templates USHIFT-6788: explicitly process bootc templates Apr 14, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 14, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 14, 2026

@copejon: This pull request references USHIFT-6788 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 bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary

  • Adds explicit processing for shared bootc templates from image-blueprints-bootc/templates/ directory
  • Templates are processed after package-specific templates but before mirror registry
  • Respects existing FORCE_REBUILD logic to skip already-processed templates

Fixes: USHIFT-6788

Test plan

  • Verify bootc image build processes templates from the shared templates directory
  • Verify existing template processing behavior is unchanged
  • Verify FORCE_REBUILD flag works correctly for shared templates

🤖 Generated with Claude Code

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.

Extract shared gomplate logic for *.template files under a directory into
process_template_files(), call from process_group and from the
image-blueprints-bootc/templates path. Blueprint templates use
skip_existing=not args.force_rebuild and ignore_missing_dir=True to preserve
prior skip-when-output-exists behavior without reading FORCE_REBUILD in the helper.

Made-with: Cursor
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 14, 2026

@copejon: This pull request references USHIFT-6788 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 bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Adds explicit processing for shared bootc templates from image-blueprints-bootc/templates/ directory
  • Templates are processed after package-specific templates but before mirror registry
  • Respects existing FORCE_REBUILD logic to skip already-processed templates

Fixes: USHIFT-6788

Test plan

  • Verify bootc image build processes templates from the shared templates directory
  • Verify existing template processing behavior is unchanged
  • Verify FORCE_REBUILD flag works correctly for shared templates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
  • Refactored build system's template file processing for improved efficiency.
  • Enhanced handling of shared template directories in the build pipeline.

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.

@copejon
Copy link
Copy Markdown
Contributor Author

copejon commented Apr 14, 2026

/test e2e-aws-tests-arm

Comment thread test/bin/pyutils/build_bootc_images.py Outdated
ifile = os.path.join(ipkgdir, ifile)
run_template_cmd(ifile, ofile, args.dry_run)
# Process shared bootc templates (USHIFT-6788)
tpldir = f"{SCRIPTDIR}/../image-blueprints-bootc/templates"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we use os.path.join for consistency instead?

Suggested change
tpldir = f"{SCRIPTDIR}/../image-blueprints-bootc/templates"
tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")

Comment thread test/bin/pyutils/build_bootc_images.py Outdated
ignore_missing_dir: if True, no-op when tpldir is absent.
"""

if ignore_missing_dir and not os.path.isdir(tpldir):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add a log if this happens?

Comment thread test/bin/pyutils/build_bootc_images.py Outdated
if not name.endswith(".template"):
continue
ofile = os.path.join(BOOTC_IMAGE_DIR, name.removesuffix(".template"))
if skip_existing and os.path.exists(ofile):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add a log if this happens?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually I agree with Giga's comment about the value of the optimizations. I'm removing these vars.

Comment thread test/bin/pyutils/build_bootc_images.py Outdated
Comment on lines +224 to +225
skip_existing: if True, skip outputs that already exist (pass False when forcing rebuild).
ignore_missing_dir: if True, no-op when tpldir is absent.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need these two arguments. Let's keep it the way it was because template processing is very very quick.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looking back at it, I agree. Will remove.

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 15, 2026

@copejon: This pull request references USHIFT-6788 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 bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Adds explicit processing for shared bootc templates from image-blueprints-bootc/templates/ directory
  • Templates are processed after package-specific templates but before mirror registry
  • Respects existing FORCE_REBUILD logic to skip already-processed templates

Fixes: USHIFT-6788

Test plan

  • Verify bootc image build processes templates from the shared templates directory
  • Verify existing template processing behavior is unchanged
  • Verify FORCE_REBUILD flag works correctly for shared templates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
  • Improved template file processing in the build pipeline for more efficient and reliable image generation.
  • Added support for processing shared template directories to ensure common templates are applied consistently during builds.

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.

Copy link
Copy Markdown
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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/bin/pyutils/build_bootc_images.py`:
- Around line 221-228: process_template_files currently lists tpldir without
handling a missing directory; add an optional parameter ignore_missing_dir=False
(matching the caller) and either check os.path.isdir(tpldir) and return early
when ignore_missing_dir is True or catch FileNotFoundError around
os.listdir(tpldir) and return silently when ignore_missing_dir is True; keep
behavior unchanged when ignore_missing_dir is False by re-raising the error.
Reference: process_template_files(tpldir, dry_run), BOOTC_IMAGE_DIR, and
run_template_cmd.
- Around line 663-668: The call to process_template_files(tpldir, args.dry_run,
skip_existing=..., ignore_missing_dir=...) passes keyword args that no longer
exist; update the call to match the current signature by removing skip_existing
and ignore_missing_dir and simply call process_template_files(tpldir,
args.dry_run). If the template directory may be absent and should be silently
skipped, add a guard before the call (e.g., check os.path.isdir(tpldir)) and
skip calling process_template_files when the directory doesn't exist; if the
original skip_existing behavior is still required, implement that handling at
the call site or restore it inside process_template_files.
🪄 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: Pro Plus

Run ID: ee8b7e87-2f11-4957-8a4a-09915fe99fd3

📥 Commits

Reviewing files that changed from the base of the PR and between 3b8402e and 82fa83e.

📒 Files selected for processing (1)
  • test/bin/pyutils/build_bootc_images.py

Comment thread test/bin/pyutils/build_bootc_images.py
Comment thread test/bin/pyutils/build_bootc_images.py Outdated
Comment on lines +663 to +668

tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")
process_template_files(
tpldir, args.dry_run,
skip_existing=not args.force_rebuild,
ignore_missing_dir=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Function call passes arguments that don't exist in the signature.

process_template_files() is defined with only (tpldir, dry_run) parameters (lines 221-222), but this call passes skip_existing and ignore_missing_dir keyword arguments. This will raise TypeError at runtime.

Per the commit message, these parameters were intentionally removed. Update the call to match:

Proposed fix
         tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")
-        process_template_files(
-            tpldir, args.dry_run,
-            skip_existing=not args.force_rebuild,
-            ignore_missing_dir=True)
+        if os.path.isdir(tpldir):
+            process_template_files(tpldir, args.dry_run)

If the directory might not exist and should be silently skipped, add a guard. If skip_existing logic is still needed, either restore it in process_template_files() or handle it at the call site.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")
process_template_files(
tpldir, args.dry_run,
skip_existing=not args.force_rebuild,
ignore_missing_dir=True)
tpldir = os.path.join(SCRIPTDIR, "..", "image-blueprints-bootc", "templates")
if os.path.isdir(tpldir):
process_template_files(tpldir, args.dry_run)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/bin/pyutils/build_bootc_images.py` around lines 663 - 668, The call to
process_template_files(tpldir, args.dry_run, skip_existing=...,
ignore_missing_dir=...) passes keyword args that no longer exist; update the
call to match the current signature by removing skip_existing and
ignore_missing_dir and simply call process_template_files(tpldir, args.dry_run).
If the template directory may be absent and should be silently skipped, add a
guard before the call (e.g., check os.path.isdir(tpldir)) and skip calling
process_template_files when the directory doesn't exist; if the original
skip_existing behavior is still required, implement that handling at the call
site or restore it inside process_template_files.

…ever missing, and b) processed very fast, thus don't require optimization
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 15, 2026

@copejon: This pull request references USHIFT-6788 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 bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Adds explicit processing for shared bootc templates from image-blueprints-bootc/templates/ directory
  • Templates are processed after package-specific templates but before mirror registry
  • Respects existing FORCE_REBUILD logic to skip already-processed templates

Fixes: USHIFT-6788

Test plan

  • Verify bootc image build processes templates from the shared templates directory
  • Verify existing template processing behavior is unchanged
  • Verify FORCE_REBUILD flag works correctly for shared templates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
  • Improved template processing in the build pipeline for more reliable and efficient image generation.
  • Added support for processing shared template directories so common templates are applied consistently across builds.

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.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
test/bin/pyutils/build_bootc_images.py (1)

223-228: Make template rendering order deterministic.

os.listdir() is filesystem-order dependent. Sorting here avoids non-deterministic render order and precedence drift when filenames collide.

Proposed patch
 def process_template_files(tpldir, dry_run):
     """Expand *.template files under tpldir into BOOTC_IMAGE_DIR via gomplate."""
-    for name in os.listdir(tpldir):
+    for name in sorted(os.listdir(tpldir), key=lambda i: (len(i), i)):
         if not name.endswith(".template"):
             continue
         ofile = os.path.join(BOOTC_IMAGE_DIR, name.removesuffix(".template"))
         ifile = os.path.join(tpldir, name)
         run_template_cmd(ifile, ofile, dry_run)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/bin/pyutils/build_bootc_images.py` around lines 223 - 228, The loop over
os.listdir(tpldir) is non-deterministic; change it to iterate over
sorted(os.listdir(tpldir)) (or equivalent sorted sequence) so template files are
rendered in a stable, lexicographic order—update the loop that currently uses
os.listdir(tpldir) and still calls run_template_cmd(ifile, ofile, dry_run) while
using tpldir and BOOTC_IMAGE_DIR to compute ifile/ofile.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/bin/pyutils/build_bootc_images.py`:
- Around line 223-228: The loop over os.listdir(tpldir) is non-deterministic;
change it to iterate over sorted(os.listdir(tpldir)) (or equivalent sorted
sequence) so template files are rendered in a stable, lexicographic order—update
the loop that currently uses os.listdir(tpldir) and still calls
run_template_cmd(ifile, ofile, dry_run) while using tpldir and BOOTC_IMAGE_DIR
to compute ifile/ofile.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: ed94338a-b921-4637-9cb9-86fb412c176b

📥 Commits

Reviewing files that changed from the base of the PR and between 82fa83e and 1a4e062.

📒 Files selected for processing (1)
  • test/bin/pyutils/build_bootc_images.py

@copejon
Copy link
Copy Markdown
Contributor Author

copejon commented Apr 15, 2026

/test e2e-aws-tests-bootc-periodic-el10

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 15, 2026

@copejon: 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.

@ggiguash
Copy link
Copy Markdown
Contributor

/lgtm
/cherry-pick release-4.22

@openshift-cherrypick-robot
Copy link
Copy Markdown

@ggiguash: once the present PR merges, I will cherry-pick it on top of release-4.22 in a new PR and assign it to you.

Details

In response to this:

/lgtm
/cherry-pick release-4.22

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.

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

openshift-ci Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: copejon, ggiguash

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

@ggiguash
Copy link
Copy Markdown
Contributor

/verified by ci

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 16, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@ggiguash: This PR has been marked as verified by ci.

Details

In response to this:

/verified by ci

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.

@openshift-merge-bot openshift-merge-bot Bot merged commit 7c96356 into openshift:main Apr 16, 2026
19 checks passed
@openshift-cherrypick-robot
Copy link
Copy Markdown

@ggiguash: new pull request created: #6513

Details

In response to this:

/lgtm
/cherry-pick release-4.22

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.

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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants