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

validate Gateway listener protocols/ports/hostnames #4462

Merged
merged 7 commits into from
Apr 14, 2022

Conversation

skriss
Copy link
Member

@skriss skriss commented Apr 13, 2022

Ensures that there is at most one insecure
port and one secure port across all Gateway
listeners, and that hostnames are unique
within the groups of insecure and secure
listeners, respectively.

Closes #4439.

Leaving as a draft for now to do some more manual testing + ensure coverage is good, also feel free to poke holes in the model, definitely possible I've misinterpreted something.

skriss added 5 commits April 13, 2022 16:59
Adds validation to both the Gateway provisioner
and the Gateway API DAG processor to check HTTP
protocol listeners to ensure a single port, and
no hostname conflicts. The provisioner uses this
to configure the correct port on the Envoy service,
and the DAG processor uses it to set listener
conditions and process only valid listeners.

Signed-off-by: Steve Kriss <krisss@vmware.com>
Signed-off-by: Steve Kriss <krisss@vmware.com>
Signed-off-by: Steve Kriss <krisss@vmware.com>
Signed-off-by: Steve Kriss <krisss@vmware.com>
Updates the Envoy service provisioning code to only
use ports from the listeners, instead of using defaults
if not specified in the model.

Signed-off-by: Steve Kriss <krisss@vmware.com>
@codecov
Copy link

codecov bot commented Apr 13, 2022

Codecov Report

Merging #4462 (f63a772) into main (7b0b73c) will increase coverage by 0.16%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4462      +/-   ##
==========================================
+ Coverage   76.48%   76.65%   +0.16%     
==========================================
  Files         138      139       +1     
  Lines       12433    12490      +57     
==========================================
+ Hits         9510     9574      +64     
+ Misses       2674     2669       -5     
+ Partials      249      247       -2     
Impacted Files Coverage Δ
internal/dag/gatewayapi_processor.go 95.55% <100.00%> (+<0.01%) ⬆️
internal/gatewayapi/listeners.go 100.00% <100.00%> (ø)
internal/provisioner/controller/gateway.go 48.93% <100.00%> (+4.43%) ⬆️
internal/provisioner/objects/service/service.go 71.96% <100.00%> (-1.32%) ⬇️
internal/envoy/v3/listener.go 98.51% <0.00%> (+0.03%) ⬆️

Signed-off-by: Steve Kriss <krisss@vmware.com>
@skriss skriss added the release-note/small A small change that needs one line of explanation in the release notes. label Apr 13, 2022
@skriss
Copy link
Member Author

skriss commented Apr 13, 2022

Looking pretty good in manual testing as well, marking ready for review.

@skriss skriss marked this pull request as ready for review April 13, 2022 22:58
@skriss skriss requested a review from a team as a code owner April 13, 2022 22:58
@skriss skriss requested review from tsaarni, stevesloka, sunjayBhatia and youngnick and removed request for a team, tsaarni and stevesloka April 13, 2022 22:58
}

// All listeners with a protocol of "HTTP" must use the same port number
// Heuristic: the first port number encountered is allowed, any other listeners with a different port number are marked "Detached" with "PortUnavailable"
Copy link
Member

Choose a reason for hiding this comment

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

this may be something to call out in a doc somewhere, i dont think this specific grouping/heuristic is in the gateway docs themselves (looking at the Listeners field documentation here https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.Gateway)

Copy link
Member Author

@skriss skriss Apr 14, 2022

Choose a reason for hiding this comment

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

Yeah, this is really a Contour-specific thing since we only support 2 ports total right now. Agree we should call this out somewhere - need to figure out where to put docs for all this, but let me add this to a new issue.

@skriss skriss mentioned this pull request Apr 14, 2022
1 task
Signed-off-by: Steve Kriss <krisss@vmware.com>
@sunjayBhatia
Copy link
Member

looks good! simple logic for determining conflicts/choosing a port 👍🏽 seems right that the provisioner will do similar collection of listeners to program an envoy service but contour can do the more detailed validation and set status

@skriss
Copy link
Member Author

skriss commented Apr 14, 2022

seems right that the provisioner will do similar collection of listeners to program an envoy service but contour can do the more detailed validation and set status

Yeah originally i was thinking they'd both need to set status, which requires more care in terms of ensuring they're not fighting with each other (a la the discussions we were having ~18 months ago), though I think would've been doable given it's all now a single codebase, but realized that it was probably fine to just have Contour itself set the status, the provisioner just needs to find out what ports to configure. We'll see if any issues pop up with that model, but I think it works pretty well actually.

@skriss skriss merged commit ec23ef7 into projectcontour:main Apr 14, 2022
@skriss skriss deleted the listener-validation branch April 14, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/small A small change that needs one line of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gateway API: handle multiple listeners properly across provisioner and xds server
2 participants