Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

gateway-controller: watch ReferencePolicy lifecycle #207

Merged
merged 11 commits into from
Jun 2, 2022

Conversation

nathancoleman
Copy link
Member

@nathancoleman nathancoleman commented Jun 2, 2022

Changes proposed in this PR:

Add a watch so that Gateways are reconciled when a ReferencePolicy change occurs

How I've tested this PR:

  • Added e2e test where Gateway is created without ReferencePolicy then the ReferencePolicy is created, correctly adjusting the Gateway's status
  • Manual testing of create + delete of ReferencePolicy, checking that the Gateway status is updated appropriately

How I expect reviewers to test this PR:

Checklist:

  • Tests added
  • CHANGELOG entry added

    Run make changelog-entry for guidance in authoring a changelog entry, and
    commit the resulting file, which should have a name matching your PR number.
    Entries should use imperative present tense (e.g. Add support for...)

@nathancoleman nathancoleman marked this pull request as ready for review June 2, 2022 21:04
@@ -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 {
Copy link
Member

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.

Copy link
Member

@sarahalsmiller sarahalsmiller left a 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.

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

internal/commands/server/k8s_e2e_test.go Show resolved Hide resolved
internal/commands/server/k8s_e2e_test.go Show resolved Hide resolved
@nathancoleman nathancoleman merged commit 358445d into main Jun 2, 2022
@nathancoleman nathancoleman deleted the gw-refpolicy-lifecycle branch June 2, 2022 21:54
Copy link
Contributor

@mikemorris mikemorris left a 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

Comment on lines +1293 to +1297
AllowedRoutes: &gateway.AllowedRoutes{
Namespaces: &gateway.RouteNamespaces{
From: &fromSelector,
},
},
Copy link
Contributor

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.

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'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
Copy link
Contributor

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.

Copy link
Member Author

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
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants