Skip to content

Conversation

nsimons
Copy link
Member

@nsimons nsimons commented May 15, 2023

Needed for #5214.

Some breaking changes have happened in these dependencies which I have addressed, biggest one being the new boolean parameter in ResourceEventHandler.OnAdd that can be used to know whether we are doing an initial sync or not. I believe we can pass false in order to retain old behavior, since we are not using it to know the sync status (yet). For the featuretests I created a simple wrapper to hide this parameter and make the change more manageable.

Keeping in draft until controller-runtime 0.15.0 stable version is released.

Signed-off-by: Niklas Simons [email protected]

}
if tc.gatewayClassParams != nil {
client.WithObjects(tc.gatewayClassParams)
}
if tc.gateway != nil {
client.WithObjects(tc.gateway)
client.WithStatusSubresource(tc.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.

This was a fun debugging journey. Without this line the tests would complain that status field could not be updated:

gatewaies.gateway.networking.k8s.io "gateway-1" not found

The incorrect pluralization is coming from this funky code. Anyway, adding the line above pre-populates the client with the correct "knowledge" of the object and thus it's pluralization form. I think.

@nsimons nsimons added the release-note/none-required Marks a PR as not requiring a release note. Should only be used for very small changes. label May 15, 2023
@codecov
Copy link

codecov bot commented May 15, 2023

Codecov Report

Merging #5362 (d44d8fe) into main (3851633) will increase coverage by 0.00%.
The diff coverage is 29.62%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5362   +/-   ##
=======================================
  Coverage   78.22%   78.23%           
=======================================
  Files         138      138           
  Lines       18414    18413    -1     
=======================================
  Hits        14405    14405           
+ Misses       3733     3732    -1     
  Partials      276      276           
Impacted Files Coverage Δ
cmd/contour/ingressstatus.go 31.57% <0.00%> (ø)
cmd/contour/serve.go 20.23% <0.00%> (+0.02%) ⬆️
internal/contour/metrics.go 71.21% <0.00%> (ø)
internal/provisioner/controller/gateway.go 62.04% <0.00%> (ø)
internal/provisioner/controller/gatewayclass.go 63.86% <0.00%> (ø)
internal/controller/gateway.go 13.10% <40.00%> (ø)
internal/controller/gatewayclass.go 17.02% <50.00%> (ø)
internal/controller/grpcroute.go 25.80% <50.00%> (ø)
internal/controller/httproute.go 25.80% <50.00%> (ø)
internal/controller/tlsroute.go 25.80% <50.00%> (ø)
... and 5 more

@nsimons nsimons marked this pull request as ready for review May 24, 2023 07:30
@nsimons nsimons requested a review from a team as a code owner May 24, 2023 07:31
@nsimons nsimons requested review from skriss and sunjayBhatia and removed request for a team May 24, 2023 07:31
@nsimons nsimons added the area/dependency Issues or PRs related to dependency changes. label May 24, 2023
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.

Thanks @nsimons! This mostly LGTM, just a couple tiny nits

func setup(t *testing.T, opts ...interface{}) (cache.ResourceEventHandler, *Contour, func()) {
// ResourceEventHandlerWrapper wraps the ResourceEventHandler interface from client-go/tools/cache.
// The OnAdd function has a boolean parameter that we do not need for testing.
type ResourceEventHandlerWrapper interface {
Copy link
Member

Choose a reason for hiding this comment

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

ah unfortunate client-go doesn't have this interface, though they would since they do have this: https://github.com/kubernetes/client-go/blob/4cb373f7caddf872f8dd0e0adbed3d0fe7c6aaf7/tools/cache/controller.go#L234-L238

Copy link
Member

Choose a reason for hiding this comment

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

@sunjayBhatia I wonder if this kind of abrupt non-backwards compatible change (the addition of isInInitialList bool parameter) in a hugely popular package could be a sign that client-go developers did not expect people to depend on ResourceEventHandler interface and redefine their own OnAdd etc methods directly? It seemed strange decision to break clients just because of new parameter like that. Maybe they expected users only to instantiate ResourceEventHandlerFuncs struct which you point out, and not define their own like Contour does.

Copy link
Member

Choose a reason for hiding this comment

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

I think the docs on the *Funcs structs imply theyre for usage when you don't need to implement all the methods, so I would expect the authors to know people will rely on the interface itself

there is also *DetailedFuncs here: https://github.com/kubernetes/client-go/blob/4cb373f7caddf872f8dd0e0adbed3d0fe7c6aaf7/tools/cache/controller.go#L264

regardless, unfortunate there was such a change w/o a major version revision

@nsimons nsimons requested a review from skriss May 25, 2023 08:11
Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

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

LGTM, looks like all the relevant deps have been bumped in this PR

I'll add a follow up issue to see if we can take advantage of the new addition to the client-go ResourceEventHandler loop to make our processing of the initial resource list/startup better

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 thanks @nsimons!

@skriss skriss merged commit 68b2bb4 into projectcontour:main May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dependency Issues or PRs related to dependency changes. release-note/none-required Marks a PR as not requiring a release note. Should only be used for very small changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants