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

[NET-6426] Add gateway proxy controller that generates empty proxy state template #19901

Merged
merged 12 commits into from
Dec 21, 2023

Conversation

nathancoleman
Copy link
Member

@nathancoleman nathancoleman commented Dec 11, 2023

Description

This PR creates the gatewayproxy.Controller, analogous to the sidecarproxy.Controller but designed to created ProxyStateTemplate (PST) resources for xGateways. It relies on gateway-kind being set in the metadata of the Workload that the PST is being created for.

#19902 introduced logic to have the sidecar proxy controller skip workloads with this piece of metadata so that the two controllers will not be fighting to write the same PST.

Testing & Reproduction steps

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

@nathancoleman nathancoleman added theme/mesh-gw Track mesh gateway work pr/no-changelog PR does not need a corresponding .changelog entry pr/no-backport labels Dec 11, 2023
@nathancoleman nathancoleman force-pushed the gatewayproxy-controller branch from 69b0ef6 to 45e54ff Compare December 18, 2023 16:32
@nathancoleman nathancoleman changed the title NET-6426 Create ProxyStateTemplate when reconciling MeshGateway resource NET-6426 Create empty ProxyStateTemplate when reconciling MeshGateway resource Dec 18, 2023
@nathancoleman nathancoleman changed the title NET-6426 Create empty ProxyStateTemplate when reconciling MeshGateway resource [NET-6426] Create empty ProxyStateTemplate when reconciling MeshGateway resource Dec 19, 2023
@nathancoleman nathancoleman force-pushed the gatewayproxy-controller branch from efc4291 to e6ba50b Compare December 21, 2023 18:54
@nathancoleman nathancoleman requested review from jm96441n, a team and sarahalsmiller and removed request for a team December 21, 2023 19:09
@nathancoleman nathancoleman marked this pull request as ready for review December 21, 2023 19:10
@nathancoleman nathancoleman requested a review from a team as a code owner December 21, 2023 19:10
@@ -9,6 +9,7 @@ import (
"strings"

"github.com/hashicorp/go-multierror"
"golang.org/x/exp/maps"
Copy link
Member

Choose a reason for hiding this comment

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

kinda off topic but are we planning to move to go 1.21 soon? the maps and slices package are part of the std lib as of that release

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea -- I assume there's a standard cadence that different teams follow @ Hashi

// an owner reference pointing to the corresponding pbmesh.MeshGateway, deletion is
// left to the garbage collector.
func (r *reconciler) Reconcile(ctx context.Context, rt controller.Runtime, req controller.Request) error {
rt.Logger = rt.Logger.With("resource-id", req.ID)
Copy link
Member

Choose a reason for hiding this comment

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

is it possible we'll ever be running this reconciler in more than one thread? if so I don't think this assignment is threadsafe and we might want to use a local var instead

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct. Since virtually every v2 resource controller that exists today uses this pattern, I'm fine leaving it and knowing that any change in the future would have to update all the other controllers as well. Thoughts?

rt.Logger = rt.Logger.With("resource-id", req.ID, "controller", ControllerName)

rt.Logger = rt.Logger.With("resource-id", req.ID, "controller", ControllerName)

and on and on...

Copy link
Member

Choose a reason for hiding this comment

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

All controllers today operate as a single thread. Each dependency mapper IIRC runs in its own goroutine though.

Copy link
Member Author

@nathancoleman nathancoleman left a comment

Choose a reason for hiding this comment

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

Personal review

@@ -41,6 +41,7 @@ flowchart TD
mesh/v2beta1/proxyconfiguration
mesh/v2beta1/proxystatetemplate --> auth/v2beta1/computedtrafficpermissions
mesh/v2beta1/proxystatetemplate --> catalog/v2beta1/service
mesh/v2beta1/proxystatetemplate --> catalog/v2beta1/serviceendpoints
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 graph is generated by the golden file test below

)

// ControllerName is the name for this controller. It's used for logging or status keys.
const ControllerName = "consul.io/gateway-proxy-controller"
Copy link
Member Author

Choose a reason for hiding this comment

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

for consistency with other name changes across consul recently

Suggested change
const ControllerName = "consul.io/gateway-proxy-controller"
const ControllerName = "consul.io/gateway-proxy"

Copy link
Member

@jm96441n jm96441n left a comment

Choose a reason for hiding this comment

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

overall logic looks good to me! few minor comments, but real exciting to see this coming together

@nathancoleman nathancoleman changed the title [NET-6426] Create empty ProxyStateTemplate when reconciling MeshGateway resource [NET-6426] Add gateway proxy controller that generates empty proxy state template Dec 21, 2023
@nathancoleman nathancoleman merged commit ab60fec into main Dec 21, 2023
88 checks passed
@nathancoleman nathancoleman deleted the gatewayproxy-controller branch December 21, 2023 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-backport pr/no-changelog PR does not need a corresponding .changelog entry theme/mesh-gw Track mesh gateway work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants