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

[provider] refactoring kubernetes provider to single reconciler #702

Merged
merged 26 commits into from
Dec 5, 2022

Conversation

chauhanshubham
Copy link
Member

@chauhanshubham chauhanshubham commented Nov 6, 2022

This commit removes separate controllers for gateway API objects, and
works on only a single controller that now watches for all related objects.
Prior to this we had n controllers each watching >=1 resources and pushing
according to the resource map. These pushes happened from these n controllers.
For instance;

  • HTTPRoute controller pushing httproute, service and namespace (for refgrant processing) to the resource map
  • every route controller duplicating this process
  • Gateway controller pushing gateways, referencegrants, namespace, secret to the resource map
  • essentially every controller pushing it's namespace to the resource map

Now:
We have a single gatewayAPIController that has a single gatewayAPIReconciler, which reconciles
the gatewayClass object while watching for ALL gateway API objects. Any CRUD in these related
objects, triggers the same reconciliation logic, where the resource structure is created from scratch,
and pushed as is to the resource map.
Any error during reconciliation - particularly around any object not being found (non-existant/deleted resource),
skips the reconciliation around that particular update, and therefore does not lead to a push to
the resource map. Therefore, the push ONLY happens when all related objects exist - once per reconciliation.

A few tests are not required so those have been removed - we could work towards adding more
meaningful ones subsequently. Conformance tests remain as is, with two new additions as part of
this PR (commented out reference grant ones)

Signed-off-by: Shubham Chauhan shubham@tetrate.io

Resolves #413
Resolves #539

@chauhanshubham chauhanshubham changed the title refactoring kubernetes provider to single reconciler [provider] refactoring kubernetes provider to single reconciler: [wip] Nov 6, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2022

Codecov Report

Merging #702 (3bb2362) into main (923c4b0) will decrease coverage by 2.19%.
The diff coverage is 47.02%.

@@            Coverage Diff             @@
##             main     #702      +/-   ##
==========================================
- Coverage   63.67%   61.47%   -2.20%     
==========================================
  Files          47       46       -1     
  Lines        5949     5649     -300     
==========================================
- Hits         3788     3473     -315     
- Misses       1921     1949      +28     
+ Partials      240      227      -13     
Impacted Files Coverage Δ
internal/cmd/server.go 8.10% <0.00%> (+0.48%) ⬆️
internal/gatewayapi/helpers_v1alpha2.go 20.63% <0.00%> (-8.26%) ⬇️
internal/gatewayapi/translator.go 85.34% <ø> (ø)
internal/gatewayapi/zz_generated.deepcopy.go 0.00% <0.00%> (ø)
internal/message/types.go 0.00% <0.00%> (-75.00%) ⬇️
internal/provider/kubernetes/kubernetes.go 58.53% <0.00%> (+7.59%) ⬆️
internal/status/status.go 0.00% <0.00%> (ø)
internal/gatewayapi/runner/runner.go 32.91% <11.11%> (-23.34%) ⬇️
internal/provider/kubernetes/predicates.go 49.65% <49.65%> (ø)
internal/provider/kubernetes/controller.go 52.13% <52.13%> (ø)
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@arkodg arkodg added this to the 0.3.0-rc.1 milestone Nov 7, 2022
@arkodg arkodg added provider/kubernetes Issues related to the Kubernetes provider priority/high Label used to express the "high" priority level labels Nov 7, 2022
@chauhanshubham
Copy link
Member Author

oh god all the tests passed :')

@chauhanshubham
Copy link
Member Author

chauhanshubham commented Nov 12, 2022

so brute force single controller is working (all based on existing tests)
On to a few more manual tests and @arkodg 's review comments and a few enhancements here and there if possible.
Manual tests would mostly cover experimenting with obj creation ordering.

@arkodg
Copy link
Contributor

arkodg commented Nov 17, 2022

hey @chauhanshubham did you get a chance to review the comments ?

@chauhanshubham chauhanshubham force-pushed the provider-refactor branch 5 times, most recently from 4ef5b14 to 63756e0 Compare November 20, 2022 21:28
@chauhanshubham chauhanshubham marked this pull request as ready for review November 20, 2022 21:41
@chauhanshubham chauhanshubham requested a review from a team as a code owner November 20, 2022 21:41
internal/status/status.go Outdated Show resolved Hide resolved
@chauhanshubham chauhanshubham changed the title [provider] refactoring kubernetes provider to single reconciler: [wip] [provider] refactoring kubernetes provider to single reconciler Nov 21, 2022
Copy link
Contributor

@danehans danehans left a comment

Choose a reason for hiding this comment

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

@chauhanshubham thanks for all your work on this PR. I have a few notes and questions that I would like your feedback on.

api/config/v1alpha1/groupversion_info.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/status/status.go Outdated Show resolved Hide resolved
internal/provider/kubernetes/helpers.go Show resolved Hide resolved
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Copy link
Contributor

@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 @chauhanshubham for taking this on, just a couple comments/questions so far. Still working my way through things.

internal/provider/kubernetes/controller.go Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
internal/message/types.go Show resolved Hide resolved
internal/provider/kubernetes/controller.go Outdated Show resolved Hide resolved
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
chauhanshubham and others added 4 commits December 2, 2022 23:05
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: danehans <daneyonhansen@gmail.com>
Adds Gateway Deletion Support to Controller
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
@danehans
Copy link
Contributor

danehans commented Dec 2, 2022

@chauhanshubham I found a regression when testing this PR. gateway.status.listeners[].attachedRoutes is not being calculated properly.

Reproducer:

  1. Create a cluster.
  2. Install EG using your branch.
  3. Install quickstart (verify that you can curl the example app). Check the Gateway status and you should see attachedRoutes: 1.
  4. Create a 2nd listener.
  5. Check the Gateway status again. You should see 2 listeners, each with attachedRoutes: 2 when each listener should reflect attachedRoutes: 1 (I confirmed this is the case using the latest release).

When I add a log statement to the end of the reconcile() method, it appears that duplicate httproute entries exist in the watchable map. From reviewing the contents of the watchable map, it appears the same issue exists for services.

Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
@danehans danehans self-requested a review December 5, 2022 18:04
Copy link
Contributor

@danehans danehans left a comment

Choose a reason for hiding this comment

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

I have tested this PR locally and all looks good. I see #773 and #774 in my testing, but these bugs are not associated with this PR.

@danehans
Copy link
Contributor

danehans commented Dec 5, 2022

Merging since this PR is blocking several other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/high Label used to express the "high" priority level provider/kubernetes Issues related to the Kubernetes provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A ReferenceGrant Should Be Removed From Watchable Map When UnReferenced Consider Merging Controllers
5 participants