Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CEL tests for v1.28+ #3325

Merged
merged 1 commit into from
Sep 10, 2024
Merged

Conversation

robscott
Copy link
Member

@robscott robscott commented Sep 9, 2024

What type of PR is this?
/kind cleanup
/kind failing-test

What this PR does / why we need it:
As @mlavacca discovered in #3316, our CEL tests were failing in v1.28+. Fortunately it was just a variety of changes to how error messages are presented to users. I've also tested these changes against v1.27 and v1.29.

Does this PR introduce a user-facing change?:

NONE

/cc @gauravkghildiyal @jpbetz

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Sep 9, 2024
@k8s-ci-robot k8s-ci-robot requested a review from jpbetz September 9, 2024 23:32
@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 9, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 9, 2024
Comment on lines +68 to +75
// Starting in k8s v1.28, CEL error messages stopped adding spec and status prefixes to path names
wantLAdjusted := strings.ReplaceAll(wantL, "spec.", "")
wantLAdjusted = strings.ReplaceAll(wantLAdjusted, "status.", "")

// Enum validation messages changed in k8s v1.28:
// Before: must be one of ['Exact', 'PathPrefix', 'RegularExpression']
// After: supported values: "Exact", "PathPrefix", "RegularExpression"
if strings.Contains(wantLAdjusted, "must be one of") {
Copy link
Member Author

Choose a reason for hiding this comment

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

@jpbetz do you know of any other changes on the horizon for CEL error messages? Any better ideas for how we can make tests like this both support multiple versions and ensure that we're returning useful error messages to users? As long as this set of workarounds remains small, I think this is ~OK, but would hate to turn this into a massive function.

Copy link

@jpbetz jpbetz Sep 10, 2024

Choose a reason for hiding this comment

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

I'm not aware of any on the horizon.. we're trying to apply a light touch to these things as we do understand Hyrum's law is in full effect. But we'll keep a close eye out.

cc @TristonianJones @cici37 for visibility

Choose a reason for hiding this comment

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

Those errors don't look like they're from CEL itself, but perhaps would be from some layer up the stack within K8s maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the quick responses! Definitely get that this is Hyrum's law in practice, just wondering if there's anywhere we can easily track potential upstream changes.

Copy link

@jpbetz jpbetz Sep 10, 2024

Choose a reason for hiding this comment

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

I looked more closely.

I don't believe the enum error is from CEL specifically. Although it is from openapi so still under api-machinery. This might be more durably matched by checking the error type, which consistently be FieldValueNotSupported. We do sometimes change error strings, but the error types are fixed.

The removal of status and spec prefixes on path names is surprising, and does not look correct. @cici37 would you look more closely at this issue?

@robscott
Copy link
Member Author

/retest

@gauravkghildiyal
Copy link
Member

Thanks a lot @robscott for taking this on!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 10, 2024
@k8s-ci-robot k8s-ci-robot merged commit f2be511 into kubernetes-sigs:main Sep 10, 2024
8 checks passed
@mlavacca
Copy link
Member

/cherrypick release-1.1

@k8s-infra-cherrypick-robot
Copy link
Contributor

@mlavacca: #3325 failed to apply on top of branch "release-1.1":

Applying: Fix CEL tests for v1.28+
Using index info to reconstruct a base tree...
M	pkg/test/cel/backendtlspolicy_test.go
A	pkg/test/cel/gateway_experimental_test.go
M	pkg/test/cel/grpcroute_test.go
M	pkg/test/cel/httproute_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/test/cel/httproute_test.go
Auto-merging pkg/test/cel/grpcroute_test.go
CONFLICT (modify/delete): pkg/test/cel/gateway_experimental_test.go deleted in HEAD and modified in Fix CEL tests for v1.28+. Version Fix CEL tests for v1.28+ of pkg/test/cel/gateway_experimental_test.go left in tree.
Auto-merging pkg/test/cel/backendtlspolicy_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Fix CEL tests for v1.28+

In response to this:

/cherrypick release-1.1

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.

mlavacca pushed a commit to mlavacca/gateway-api that referenced this pull request Oct 28, 2024
k8s-ci-robot pushed a commit that referenced this pull request Oct 28, 2024
* Fix CEL tests for v1.28+ (#3325)

* feat: validate CRDs on specific k8s versions (#3316)

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>

* finalize verify->crds-validation migration (#3330)

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>

* Fixing kind v1.30 image ref (#3329)

---------

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
Co-authored-by: Rob Scott <robertjscott@google.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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants