Skip to content

Fix per-component criteria for multi-arch#3272

Open
simonbaird wants to merge 1 commit intoconforma:mainfrom
simonbaird:multi-arch-component-criteria-fix
Open

Fix per-component criteria for multi-arch#3272
simonbaird wants to merge 1 commit intoconforma:mainfrom
simonbaird:multi-arch-component-criteria-fix

Conversation

@simonbaird
Copy link
Copy Markdown
Member

For multi-arch images, the original component gets expanded into several components, each with a name that includes a digest and an arch. This patch makes sure those additional components can also match a volatile exclude with component name criteria.

Bug originally reported in
https://redhat.atlassian.net/browse/KFLUXSPRT-7780

Ref: https://redhat.atlassian.net/browse/EC-1800

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: d92e3da9-dc96-4c48-a877-292e5df39c52

📥 Commits

Reviewing files that changed from the base of the PR and between dae61a1 and 3cc2555.

📒 Files selected for processing (2)
  • internal/evaluator/criteria.go
  • internal/evaluator/criteria_test.go

📝 Walkthrough

Walkthrough

Criteria.get now treats component-scoped lookups to include both the provided componentName and an original name computed by stripping a multi-arch expanded suffix of the form -sha256:<64 hex>-<arch>, enabling matches for per-arch expanded component keys.

Changes

Multi-Arch Component Matching

Layer / File(s) Summary
Pattern Definition & Helper
internal/evaluator/criteria.go
Adds regexp import, defines multiArchSuffixRe to match -sha256:<64 hex>-<arch> suffixes, and implements originalComponentName(componentName string) string to strip that suffix.
Criteria Matching Logic
internal/evaluator/criteria.go
Updates Criteria.get to consult c.componentItems[componentName] and, when the stripped originalComponentName differs, also merge matches from c.componentItems[originalComponentName(componentName)].
Tests
internal/evaluator/criteria_test.go
Extends TestCriteriaGetWithComponentName with positive cases for arm64/noarch expanded component names and a negative similar-name case; adds TestOriginalComponentName covering plain names, various multi-arch suffixes, non-stripping similar names, and empty input.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing per-component criteria handling for multi-arch images.
Description check ✅ Passed The description is directly related to the changeset, explaining the multi-arch component expansion issue and how the patch addresses it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@simonbaird simonbaird force-pushed the multi-arch-component-criteria-fix branch from 71124c4 to 36cefe7 Compare May 5, 2026 17:52
Copy link
Copy Markdown

@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

Caution

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

⚠️ Outside diff range comments (1)
internal/evaluator/criteria_test.go (1)

980-1077: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix gci formatting in this test block before merge

golangci-lint reports this file as not properly formatted (Line 983). Please run formatting/import normalization for this file so CI passes.

🤖 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 `@internal/evaluator/criteria_test.go` around lines 980 - 1077, The test file
fails golangci-lint gci formatting around the TestOriginalComponentName block;
run your Go import/format tools (gofmt/gci or goimports) on the file and
reformat imports so the TestOriginalComponentName test table and the
originalComponentName usages follow the project's gci rules, then re-run CI;
ensure the tests slice and its entries (the table-driven tests) and import
ordering are normalized before committing.
🤖 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.

Inline comments:
In `@internal/evaluator/criteria.go`:
- Around line 134-141: The regex in multiArchSuffixRe is too permissive (uses
[0-9a-f]+) and wrongly strips names like "foo-sha256:abc-arm64"; tighten it to
match a full SHA-256 hex digest by requiring exactly 64 hex chars and allow
uppercase too (e.g., use [0-9a-fA-F]{64} or a case-insensitive flag) so
originalComponentName only removes true multi-arch suffixes; update the
multiArchSuffixRe definition accordingly and keep originalComponentName as-is.

---

Outside diff comments:
In `@internal/evaluator/criteria_test.go`:
- Around line 980-1077: The test file fails golangci-lint gci formatting around
the TestOriginalComponentName block; run your Go import/format tools (gofmt/gci
or goimports) on the file and reformat imports so the TestOriginalComponentName
test table and the originalComponentName usages follow the project's gci rules,
then re-run CI; ensure the tests slice and its entries (the table-driven tests)
and import ordering are normalized before committing.
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 6bceb4c7-3e18-4d9a-b4ee-f68391d0a243

📥 Commits

Reviewing files that changed from the base of the PR and between b345847 and 71124c4.

📒 Files selected for processing (2)
  • internal/evaluator/criteria.go
  • internal/evaluator/criteria_test.go

Comment thread internal/evaluator/criteria.go Outdated
@simonbaird simonbaird force-pushed the multi-arch-component-criteria-fix branch from 36cefe7 to dae61a1 Compare May 5, 2026 18:04
For multi-arch images, the original component gets expanded into
several components, each with a name that includes a digest and an
arch. This patch makes sure those additional components can also
match a volatile exclude with component name criteria.

Bug originally reported in
https://redhat.atlassian.net/browse/KFLUXSPRT-7780

Ref: https://redhat.atlassian.net/browse/EC-1800
Co-authored-by: Claude Code <noreply@anthropic.com>
@simonbaird simonbaird force-pushed the multi-arch-component-criteria-fix branch from dae61a1 to 3cc2555 Compare May 6, 2026 20:11
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
acceptance 55.16% <60.00%> (-0.01%) ⬇️
generative 17.89% <0.00%> (-0.01%) ⬇️
integration 26.66% <60.00%> (+0.01%) ⬆️
unit 69.02% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/evaluator/criteria.go 96.87% <100.00%> (+0.17%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants