Skip to content

fix(webhook): add separator between PodGroup validation errors#5487

Merged
volcano-sh-bot merged 2 commits into
volcano-sh:masterfrom
aeron-gh:fix/podgroup-validate-error-separator
Jul 9, 2026
Merged

fix(webhook): add separator between PodGroup validation errors#5487
volcano-sh-bot merged 2 commits into
volcano-sh:masterfrom
aeron-gh:fix/podgroup-validate-error-separator

Conversation

@aeron-gh

Copy link
Copy Markdown
Contributor

Fixes #5443

What this fixes

validatePodGroup built its rejection message by appending each validator's output with += and no separator:

errMsg += checkQueueState(pg.Spec.Queue)
errMsg += validateNetworkTopology(pg.Spec.NetworkTopology, pg.Spec.SubGroupPolicy)

So when a PodGroup failed more than one check at once (for example a non-existent queue and an invalid networkTopology), the two messages ran together mid-sentence and the rejection was hard to read.

This collects each non-empty message into a slice and joins them with "; ", so the errors are reported as distinct, readable items. An empty slice still joins to "", so the valid (no-error) path is unchanged.

Test

Added a case to TestValidatePodGroup that fails both the queue and the networkTopology checks at the same time, and asserts the resulting message contains both fragments and the "; " separator.


cc @DevMhrn — you mentioned on the issue that you might pick this up. I already had the fix and test ready so I went ahead and opened it, but happy to defer or close this if you'd rather take it. Either way, no problem at all.

Copilot AI review requested due to automatic review settings June 23, 2026 09:56
@volcano-sh-bot volcano-sh-bot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 23, 2026
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

Welcome @aeron-gh! It looks like this is your first PR to volcano-sh/volcano 🎉

@volcano-sh-bot volcano-sh-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 23, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the validatePodGroup function to collect multiple validation errors into a slice and join them with a semicolon separator, rather than concatenating them directly. It also adds a test case to verify this behavior. The review feedback highlights two important improvements: trimming whitespace from individual error messages to prevent formatting issues when they are joined, and adding a nil-pointer guard in the test runner to prevent potential panics when asserting on the response message.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/webhooks/admission/podgroups/validate/validate_podgroup.go
Comment thread pkg/webhooks/admission/podgroups/validate/validate_podgroup_test.go Outdated

Copilot AI left a comment

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.

Pull request overview

Improves readability of PodGroup admission webhook rejection messages when multiple validations fail by separating individual error fragments, and adds a regression test to cover the multi-error case described in #5443.

Changes:

  • Collects non-empty validation error messages and joins them with "; " in validatePodGroup.
  • Adds a table-driven test case ensuring both queue and networkTopology validation errors appear with the separator.
  • Extends the test table with msgContains assertions for message content.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/webhooks/admission/podgroups/validate/validate_podgroup.go Joins multiple validation error strings with a "; " separator instead of concatenating directly.
pkg/webhooks/admission/podgroups/validate/validate_podgroup_test.go Adds a regression test case and message substring assertions for the separated multi-error output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/webhooks/admission/podgroups/validate/validate_podgroup.go
Comment thread pkg/webhooks/admission/podgroups/validate/validate_podgroup_test.go
@aeron-gh
aeron-gh force-pushed the fix/podgroup-validate-error-separator branch from adf0ef9 to ab90269 Compare June 23, 2026 10:02
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 23, 2026
@aeron-gh

Copy link
Copy Markdown
Contributor Author

Gentle ping on this one CI is green and it's a pretty small change. Could someone take a look when you have a moment? Happy to rebase or tweak anything if needed. Thanks!
cc @hajnalmt

validatePodGroup joined each validator's result with += and no
separator, so a PodGroup failing more than one check (for example a
non-existent queue plus an invalid networkTopology) produced a run-on
message that was hard to read.

Collect the non-empty messages into a slice and join them with "; ".
Also add a test that fails both checks and verifies the separator.

Signed-off-by: aeron-gh <agab0323@gmail.com>
@aeron-gh
aeron-gh force-pushed the fix/podgroup-validate-error-separator branch from ab90269 to 1d90b88 Compare July 6, 2026 22:07
@aeron-gh

aeron-gh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

/kind bug

Rebased this onto the latest master since it had fallen a bit behind, so CI is green again. It's a small, self-contained webhook fix, would really appreciate a review whenever someone gets a spare moment. Happy to tweak anything if needed. Thanks!

@volcano-sh-bot volcano-sh-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 6, 2026
@aeron-gh

aeron-gh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@hajnalmt could you take a quick look when you have a moment? It's a small, self-contained webhook fix and CI is green. Thanks!

@hajnalmt hajnalmt left a comment

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.

/area webhooks

Thanks for the PR! The test and the fix looks ok, please add the bot suggestions they are useful additions.

Comment thread pkg/webhooks/admission/podgroups/validate/validate_podgroup.go
Comment thread pkg/webhooks/admission/podgroups/validate/validate_podgroup_test.go
Trim each validation message before joining so the combined output has
no stray space before the "; " separator when a helper returns a message
with trailing whitespace. Also guard the test's message assertion against
a nil Result to avoid a possible nil-pointer panic on allowed responses.

Signed-off-by: aeron-gh <agab0323@gmail.com>
@aeron-gh

aeron-gh commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

/retest

the failure in Verify codes, generated files is an unrelated flake, nothing to do with this webhook change. The podgroups/validate tests pass. Re-running to confirm green.

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

@aeron-gh: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

Heads-up: the failure in Verify codes, generated files is an unrelated flake in TestNodeAdditionAndDeletion (pkg/controllers/sharding) — an async node-assignment race, nothing to do with this webhook change. The podgroups/validate tests pass. Re-running to confirm green.

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/test-infra repository.

@aeron-gh aeron-gh closed this Jul 8, 2026
@aeron-gh aeron-gh reopened this Jul 8, 2026
@aeron-gh

aeron-gh commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

thanks @hajnalmt both applied trimmed the messages before joining, and added the nil result guard in the test. CI is gren now

@hajnalmt hajnalmt left a comment

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.

/label tide/merge-method-squash
/lgtm
/approve

Thank you for the contribution!

@volcano-sh-bot volcano-sh-bot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. lgtm Indicates that a PR is ready to be merged. labels Jul 9, 2026
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hajnalmt

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

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2026
@volcano-sh-bot
volcano-sh-bot merged commit 28160f1 into volcano-sh:master Jul 9, 2026
58 of 59 checks passed
@aeron-gh
aeron-gh deleted the fix/podgroup-validate-error-separator branch July 10, 2026 09:40
yash-pokhriyal pushed a commit to yash-pokhriyal/volcano that referenced this pull request Jul 13, 2026
…no-sh#5487)

* fix(webhook): add separator between PodGroup validation errors

validatePodGroup joined each validator's result with += and no
separator, so a PodGroup failing more than one check (for example a
non-existent queue plus an invalid networkTopology) produced a run-on
message that was hard to read.

Collect the non-empty messages into a slice and join them with "; ".
Also add a test that fails both checks and verifies the separator.

Signed-off-by: aeron-gh <agab0323@gmail.com>

* fix(webhook): trim joined PodGroup validation errors and guard test

Trim each validation message before joining so the combined output has
no stray space before the "; " separator when a helper returns a message
with trailing whitespace. Also guard the test's message assertion against
a nil Result to avoid a possible nil-pointer panic on allowed responses.

Signed-off-by: aeron-gh <agab0323@gmail.com>

---------

Signed-off-by: aeron-gh <agab0323@gmail.com>
yash-pokhriyal pushed a commit to yash-pokhriyal/volcano that referenced this pull request Jul 13, 2026
…no-sh#5487)

* fix(webhook): add separator between PodGroup validation errors

validatePodGroup joined each validator's result with += and no
separator, so a PodGroup failing more than one check (for example a
non-existent queue plus an invalid networkTopology) produced a run-on
message that was hard to read.

Collect the non-empty messages into a slice and join them with "; ".
Also add a test that fails both checks and verifies the separator.

Signed-off-by: aeron-gh <agab0323@gmail.com>

* fix(webhook): trim joined PodGroup validation errors and guard test

Trim each validation message before joining so the combined output has
no stray space before the "; " separator when a helper returns a message
with trailing whitespace. Also guard the test's message assertion against
a nil Result to avoid a possible nil-pointer panic on allowed responses.

Signed-off-by: aeron-gh <agab0323@gmail.com>

---------

Signed-off-by: aeron-gh <agab0323@gmail.com>
Signed-off-by: yash-pokhriyal <er.yash.pokhriyal@gmail.com>
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. area/webhooks kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PodGroup admission webhook concatenates multiple validation errors without a separator

4 participants