-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
69b0ef6
to
45e54ff
Compare
This cheats and looks up the MeshGateway directly. In the future, we will need a Workload => xGateway mapper
efc4291
to
e6ba50b
Compare
@@ -9,6 +9,7 @@ import ( | |||
"strings" | |||
|
|||
"github.com/hashicorp/go-multierror" | |||
"golang.org/x/exp/maps" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
const ControllerName = "consul.io/gateway-proxy-controller" | |
const ControllerName = "consul.io/gateway-proxy" |
internal/mesh/internal/controllers/gatewayproxy/fetcher/data_fetcher.go
Outdated
Show resolved
Hide resolved
internal/mesh/internal/controllers/gatewayproxy/fetcher/data_fetcher.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
Description
This PR creates the
gatewayproxy.Controller
, analogous to thesidecarproxy.Controller
but designed to createdProxyStateTemplate
(PST) resources for xGateways. It relies ongateway-kind
being set in the metadata of theWorkload
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