-
Notifications
You must be signed in to change notification settings - Fork 16
gateway-controller: watch ReferencePolicy lifecycle #207
Conversation
Creating a Gateway in a namespace other than the one set up for the test encounters issues such as a ServiceAccount that doesn't exist in the newly-created namespace
d145db3
to
aee35c7
Compare
@@ -1565,15 +1671,13 @@ func createHTTPSListener(ctx context.Context, t *testing.T, port gateway.PortNum | |||
} | |||
} | |||
|
|||
func createGateway(ctx context.Context, t *testing.T, resources *resources.Resources, gatewayName string, gc *gateway.GatewayClass, listeners []gateway.Listener) *gateway.Gateway { | |||
func createGateway(ctx context.Context, t *testing.T, resources *resources.Resources, gatewayName, gatewayNamespace string, gc *gateway.GatewayClass, listeners []gateway.Listener) *gateway.Gateway { |
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.
We might consider making a createGatewayWithParams wrapper that matches the createGatewayClassWithParams pattern that Mike set up, but thats a nitpick.
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.
Looks good, has tests and makes sense to me.
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
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.
Late reviewing but LGTM
AllowedRoutes: &gateway.AllowedRoutes{ | ||
Namespaces: &gateway.RouteNamespaces{ | ||
From: &fromSelector, | ||
}, | ||
}, |
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 config (and fromSelector := gateway.NamespacesFromAll
above) seems extraneous, doesn't look like any routes are attaching to the gateway in this test.
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're correct that there are no routes attaching. I kinda assumed things would break if we didn't have this minimal config here but didn't dig in to find out for sure.
var matches []gateway.Gateway | ||
|
||
for _, from := range refPolicy.Spec.From { | ||
// TODO: search by from.Group and from.Kind instead of assuming this ReferencePolicy references a Gateway |
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.
Could we open an issue tracking this TODO now that we have three different controllers implementing similar logic? Could be a good first issue for a potential contributor.
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.
I might just contribute the change - I think it amounts to just early outing before querying all Gateways, but I didn't want to throw that into this PR and complicate testing and whatnot. Thoughts?
if from.Group != "" || from.Kind != "Secret" {
continue
}
Changes proposed in this PR:
Add a watch so that Gateways are reconciled when a
ReferencePolicy
change occursHow I've tested this PR:
How I expect reviewers to test this PR:
Checklist: