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

GEP-718: consolidation of ServiceName in RouteForwardTo #719

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

hbagdi
Copy link
Contributor

@hbagdi hbagdi commented Jul 13, 2021

What type of PR is this?

/kind gep
What this PR does / why we need it:
This adds a GEP for droping ServiceName field from RouteForwardTo(#718)

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added kind/gep PRs related to Gateway Enhancement Proposal(GEP) cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 13, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hbagdi

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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 13, 2021

```go
// RouteForwardTo defines how a Route should forward a request.
type RouteForwardTo struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to put an indicator as to if there are changes to the long comment text

like this?

// no change
// blah blah blah    <<
// no change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bowei I added another summarized diff in the proposal for a clearer understanding of what is changing. PTAL.

@bowei
Copy link
Contributor

bowei commented Jul 15, 2021

/hold (in case of accidental merge)

This looks reasonable to me

LGTM

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2021

## Note on future consolidation

It has been noted that `forwardTo` doesn't flow as good as `backendRefs`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Question - why wait to make this consolidation? Every change will be harder in the future and v1alpha2 is the best milestone to make these changes. The forwardTo block has a big impact on the YAML size and new user experience. Even the most basic Route with no matches must use it.

Copy link
Contributor Author

@hbagdi hbagdi Jul 15, 2021

Choose a reason for hiding this comment

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

I should have used the word future more carefully.
I'll be writing another small GEP to dedicate a discussion on this matter and then implement this and the future GEP together for v1a2. This is to reach consensus on unrelated areas sooner. Sort of small atomic decisions.

Copy link
Contributor

Choose a reason for hiding this comment

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

My preference is the structure shown here. I read it as "forward to target X, with parameters A,B,C". I don't think that collapsing improves the readability.

@hbagdi
Copy link
Contributor Author

hbagdi commented Jul 15, 2021

/cc @jpeach @youngnick

@hbagdi
Copy link
Contributor Author

hbagdi commented Jul 21, 2021

@robscott @bowei Ping for a review.

@robscott
Copy link
Member

@robscott
Copy link
Member

@hbagdi Thanks for writing this up! This generally LGTM and seems reasonable, but I think I'd rather explore the future consolidation in the same GEP, especially if this and the future consolidation would be part of the v1alpha2 release. I'm hesitant to commit to adding the extra yaml (backend.name vs serviceName) without exploring the other options currently listed as either future expansion or alternatives.

following:

```yaml
backendRefs:
Copy link
Member

Choose a reason for hiding this comment

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

The more I've thought about this, I actually think this approach could make the most sense. It's just as concise as the existing API while also being less confusing. I'm a little concerned that there will not be a way to reference/apply policy to a specific item in this list, but that seems like an edge case to me. In most cases that could be resolved by applying policy either to the route rule or to the backend itself.

//
// +optional
// +kubebuilder:default={kind: "service"}
BackendRef *LocalObjectReference `json:"backendRef,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe TargetRef, if we are considering names :)

@hbagdi
Copy link
Contributor Author

hbagdi commented Jul 22, 2021

I think I'd rather explore the future consolidation in the same GEP, especially if this and the future consolidation would be part of the v1alpha2 release. I'm hesitant to commit to adding the extra yaml (backend.name vs serviceName) without exploring the other options currently listed as either future expansion or alternatives.

Got it. I'll update the GEP to include this. Expect an update early next week.

```yaml
...
forwardTo:
- backendRef:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we remove the backendRef field and just have those fields exist in the RouteForwardTo struct?

You'd end up with this:

forwardTo:
  - name: foo-service-v1
    port: 80
    weight: 80
  - name: foo-service-canary
    port: 80
    weight: 20 
---
forwardTo:
-  name: foo-v1
    kind: server
    group: networking.acme.io
    port: 80
    weight: 80
-  name: foo-v1-canary
    kind: server
    group: networking.acme.io
    port: 80
    weight: 20

Copy link
Contributor

Choose a reason for hiding this comment

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

This is mentioned here (https://github.com/kubernetes-sigs/gateway-api/pull/719/files#diff-200562f21cd2e117d439d1a59d8b3c844217b91f3d6224f34222687e9a8fa5faR267) to move the port/weight fields into the backendRef struct.

I'm suggesting something similar but just the opposite, moving everything into the forwardTo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robscott @youngnick Do you know if this is a violation of the upstream API convention or not?
I lean towards an xRef containing only the reference (as API evolves, having such a standard makes the UX much better, envoy is a good example here) but happy to tweak this if that's helpful.

Copy link
Member

Choose a reason for hiding this comment

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

This is a good question. I can't find anything in the k8s API conventions about this. @lavalamp would it ever be acceptable to include concepts like port or weight in an object reference? We're trying to figure out if we can flatten our API a bit. Essentially translating this:

forwardTo:
- backendRef:
    group: ""
    kind: Service
    name: foo
  port: 80
  weight: 10

to something like this:

backendRefs:
- group: ""
  kind: Service
  name: foo
  port: 80
  weight: 10

Choose a reason for hiding this comment

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

I think additional fields should be fine. As long as they don't collide with any standard fields, or fields we're likely to add. I doubt object references will ever have "port" or "weight" fields so you should be good. @deads2k will probably agree.

@hbagdi
Copy link
Contributor Author

hbagdi commented Jul 28, 2021

@robscott @stevesloka @jpeach I've updated this GEP to include the larger RouteForwardTo rework. Please take another look.

@hbagdi hbagdi requested review from jpeach and robscott July 28, 2021 18:14
@hbagdi hbagdi requested a review from bowei July 28, 2021 18:14
Comment on lines 67 to 68
- Rename `RouteForwardTo.BackendRef` to `RouteForwardTo.TargetRef`
- Rename `RouteForwardTo` to `Backend`
Copy link
Member

Choose a reason for hiding this comment

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

I personally think that forwardTo is better unless we're able to flatten everything into a backendRefs list. In this current proposal we end up with the same levels of nesting (forwardTo.backendRef becomes backends.targetRef). That feels like a slightly different way to accomplish the same thing and I'm not sure it justifies a breaking change.

I am very curious if we could have a list of backendRefs that also included concepts like weight and port. If not, I think I'd prefer to fallback to forwardTo.backendRef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am very curious if we could have a list of backendRefs that also included concepts like weight and port. If not, I think I'd prefer to fallback to forwardTo.backendRef.

I'm fine with flattening those out if we have answers to the concerned raised below in the doc (alternatives).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Read Daniel's comment after posting the above comment, let me update this GEP in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robscott updated the GEP.

type: Exact
values:
env: canary
backends:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestions so far on this name:

  • backendRefs: refs doesn't add much value here
  • targetRefs: target feels a bit too generic here

Choose a reason for hiding this comment

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

Destination and/or source is almost always preferable to "target". Target is ambiguous because it could be talking about the source's target (which is the destination) or the rule's target, (which is often the source).

@mark-church
Copy link
Contributor

mark-church commented Aug 2, 2021

I'll just add my support for this GEP:

  • The new structure is very straightforward and less indentation makes it easier to read.
  • "backend" as a noun will make language very clear when referring to it.
  • It still supports weights, namespaces, and if we add name policy references too.

Given that forwardTo's are probably the most repeated field within the Gateway API, having a concise and generic format will have a big impact.

@hbagdi
Copy link
Contributor Author

hbagdi commented Aug 2, 2021

It still supports weights, namespaces, and if we add name policy references too.

Interesting reference to PolicyReference there.
Since we have flattened out the fields, name is used to identify the backend resource (as in the API resource name).
So, if the same name is used for referencing policy as well, are there any gotchas?

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 for the work on this! Just a few nits and a suggested tweak to the name but otherwise LGTM.

@mark-church
Copy link
Contributor

mark-church commented Aug 2, 2021

Ignore my comment @hbagdi I don't think per-backend policies are a very realistic use-case or are easily implementable. I was thinking per-match policies and I got it mixed up.

@hbagdi
Copy link
Contributor Author

hbagdi commented Aug 3, 2021

@robscott Updated.

@robscott
Copy link
Member

robscott commented Aug 3, 2021

Thanks @hbagdi!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 3, 2021
@robscott
Copy link
Member

robscott commented Aug 3, 2021

I think this has broad enough feedback and consensus to remove the hold.

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2021
@k8s-ci-robot k8s-ci-robot merged commit 43eb1d9 into kubernetes-sigs:master Aug 3, 2021
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/gep PRs related to Gateway Enhancement Proposal(GEP) 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.

8 participants