Skip to content

[ci_gen_kustomize_values] Fix non-deterministic snippet combine order - #4138

Open
imatza-rh wants to merge 1 commit into
mainfrom
fix-snippet-combine-order
Open

[ci_gen_kustomize_values] Fix non-deterministic snippet combine order#4138
imatza-rh wants to merge 1 commit into
mainfrom
fix-snippet-combine-order

Conversation

@imatza-rh

@imatza-rh imatza-rh commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

generate_values.yml combines per-stage YAML snippets via a loop over ansible.builtin.find results. Snippet filenames use a numeric prefix (02_ci_data.yaml, 03_user_data_b64.yaml, 04_user_data.yaml) to signal intended override precedence, but find() does not guarantee sorted results, so combine order was filesystem-order dependent instead of matching the intended numeric precedence.

Impact observed

On RHOSO 19 RHEL 10 uni01alpha (OSPNW-1694), a user-provided edpm_fips_mode: check override (needed because fips-mode-setup was removed from RHEL 10) was silently discarded in favor of the common edpm-nodeset-values template's cifmw_fips_enabled-derived default of enabled, causing every EDPM bootstrap job to fail with fips-mode-setup: No such file or directory.

Live verification: on the held CI node from tp !2601 build b5e8409, the OpenStackDataPlaneNodeSet spec carried edpm_fips_mode: enabled despite the job-var override. Patching it to check directly on the live NodeSet and re-running the bootstrap service completed cleanly (all FIPS tasks correctly skipped, failed=0).

Fix

Add an explicit sort(attribute='source') on the combine loop so snippets are always applied in filename order, matching the numeric prefix convention already in use.

Related-Issue: #OSPNW-1694
Related-Issue: #OSPNW-1715

generate_values.yml combines per-stage YAML snippets (base template
defaults, base64 patches, user-provided overrides) via a loop over
ansible.builtin.find results. Snippet filenames use a numeric prefix
(02_ci_data.yaml, 03_user_data_b64.yaml, 04_user_data.yaml) to signal
intended override precedence, but find() does not guarantee sorted
results, so combine order (and therefore which snippet wins on
conflicting keys) was filesystem-order dependent instead of matching
the intended numeric precedence.

Observed on RHOSO 19 RHEL 10 uni01alpha (OSPNW-1694): a user-provided
edpm_fips_mode: check override (needed because fips-mode-setup was
removed from RHEL 10) was silently discarded in favor of the common
edpm-nodeset-values template's cifmw_fips_enabled-derived default of
'enabled', causing every EDPM bootstrap job to fail with
'fips-mode-setup: No such file or directory'. Confirmed live on the
held CI node: the OpenStackDataPlaneNodeSet spec carried
edpm_fips_mode: enabled despite the override, and patching it to
'check' on the same live NodeSet let the bootstrap job complete
cleanly (all FIPS tasks correctly skipped).

Add an explicit sort(attribute='source') on the combine loop so
snippets are always applied in filename order, matching the numeric
prefix convention already in use.

Related-Issue: #OSPNW-1694
Related-Issue: #OSPNW-1715
Signed-off-by: Itay Matza <imatza@redhat.com>
@openshift-ci

openshift-ci Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

[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 eshulman2 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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix deterministic YAML snippet precedence in ci_gen_kustomize_values

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Sort per-stage snippet results before combining to ensure deterministic overrides.
• Align merge precedence with numeric filename prefixes (02/03/04) used by convention.
• Prevent filesystem-order dependent merges that can silently drop user overrides.
Diagram

graph TD
  A["generate_values.yml"] --> B["find snippets"] --> C["sort by source"] --> D["combine YAML"] --> E["final values"]

  subgraph Legend
    direction LR
    _file["Task file"] ~~~ _step["Processing step"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Sort by basename (or numeric prefix) instead of full source path
  • ➕ More explicitly matches the documented intent (02/03/04 precedence).
  • ➕ More robust if snippet directory paths differ but filenames define ordering.
  • ➖ Requires extra parsing (basename extraction and/or integer prefix parsing).
  • ➖ Slightly more code and potential edge cases (missing/invalid prefixes).
2. Use an explicit ordered snippet list (no find-driven ordering)
  • ➕ Guarantees precedence without relying on filesystem discovery behavior.
  • ➕ Makes override precedence obvious in one place.
  • ➖ Less flexible/extensible than discovery; adding new snippet types requires list updates.
  • ➖ May break setups that rely on drop-in snippets without modifying the role.

Recommendation: The PR’s approach (sorting find results by source) is the best trade-off: minimal change, preserves discovery-based extensibility, and restores deterministic precedence consistent with existing numeric filename conventions. If future needs require more nuanced ordering rules, consider sorting by basename or parsed numeric prefix.

Files changed (1) +6 / -1

Bug fix (1) +6 / -1
generate_values.ymlSort snippet combine loop to enforce numeric-prefix precedence +6/-1

Sort snippet combine loop to enforce numeric-prefix precedence

• Adds an explicit 'sort(attribute='source')' to the loop over discovered snippet content so YAML merges happen deterministically. Includes inline comments explaining why 'ansible.builtin.find' ordering is not reliable and how filename prefixes define intended override precedence.

roles/ci_gen_kustomize_values/tasks/generate_values.yml

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@centosinfra-prod-github-app

Copy link
Copy Markdown

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/t/rdoproject.org/buildset/4e557af042aa4103ad4e77cdc2624841

✔️ openstack-k8s-operators-content-provider SUCCESS in 3h 53m 46s
✔️ podified-multinode-edpm-deployment-crc SUCCESS in 1h 30m 27s
✔️ cifmw-crc-podified-edpm-baremetal SUCCESS in 1h 50m 58s
✔️ cifmw-crc-podified-edpm-baremetal-minor-update SUCCESS in 2h 24m 23s
✔️ cifmw-pod-zuul-files SUCCESS in 5m 38s
openstack-k8s-operators-content-provider-bootc FAILURE in 34m 19s
⚠️ cifmw-crc-podified-edpm-baremetal-bootc SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider-bootc
✔️ noop SUCCESS in 0s
✔️ cifmw-pod-ansible-test SUCCESS in 9m 47s
✔️ cifmw-pod-pre-commit SUCCESS in 8m 58s
✔️ cifmw-architecture-validate-hci SUCCESS in 6m 07s
✔️ cifmw-molecule-ci_gen_kustomize_values SUCCESS in 7m 26s

@imatza-rh

Copy link
Copy Markdown
Contributor Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant