Skip to content

fix(EC-1994): correct off-by-one in validate image worker loop#3425

Open
cuipinghuo wants to merge 1 commit into
conforma:mainfrom
cuipinghuo:EC-1994
Open

fix(EC-1994): correct off-by-one in validate image worker loop#3425
cuipinghuo wants to merge 1 commit into
conforma:mainfrom
cuipinghuo:EC-1994

Conversation

@cuipinghuo

@cuipinghuo cuipinghuo commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix off-by-one in worker loop at cmd/validate/image.go:404: <= changed to < so the loop spawns exactly numWorkers goroutines instead of numWorkers+1
  • Bump task worker defaults by 1 to preserve the effective concurrency users had before the fix (since the old <= loop spawned N+1 workers for a configured value of N):
    • verify-conforma-konflux-ta: 4 → 5
    • verify-enterprise-contract: 1 → 2
  • Update READMEs and generated docs to match new defaults; fix stale documentation that incorrectly claimed WORKERS was unused and defaulted to 35

Test plan

  • go build ./cmd/validate/ passes
  • go test -tags=unit ./cmd/validate/ -run TestValidateImage passes
  • make generate produces no additional diff

Resolves: https://redhat.atlassian.net/browse/EC-1994

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fb21d366-2095-4a3d-8ac7-5879880c0b34

📥 Commits

Reviewing files that changed from the base of the PR and between 44b18de and bd52d43.

📒 Files selected for processing (7)
  • cmd/validate/image.go
  • docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc
  • docs/modules/ROOT/pages/verify-enterprise-contract.adoc
  • tasks/verify-conforma-konflux-ta/0.1/README.md
  • tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml
  • tasks/verify-enterprise-contract/0.1/README.md
  • tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml
  • tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml
  • cmd/validate/image.go

📝 Walkthrough

Walkthrough

The image validator now starts exactly the configured number of workers. The Konflux and enterprise contract Tekton Tasks update their default WORKERS values and corresponding documentation.

Changes

Worker parallelism

Layer / File(s) Summary
Match configured worker count
cmd/validate/image.go
The worker loop now starts exactly numWorkers workers.
Update Konflux worker default
tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml, docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc, tasks/verify-conforma-konflux-ta/0.1/README.md
The default changes from 4 to 5, and documentation describes the parameter’s parallelism behavior.
Update enterprise contract worker default
tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml, docs/modules/ROOT/pages/verify-enterprise-contract.adoc, tasks/verify-enterprise-contract/0.1/README.md
The default changes from 1 to 2 in the task definition and documentation.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: robnester-rh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 names the off-by-one worker-loop fix and matches the main code change.
Description check ✅ Passed The description includes the change summary, rationale, test plan, and linked ticket, covering the template’s required info.
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.
✨ 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.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
acceptance 54.25% <100.00%> (-0.01%) ⬇️
generative 16.80% <0.00%> (ø)
integration 27.97% <100.00%> (ø)
unit 71.75% <100.00%> (ø)

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

