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

validation: take parentRef.port into account #1995

Merged

Conversation

howardjohn
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:
Currently, we cannot have:

  parentRefs:
  - name: gw1
    port: 80
  - name: gw1
    port: 8080

This seems like an oversight; our validation only takes sectionName into consideration.

Note: this DOES allow overlapping parentSection selection. For exampe, i may select port=80 and sectionName=http which refer to the same thing. This is not something we can catch in validation. Perhaps we need to clarify the behavior here in the spec, if its not clear. Note this could always happen with 2 different routes anyways, though.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 4, 2023
@k8s-ci-robot k8s-ci-robot requested review from shaneutt and youngnick May 4, 2023 18:36
Currently, we cannot have:

```yaml
  parentRefs:
  - name: gw1
    port: 80
  - name: gw1
    port: 8080
```

This seems like an oversight; our validation only takes sectionName into consideration.

Note: this DOES allow overlapping parentSection selection. For exampe, i may select port=80 and sectionName=http
which refer to the same thing. This is not something we can catch in
validation. Perhaps we need to clarify the behavior here in the spec, if
its not clear. Note this could always happen with 2 different routes
anyways, though.
@youngnick
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 4, 2023
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @howardjohn! Mostly LGTM, but would be helpful to have one more test case.

apis/v1beta1/validation/common_test.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 4, 2023
@howardjohn howardjohn force-pushed the validation/allow-port-specifier branch from 00841bd to ac4a2fb Compare May 5, 2023 00:16
if len(s[0]) == 0 || len(*targetSection) == 0 {
errs = append(errs, field.Required(path.Child("parentRefs"), "sectionNames must be specified when more than one parentRef refers to the same parent"))
if s.UnsortedList()[0] == (parentQualifier{}) || pq == (parentQualifier{}) {
errs = append(errs, field.Required(path.Child("parentRefs"), "sectionNames or port must be specified when more than one parentRef refers to the same parent"))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
errs = append(errs, field.Required(path.Child("parentRefs"), "sectionNames or port must be specified when more than one parentRef refers to the same parent"))
errs = append(errs, field.Required(path.Child("parentRefs"), "sectionNames or ports must be specified when more than one parentRef refers to the same parent"))

@gyohuangxin
Copy link
Member

LGTM, but a small typo. @howardjohn Thanks!

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @howardjohn!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 5, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: howardjohn, 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2023
@k8s-ci-robot k8s-ci-robot merged commit 497e67d into kubernetes-sigs:main May 5, 2023
howardjohn added a commit to howardjohn/istio that referenced this pull request May 17, 2023
istio-testing pushed a commit to istio/istio that referenced this pull request May 18, 2023
* gateway mesh: support `port` field

this was unimplemented.

Depends on kubernetes-sigs/gateway-api#1995

Tested by kubernetes-sigs/gateway-api#1989

* Stable
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/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants