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: Gateway Infrastructure Metadata #2845

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 69 additions & 0 deletions conformance/tests/gateway-infrastructure-metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package tests

import (
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"
)

func init() {
ConformanceTests = append(ConformanceTests, GatewayInfraMetadata)
}

var GatewayInfraMetadata = suite.ConformanceTest{
ShortName: "GatewayInfraMetadata",
Description: "A Gateway should accept infrastructure metadata",
Features: []features.SupportedFeature{
features.SupportGateway,
features.SupportGatewayInfrastructureMetadata,
},
Manifests: []string{
"tests/gateway-infrastructure-metadata.yaml",
},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
gwNN := types.NamespacedName{
Name: "gateway-infra-metadata",
Namespace: "gateway-conformance-infra",
}

conditions := []metav1.Condition{
Copy link
Contributor

Choose a reason for hiding this comment

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

imo I dont know this test is very useful, we ideally need a way to retrieve the metatdata from the data plane but since its unique, we are add a conformance test for it

Copy link
Contributor Author

@dprotaso dprotaso Apr 3, 2024

Choose a reason for hiding this comment

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

way to retrieve the metatdata from the data plane

That's implementation specific.

The test really just asserts that we're able to set this property on the infrastructure stanza and it's accepted by the implementation - nothing else.

Also I think it's important to have a Feature enum so end users know they can use this feature and it's surfaced on the GatewayClass

Copy link
Contributor

Choose a reason for hiding this comment

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

so the real use case is to surface the feature in the GatewayClass :) ?

Copy link
Contributor Author

@dprotaso dprotaso Apr 3, 2024

Choose a reason for hiding this comment

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

It's part of it.

Like as an end-user I want to know if a class supports this feature. Likewise if an implementation advertises that then I expect I can set these attributes and the gateway is accepted and programmed. (which this test is doing)

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this one, it's not necessarily wrong, just also not clear that it provides much value. Just being able to set a value doesn't really mean it's not supported, it may just mean the Gateway implementation hasn't gone out of it's way to block this from being set. I know we don't really have strong guidelines for what does or doesn't fit as a conformance test, but this feels like it's on the edge, and I'd lean to say that it doesn't really provide sufficient value.

It seems conceptually similar to confirming that an implementation supports setting TLS options to some arbitrary value, I'm not sure how useful a test like this is without also confirming the desired result.

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'm fine with dropping this conformance tests - I guess I'm trying to answer the question

How do I know which implementations support setting this property and won't fail.

Is the conformance report a good place for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe PR'ing the feature string makes sense and then we enable report generation to include additional features that don't have tests?

{
Type: string(gatewayv1.GatewayConditionAccepted),
Status: metav1.ConditionTrue,
Reason: "", // any reason
},
{
Type: string(gatewayv1.GatewayConditionProgrammed),
Status: metav1.ConditionTrue,
Reason: "", // any reason
},
}

kubernetes.GatewayMustHaveLatestConditions(t, suite.Client, suite.TimeoutConfig, gwNN)
for _, condition := range conditions {
kubernetes.GatewayMustHaveCondition(t, suite.Client, suite.TimeoutConfig, gwNN, condition)
}
},
}
17 changes: 17 additions & 0 deletions conformance/tests/gateway-infrastructure-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: gateway-infra-metadata
namespace: gateway-conformance-infra
spec:
gatewayClassName: "{GATEWAY_CLASS_NAME}"
infrastructure:
labels:
label-key: label-value
annotations:
annotation-key: annotation-value
listeners:
- name: http
port: 8080
protocol: HTTP
18 changes: 18 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ var GatewayExtendedFeatures = sets.New(
SupportGatewayStaticAddresses,
)

// -----------------------------------------------------------------------------
// Features - Gateway Conformance (Experimental)
// -----------------------------------------------------------------------------

const (
// SupportGatewayInfrastructureMetadata option indicates that the Gateway is capable
// having annotations and labels which are propagated to underlying resources
SupportGatewayInfrastructureMetadata SupportedFeature = "GatewayInfrastructureMetadata"
)

// GatewayExperimentalFeatures includes all the supported experimental features, currently only
// available in our experimental release channel.
// Implementations have the flexibility to opt-in for either specific features or the entire set.
var GatewayExperimentalFeatures = sets.New(
SupportGatewayInfrastructureMetadata,
)

// -----------------------------------------------------------------------------
// Features - ReferenceGrant Conformance (Core)
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -255,6 +272,7 @@ var GRPCRouteCoreFeatures = sets.New(
// NOTE: as new feature sets are added they should be inserted into this set.
var AllFeatures = sets.New[SupportedFeature]().
Insert(GatewayCoreFeatures.UnsortedList()...).
Insert(GatewayExperimentalFeatures.UnsortedList()...).
Insert(GatewayExtendedFeatures.UnsortedList()...).
Insert(ReferenceGrantCoreFeatures.UnsortedList()...).
Insert(HTTPRouteCoreFeatures.UnsortedList()...).
Expand Down