Files with missing lines Coverage Δ
cmd/validate/image.go 91.21% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jsmid1
jsmid1 previously approved these changes Jul 23, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 2:07 PM UTC · Ended 2:15 PM UTC
Commit: 87c4a29 · View workflow run →

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml`:
- Line 180: Synchronize the README worker defaults with the Task definitions:
for tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml lines
180-180, document the effective default as 5 instead of 35/unused; for
tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml lines
186-186, update the README default from 1 to 2.
🪄 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: Pro Plus

Run ID: 8ffe48a4-a59b-47ad-aa6c-96664ec08be3

📥 Commits

Reviewing files that changed from the base of the PR and between ea9f3be and 44b18de.

📒 Files selected for processing (2)
  • tasks/verify-conforma-konflux-ta/0.1/verify-conforma-konflux-ta.yaml
  • tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml

@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 2:16 PM UTC · Completed 2:31 PM UTC
Commit: 87c4a29 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review

Findings

Medium

  • [stale-default-value] docs/modules/ROOT/pages/verify-conforma-vsa-release-ta.adoc:55 — The WORKERS parameter default is documented as 4, but the verify-conforma-konflux-ta task YAML default was bumped from 4 to 5 in this PR. The sibling page verify-conforma-konflux-ta.adoc was correctly updated, but this page was missed.
    Remediation: Update the WORKERS default from 4 to 5 in verify-conforma-vsa-release-ta.adoc to match the updated task YAML default, unless this task has its own separate WORKERS override.

Low

  • [default-consistency] cmd/validate/image.go:59 — The Go-code default for workers remains 5, but before the off-by-one fix the effective worker count was 6 (<= 5 spawns workers 0–5). The task YAML defaults were each bumped by 1 to preserve effective concurrency (4→5 and 1→2), yet the CLI's own default was not bumped (5→6). Users invoking the CLI directly will silently drop from 6 to 5 effective workers. This appears to be an intentional choice (the default was always meant to be 5), but is worth confirming.

  • [documentation-accuracy] tasks/verify-conforma-konflux-ta/0.1/README.md:34 — The README update replaces the old claim that WORKERS was unused ("All policy evaluations are run with 35 workers") with a note about managed release pipelines overriding via conforma.workerCount in konflux-release-data. This corrects stale documentation and is valuable cleanup, though it goes slightly beyond the minimal off-by-one fix scope.

Previous run

Review

Findings

Low

  • [scope alignment] tasks/verify-enterprise-contract/0.1/verify-enterprise-contract.yaml:186 — The PR description only mentions fixing the off-by-one bug in the worker loop, but the PR also changes default WORKERS values across two task definitions and their documentation, and removes the "currently not used" note from the verify-conforma-konflux-ta README. These changes preserve the previous effective worker counts (since the old <= loop spawned N+1 workers for a configured value of N), but this rationale is not stated in the PR description.
    Remediation: Update the PR description to explain that the default values are bumped by 1 to preserve the previous effective worker counts after the off-by-one fix.

Labels: Bug fix in CLI validate command with documentation updates

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added ready-for-merge All reviewers approved — ready to merge bug Something isn't working cli labels Jul 23, 2026
@joejstuart

Copy link
Copy Markdown
Contributor

The change looks good, I'm just unsure of the impact to the users that modify the workers outside of the task (ie: in konflux-release-data). All configs that modify the count are set to 35, which means we're only taking away 1 worker, so it should be negligible. They could see a little slower runtimes though. In theory it should slow a 10 minute Conforma run by 17 seconds.
The alternative is we live with this bug.

* **HOMEDIR**: Value for the HOME environment variable. (default: "/tekton/home")
* **EFFECTIVE_TIME**: Run policy checks with the provided time. (default: "now")
* **EXTRA_RULE_DATA**: Merge additional Rego variables into the policy data. Use syntax "key=value,key2=value2..." (default: "")
* **WORKERS**: Number of parallel workers to use for policy evaluation. This parameter is currently not used. All policy evaluations are run with 35 workers. (default: "35")

@simonbaird simonbaird Jul 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was some left-over incorrect documentation, right??

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.

Yes, it was stale/incorrect documentation. It was introduced in 5302c52 (fix(ec-1404)) — that commit rewrote this README line to say "This parameter is currently not used. All policy evaluations are run with 35 workers." The "35" likely came from conforma.workerCount: 35 which is set in ~107 ReleasePlanAdmission CRDs in konflux-release-data. However, that workerCount field is never wired to the task's WORKERS param — the release pipelines in release-service-catalog don't pass a WORKERS param at all, so the task YAML default always controlled --workers. The README was wrong from the moment it was written.

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.

Correction to my previous comment: my local clone of release-service-catalog was stale. The upstream konflux-ci/release-service-catalog does pass WORKERS in the managed pipelines (under pipelines/managed/), e.g. https://github.com/konflux-ci/release-service-catalog/blob/main/pipelines/managed/rh-advisories/rh-advisories.yaml — the value comes from $(tasks.collect-task-params.results.extractedValues[0]), which extracts conforma.workerCount: 35 from konflux-release-data.

So for release pipelines, the task default doesn't matter — it gets overridden to 35 (which with the old <= bug meant 36 actual goroutines). The task default only applies when the task is invoked without an explicit WORKERS param (e.g. integration pipelines via verify-conforma-konflux-ta).

The README text "This parameter is currently not used" was still misleading though — the parameter is used, it's just that the release pipelines override it.

The worker loop used <= instead of <, spawning numWorkers+1 goroutines
instead of the intended numWorkers. Bump task defaults to preserve the
effective concurrency users had before the fix:
- verify-conforma-konflux-ta: 4 → 5
- verify-enterprise-contract: 1 → 2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Review · ❌ Failure · Started 8:26 PM UTC · Completed 8:40 PM UTC
Commit: 87c4a29 · View workflow run →

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

Labels

bug Something isn't working cli ready-for-merge All reviewers approved — ready to merge size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants