Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jpeach
Copy link
Contributor

@jpeach jpeach commented Jul 31, 2020

The contour.CacheHandler struct contains the xDS resource caches as
embedded members. If we extract a DAG observer interface, however, we
can remove knowledge of specific resources from CacheHandler.
All it really needs is a set of objects that can vist the DAG when it
changes to generate any relevant xDS resources, and that can be called
on to publish those into the xDS GRPC interface.

Separating out the new contour.ResourceCache interface gives us the
opportunity to add new DAG consumers by only having to modify code
when the Contour server starts up. There's no longer any cache handler
plumbing needed.

Once we can compose the xDS caches under the Observer interface, the
need for a separate cache handler struct goes away, and we can attach
everything we need directly to the event handler.

This updates #2775.

@jpeach
Copy link
Contributor Author

jpeach commented Jul 31, 2020

@stevesloka This PR came out of trying to see how we can better integrate EDS with knowledge of the DAG. It heavily conflicts with your go-control-plane refactor, so we probably want to see whether it still makes sense in conjunction with that.

@codecov
Copy link

codecov bot commented Jul 31, 2020

Codecov Report

Merging #2753 into master will decrease coverage by 0.12%.
The diff coverage is 81.02%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2753      +/-   ##
==========================================
- Coverage   76.79%   76.67%   -0.13%     
==========================================
  Files          72       72              
  Lines        5775     5792      +17     
==========================================
+ Hits         4435     4441       +6     
- Misses       1252     1259       +7     
- Partials       88       92       +4     
Impacted Files Coverage Δ
cmd/contour/serve.go 2.56% <0.00%> (ø)
internal/contour/endpointstranslator.go 79.16% <0.00%> (-0.84%) ⬇️
internal/contour/metrics.go 68.00% <77.77%> (+2.14%) ⬆️
internal/e2e/e2e.go 85.92% <86.66%> (-1.49%) ⬇️
internal/contour/listener.go 94.97% <97.05%> (+0.10%) ⬆️
internal/contour/cluster.go 100.00% <100.00%> (ø)
internal/contour/handler.go 78.26% <100.00%> (-0.69%) ⬇️
internal/contour/resources.go 100.00% <100.00%> (ø)
internal/contour/route.go 93.57% <100.00%> (+0.18%) ⬆️
internal/contour/secret.go 100.00% <100.00%> (ø)
... and 5 more

@jpeach
Copy link
Contributor Author

jpeach commented Jul 31, 2020

@stevesloka This PR came out of trying to see how we can better integrate EDS with knowledge of the DAG. It heavily conflicts with your go-control-plane refactor, so we probably want to see whether it still makes sense in conjunction with that.

Alternatively, it might make the go-control-plane change easier 🤷

@stevesloka
Copy link
Member

I ripped out the entire cachehandler in #2604.

@jpeach jpeach force-pushed the decouple-cache-handler branch 2 times, most recently from c2c94f5 to 13c9454 Compare August 7, 2020 02:56
@jpeach
Copy link
Contributor Author

jpeach commented Aug 7, 2020

I ripped out the entire cachehandler in #2604.

🥳 I was able to remove it from this PR too. It's replaced by composing DAG observers.

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me, just a handful of minor comments and a question.

@jpeach jpeach force-pushed the decouple-cache-handler branch from 13c9454 to 04ea6e0 Compare August 9, 2020 23:46
@jpeach
Copy link
Contributor Author

jpeach commented Aug 9, 2020

@skriss @youngnick This is ready for the next review pass. Thanks :)

@jpeach jpeach force-pushed the decouple-cache-handler branch from 04ea6e0 to 69159da Compare August 10, 2020 01:05
Copy link
Member

@youngnick youngnick left a comment

Choose a reason for hiding this comment

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

LGTM. I don't think we've used interface assertions much before. It feels a little bit of a weird syntax for me, but I can see that it's useful. If we're going to add them, we should either do it for everything or not do it though, I think.

@jpeach jpeach force-pushed the decouple-cache-handler branch from 69159da to 3e3ae0d Compare August 10, 2020 04:27
@jpeach
Copy link
Contributor Author

jpeach commented Aug 10, 2020

LGTM. I don't think we've used interface assertions much before. It feels a little bit of a weird syntax for me, but I can see that it's useful. If we're going to add them, we should either do it for everything or not do it though, I think.

I removed these.

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM

The `contour.CacheHandler` struct contains the xDS resource caches as
embedded members. If we extract a DAG observer interface, however, we
can remove knowledge of specific resources from `CacheHandler`.
All it really needs is a set of objects that can vist the DAG when it
changes to generate any relevant xDS resources, and that can be called
on to publish those into the xDS GRPC interface.

Separating out the new `contour.ResourceCache` interface gives us the
opportunity to add new DAG consumers by only having to modify code
when the Contour server starts up. There's no longer any cache handler
plumbing needed.

Once we can compose the xDS caches under the `Observer` interface, the
need for a separate cache handler struct goes away, and we can attach
everything we need directly to the event handler.

This updates projectcontour#2775.

Signed-off-by: James Peach <[email protected]>
@jpeach jpeach force-pushed the decouple-cache-handler branch from 3e3ae0d to ff326b2 Compare August 10, 2020 21:45
@jpeach jpeach merged commit ef09d9d into projectcontour:master Aug 10, 2020
@jpeach jpeach deleted the decouple-cache-handler branch August 10, 2020 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants