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

Implementing GEP 724: Refresh Route-Gateway Binding #754

Merged
merged 5 commits into from
Aug 12, 2021

Conversation

robscott
Copy link
Member

@robscott robscott commented Aug 9, 2021

What type of PR is this?
/kind feature

What this PR does / why we need it:
Implements GEP #724

Which issue(s) this PR fixes:
Fixes #724

Does this PR introduce a user-facing change?:

- Routes attach to Gateways with direct object references
- Gateway Route selector has been removed
- Gateway Route group/kind restriction has changed into an optional list

Note: This PR does not include any docs yet. I will follow up with that either in this PR or a follow up.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 9, 2021
@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2021
Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

LGTM

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2021
Copy link
Contributor

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

first pass, looking good

apis/v1alpha2/gateway_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/gateway_types.go Show resolved Hide resolved
apis/v1alpha2/gateway_types.go Show resolved Hide resolved
apis/v1alpha2/gateway_types.go Show resolved Hide resolved
apis/v1alpha2/gateway_types.go Outdated Show resolved Hide resolved
@@ -41,17 +41,29 @@ type TCPRoute struct {

// TCPRouteSpec defines the desired state of TCPRoute
type TCPRouteSpec struct {
// ParentRefs references the resources that can attach to this Route. The
Copy link
Contributor

Choose a reason for hiding this comment

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

// ParentRefs references the resources that can attach to this Route. The

Instead of resources, just use Gateway for now. Optimize for the vast majority.

Copy link
Member Author

Choose a reason for hiding this comment

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

Rewrote a good chunk of this, hopefully it's clearer now.

apis/v1alpha2/udproute_types.go Outdated Show resolved Hide resolved
examples/v1alpha2/http-redirect.yaml Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2021
@hbagdi hbagdi linked an issue Aug 9, 2021 that may be closed by this pull request
@robscott robscott force-pushed the gep-724-implementation branch 2 times, most recently from 1edfec1 to 5a758ad Compare August 10, 2021 00:00
//
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
Kind string `json:"kind"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a status that should be set if the Kind is invalid or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a great question, but unfortunately I don't have a good answer. This is one of the many situations where it would be unclear which controller was responsible for communicating that status. Of course every controller only knows the resources it supports, not what other implementations may support. I think the best indication of this for now would just be if this resource was missing from the RouteParents status altogether since no controller would have added it.

Copy link
Contributor

Choose a reason for hiding this comment

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

  // Kind MUST correspond to kinds of Routes that are compatible with the    
  // application protocol specified in the Listener's Protocol field. If an    
  // implementation does not support or recognize this resource type, it    
  // SHOULD set the "ResolvedRefs" condition to false for this listener with
  // the "InvalidRoutesRef" reason.

ListenerRoutes says this case should raise a status condition (on the gateway).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh woops, I misinterpreted this as a question about an invalid ref from a Route to a Gateway. The answer from @jpeach is completely correct for what was actually being asked here.

apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
@robscott
Copy link
Member Author

Thanks for the great feedback on this @stevesloka @hbagdi and @howardjohn! I think I've responded to everything now, PTAL. I'm planning on covering docs and additional examples in a follow up PR so this one doesn't become too massive.

Copy link
Contributor

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

LGTM overall

apis/v1alpha2/gateway_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/gateway_types.go Outdated Show resolved Hide resolved
// +optional
Hostname *Hostname `json:"hostname,omitempty"`
SupportedKinds []RouteGroupKind `json:"supportedKinds,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

So if this field is not optional, does it mean minItem=1 is automatically imposed? Probably not.
What is the reason for not adding minItem=1 here?

apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/tcproute_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/udproute_types.go Outdated Show resolved Hide resolved
//
// +optional
Hostname *Hostname `json:"hostname,omitempty"`
// +kubebuilder:validation:MaxItems=8
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:validation:MaxItems=8
// +kubebuilder:validation:MaxItems=16

Copy link
Member Author

Choose a reason for hiding this comment

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

At present we only have 4 valid Route kinds, and it's unlikely/impossible that they'd all be valid for a given listener. We can always increase this limit in the future if needed, but I'd be hesitant to start too high here.

//
// Support: Core
Kind string `json:"kind"`
// +kubebuilder:validation:MaxItems=8
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:validation:MaxItems=8
// +kubebuilder:validation:MaxItems=16

Copy link
Member Author

Choose a reason for hiding this comment

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

Same comment as above.

SupportedKinds []RouteGroupKind `json:"supportedKinds,omitempty"`

// AttachedRoutes represents the total number of Routes that have been
// successfully attached to this Listener.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// successfully attached to this Listener.
// successfully attached to this Listener.
//
// +kubebuilder:validation:Minimum=1

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't it valid for this to be 0? No guarantee that a Route will be attached to a Listener.

@jpeach
Copy link
Contributor

jpeach commented Aug 10, 2021

Looks great, just a few nits to tidy up 👍

// Support: Core
//
// +kubebuilder:validation:MaxLength=253
Name string `json:"name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to restrict the name a little more, for example with +kubebuilder:validation:Pattern=`^[0-9A-Za-z_-]+$`.

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL, I didn't know this was even possible.
Out of scope of this PR, should we use this in most places?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I've been thinking this would be a good time to introduce some standard regex validation for these fields as part of v1alpha2.

Copy link
Contributor

Choose a reason for hiding this comment

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

Added #767

Copy link
Member Author

Choose a reason for hiding this comment

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

I completely agree that we should do this, but want to leave this for a follow up PR so we can establish consistent regexes for different types of fields. #767 is in the v1alpha2 milestone so we can make sure it gets in.

apis/v1alpha2/gateway_types.go Outdated Show resolved Hide resolved
Comment on lines 185 to 186
// ParentRef is a reference to the parent resource that the route wants to
// be attached to.
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 status—it should report actual state, not desired state.

Suggested change
// ParentRef is a reference to the parent resource that the route wants to
// be attached to.
// ParentRef is a reference to the parent resource that the route is attached to.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was actually an intentional distinction. We want status to include entries for each parent the Route wants to be attached to so there is a way to explain when an attachment is not allowed and/or being prevented for some reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ParentRef is a reference to the parent resource that the route wants to
// be attached to.
// ParentRef is a reference to the parent resource to which the route's spec
// requests to be attached.

Maybe this? Reads a little awkward, I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree it was confusing. I took another shot at this, let me know what you think

apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
// Otherwise, if an alternative API group is desired, specify the desired
// group:

// Kinds specifies the groups and kinds of Routes that are allowed to bind
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Kinds specifies the groups and kinds of Routes that are allowed to bind
// Kinds specifies the groups and kinds of Routes that are allowed to attach

for consistency and to save me from wondering whether "bind" and "attach" mean different things... which they don't, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not intended to mean anything different, just ended up having more attach terminology in the godocs this time around because the field started with an attachTo name.

apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
@robscott robscott added this to the v1alpha2 milestone Aug 11, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2021
@robscott
Copy link
Member Author

Thanks for the great feedback on this PR! I think I've addressed everything now, PTAL.

@youngnick
Copy link
Contributor

Only a few small nits from me, LGTM otherwise.

@robscott
Copy link
Member Author

Thanks for the feedback @youngnick! PTAL.

@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 Aug 12, 2021
@k8s-ci-robot k8s-ci-robot merged commit f573729 into kubernetes-sigs:master Aug 12, 2021
@robscott robscott mentioned this pull request Aug 18, 2021
10 tasks
@robscott robscott deleted the gep-724-implementation branch January 8, 2022 01:05
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/feature Categorizes issue or PR as related to a new feature. 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
8 participants