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

conformance against invalid ReferenceGrants in HTTPRoute and TLSRoute #2076

Conversation

meyskens
Copy link
Contributor

What type of PR is this?
/kind test
/area conformance

What this PR does / why we need it:

This PR adds two new conformance tests to test that invalid ReferenceGrants are not getting programmed as well as checking that they are indeed not. It does this check for both HTTPRoutes and TLSRoutes. The list of invalid ReferenceGrants is based on the test in https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-invalid-reference-grant.go

Which issue(s) this PR fixes:

Fixes #2075

Does this PR introduce a user-facing change?:

Add conformance tests against accepting invalid ReferenceGrants in HTTPRoute and TLSRoute

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/test area/conformance labels May 29, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @meyskens!

It looks like this is your first PR to kubernetes-sigs/gateway-api 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/gateway-api has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 29, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @meyskens. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 29, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label May 29, 2023
@meyskens meyskens changed the title Meyskens/aditional referencegrant tests conformance against invalid ReferenceGrants in HTTPRoute and TLSRoute May 30, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 30, 2023
@meyskens meyskens marked this pull request as ready for review May 30, 2023 06:47
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 30, 2023
@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch from da1c97d to af206d2 Compare June 1, 2023 11:49
Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

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

missing from here:

func SetupTimeoutConfig(timeoutConfig *TimeoutConfig) {

	if timeoutConfig.TLSRouteMustHaveCondition == 0 {
		timeoutConfig.TLSRouteMustHaveCondition = defaultTimeoutConfig.TLSRouteMustHaveCondition
	}

@@ -300,6 +300,75 @@ spec:
---
apiVersion: v1
kind: Namespace
metadata:
name: gateway-conformance-tls-backend
Copy link
Member

Choose a reason for hiding this comment

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

could be reuse the existing -app-backend instead of having to create a new namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was doubting to do to that but not entirely too sure about it so I chose to make a separate namespace to make clear boundaries. Happy to revert it and use the app namespace.

Copy link
Member

Choose a reason for hiding this comment

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

i think one of the maintainers may chime in here but I believe we've tried to limit the number of namespaces/resources the tests create to streamline things a bit 👍🏽

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @sunjayBhatia, where possible I think we should reuse the same resources instead of creating new ones for specific use cases.

@sunjayBhatia
Copy link
Member

(with the timeout change, these pass against Contour)

This adds a test comparable to the one for Gateway checking if
ReferenceGrants are not incorrectly accepted.

Signed-off-by: Maartje Eyskens <maartje.eyskens@isovalent.com>
@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch from af206d2 to 6c7fe97 Compare June 5, 2023 08:11
@sunjayBhatia
Copy link
Member

/ok-to-test

@@ -300,6 +300,75 @@ spec:
---
apiVersion: v1
kind: Namespace
metadata:
name: gateway-conformance-tls-backend
Copy link
Member

Choose a reason for hiding this comment

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

I agree with @sunjayBhatia, where possible I think we should reuse the same resources instead of creating new ones for specific use cases.

Copy link
Member

Choose a reason for hiding this comment

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

:+1 I like that you created many ReferenceGrants, each with a possible misconfiguration.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is really great, nicely done @meyskens!

@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch 3 times, most recently from d404197 to b5c82e5 Compare June 26, 2023 12:14
@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch from b5c82e5 to fb72173 Compare June 26, 2023 15:26
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 26, 2023
@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch from fb72173 to 75a582b Compare June 26, 2023 16:02
@robscott robscott added this to the v0.8.0 milestone Jun 26, 2023
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @meyskens! Other than @sunjayBhatia's comment, this mostly LGTM.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is really great, nicely done @meyskens!

conformance/tests/httproute-invalid-reference-grant.go Outdated Show resolved Hide resolved
@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch from 75a582b to 3a12feb Compare June 27, 2023 12:49
@meyskens
Copy link
Contributor Author

/retest


kubernetes.GatewayAndTLSRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)

t.Run("TLSRoute with BackendRef in another namespace and no ReferenceGrant covering the Service has a ResolvedRefs Condition with status False and Reason RefNotPermitted", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

realizing this test only specifies the conditions set on the route with no valid referencegrant to make the backendref in it valid, which is valuable

however, it seems the language on what to do with an invalid backendref needs some more specificity, particularly what "reject" means since this is a "must" statement:

// sent. If unspecified or invalid (refers to a non-existent resource or
// a Service with no endpoints), the rule performs no forwarding; if no
// filters are specified that would result in a response being sent, the
// underlying implementation must actively reject request attempts to this
// backend, by rejecting the connection or returning a 500 status code.

I think we could use a follow up to this PR that clarifies that language (and possibly removes the HTTP 500 reference) and adds coverage to this test

Copy link
Member

Choose a reason for hiding this comment

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

follow up #2153

Copy link
Member

@sunjayBhatia sunjayBhatia left a comment

Choose a reason for hiding this comment

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

LGTM, tests both pass with Contour

one comment here that needs a follow up issue: https://github.com/kubernetes-sigs/gateway-api/pull/2076/files#r1245405876

This checks ReferenceGrant rules for TLSRoute against accepting an
invalid ReferenceGrant for the backend service.

Signed-off-by: Maartje Eyskens <maartje.eyskens@isovalent.com>
@meyskens meyskens force-pushed the meyskens/aditional-referencegrant-tests branch from 3a12feb to e3c6ccc Compare June 29, 2023 08:54
@robscott
Copy link
Member

Thanks @meyskens!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 29, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: meyskens, robscott, sunjayBhatia

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2023
@k8s-ci-robot k8s-ci-robot merged commit 9b839f2 into kubernetes-sigs:main Jun 29, 2023
@meyskens meyskens deleted the meyskens/aditional-referencegrant-tests branch June 30, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/conformance cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/test lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add conformance tests for invalid ReferenceGrants for backends
5 participants