Skip to content

Commit

Permalink
feat: add supported features to gateway class
Browse files Browse the repository at this point in the history
Signed-off-by: Kobi Levi <[email protected]>
  • Loading branch information
levikobi committed May 12, 2024
1 parent c30d09f commit a15245e
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,34 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRouteParentRefPort
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRouteParentRefPort
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@
"reason": "Accepted",
"message": "Valid GatewayClass"
}
],
"supportedFeatures": [
"GRPCRoute",
"Gateway",
"GatewayHTTPListenerIsolation",
"GatewayPort8080",
"GatewayStaticAddresses",
"HTTPRoute",
"HTTPRouteBackendProtocolH2C",
"HTTPRouteBackendProtocolWebSocket",
"HTTPRouteBackendRequestHeaderModification",
"HTTPRouteBackendTimeout",
"HTTPRouteDestinationPortMatching",
"HTTPRouteHostRewrite",
"HTTPRouteMethodMatching",
"HTTPRouteParentRefPort",
"HTTPRoutePathRedirect",
"HTTPRoutePathRewrite",
"HTTPRoutePortRedirect",
"HTTPRouteQueryParamMatching",
"HTTPRouteRequestMirror",
"HTTPRouteRequestMultipleMirrors",
"HTTPRouteRequestTimeout",
"HTTPRouteResponseHeaderModification",
"HTTPRouteSchemeRedirect",
"MeshClusterIPMatching",
"MeshConsumerRoute",
"ReferenceGrant",
"TLSRoute"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ gatewayClass:
reason: InvalidParameters
status: "False"
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRouteParentRefPort
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,34 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRouteParentRefPort
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ gatewayClass:
reason: Accepted
status: "True"
type: Accepted
supportedFeatures:
- GRPCRoute
- Gateway
- GatewayHTTPListenerIsolation
- GatewayPort8080
- GatewayStaticAddresses
- HTTPRoute
- HTTPRouteBackendProtocolH2C
- HTTPRouteBackendProtocolWebSocket
- HTTPRouteBackendRequestHeaderModification
- HTTPRouteBackendTimeout
- HTTPRouteDestinationPortMatching
- HTTPRouteHostRewrite
- HTTPRouteMethodMatching
- HTTPRouteParentRefPort
- HTTPRoutePathRedirect
- HTTPRoutePathRewrite
- HTTPRoutePortRedirect
- HTTPRouteQueryParamMatching
- HTTPRouteRequestMirror
- HTTPRouteRequestMultipleMirrors
- HTTPRouteRequestTimeout
- HTTPRouteResponseHeaderModification
- HTTPRouteSchemeRedirect
- MeshClusterIPMatching
- MeshConsumerRoute
- ReferenceGrant
- TLSRoute
gateways:
- metadata:
creationTimestamp: null
Expand Down
8 changes: 8 additions & 0 deletions internal/cmd/egctl/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"

"github.com/envoyproxy/gateway/internal/gatewayapi/status"
"github.com/envoyproxy/gateway/internal/utils/field"
"github.com/envoyproxy/gateway/internal/utils/file"
)
Expand Down Expand Up @@ -349,6 +350,13 @@ func TestTranslate(t *testing.T) {
}
want := &TranslationResult{}
mustUnmarshal(t, requireTestDataOutFile(t, fn), want)

// Supported features are dynamic, instead of hard-coding them in the output files
// we define them here.
if want.GatewayClass != nil {
want.GatewayClass.Status.SupportedFeatures = status.GatewaySupportedFeatures
}

opts := cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime")
require.Empty(t, cmp.Diff(want, got, opts))
})
Expand Down
19 changes: 19 additions & 0 deletions internal/gatewayapi/status/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/envoyproxy/gateway/test/conformance"
)

const (
Expand All @@ -32,6 +35,7 @@ const (
// for the provided GatewayClass.
func SetGatewayClassAccepted(gc *gwapiv1.GatewayClass, accepted bool, reason, msg string) *gwapiv1.GatewayClass {
gc.Status.Conditions = MergeConditions(gc.Status.Conditions, computeGatewayClassAcceptedCondition(gc, accepted, reason, msg))
gc.Status.SupportedFeatures = GatewaySupportedFeatures
return gc
}

Expand Down Expand Up @@ -61,3 +65,18 @@ func computeGatewayClassAcceptedCondition(gatewayClass *gwapiv1.GatewayClass,
}
}
}

// GatewaySupportedFeatures is a list of supported Gateway-API features,
// based on the running conformance tests suite.
var GatewaySupportedFeatures = getSupportedFeatures()

func getSupportedFeatures() []gwapiv1.SupportedFeature {
supportedFeatures := conformance.EnvoyGatewaySuite.SupportedFeatures
supportedFeatures.Delete(conformance.EnvoyGatewaySuite.ExemptFeatures.UnsortedList()...)

ret := sets.New[gwapiv1.SupportedFeature]()
for _, feature := range supportedFeatures.UnsortedList() {
ret.Insert(gwapiv1.SupportedFeature(feature))
}
return sets.List(ret)
}
5 changes: 5 additions & 0 deletions internal/provider/kubernetes/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/envoyproxy/gateway/internal/envoygateway"
"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/gatewayapi"
"github.com/envoyproxy/gateway/internal/gatewayapi/status"
"github.com/envoyproxy/gateway/internal/logging"
)

Expand Down Expand Up @@ -189,6 +190,7 @@ func TestHasManagedClass(t *testing.T) {
Status: metav1.ConditionTrue,
},
},
SupportedFeatures: status.GatewaySupportedFeatures,
},
},
},
Expand Down Expand Up @@ -223,6 +225,7 @@ func TestHasManagedClass(t *testing.T) {
Status: metav1.ConditionTrue,
},
},
SupportedFeatures: status.GatewaySupportedFeatures,
},
},
},
Expand Down Expand Up @@ -275,6 +278,7 @@ func TestHasManagedClass(t *testing.T) {
Status: metav1.ConditionTrue,
},
},
SupportedFeatures: status.GatewaySupportedFeatures,
},
},
{
Expand All @@ -297,6 +301,7 @@ func TestHasManagedClass(t *testing.T) {
Status: metav1.ConditionFalse,
},
},
SupportedFeatures: status.GatewaySupportedFeatures,
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions test/conformance/conformance_features.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package conformance

import (
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"
)

var EnvoyGatewaySuite = suite.ConformanceOptions{
SupportedFeatures: features.AllFeatures,
ExemptFeatures: features.MeshCoreFeatures,
SkipTests: []string{
tests.GatewayStaticAddresses.ShortName,
tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049
tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338
},
}
11 changes: 3 additions & 8 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,15 @@ import (
"sigs.k8s.io/gateway-api/conformance"
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"
)

func TestGatewayAPIConformance(t *testing.T) {
flag.Parse()

opts := conformance.DefaultOptions(t)
opts.SkipTests = []string{
tests.GatewayStaticAddresses.ShortName,
tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049
tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338
}
opts.SupportedFeatures = features.AllFeatures
opts.ExemptFeatures = features.MeshCoreFeatures
opts.SkipTests = EnvoyGatewaySuite.SkipTests
opts.SupportedFeatures = EnvoyGatewaySuite.SupportedFeatures
opts.ExemptFeatures = EnvoyGatewaySuite.ExemptFeatures

cSuite, err := suite.NewConformanceTestSuite(opts)
if err != nil {
Expand Down
11 changes: 3 additions & 8 deletions test/conformance/experimental_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,16 @@ import (
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/flags"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
"sigs.k8s.io/gateway-api/pkg/features"
"sigs.k8s.io/yaml"
)

func TestExperimentalConformance(t *testing.T) {
flag.Parse()

opts := conformance.DefaultOptions(t)
opts.SkipTests = []string{
tests.GatewayStaticAddresses.ShortName,
tests.GatewayHTTPListenerIsolation.ShortName, // https://github.com/kubernetes-sigs/gateway-api/issues/3049
tests.HTTPRouteBackendRequestHeaderModifier.ShortName, // https://github.com/envoyproxy/gateway/issues/3338
}
opts.SupportedFeatures = features.AllFeatures
opts.ExemptFeatures = features.MeshCoreFeatures
opts.SkipTests = EnvoyGatewaySuite.SkipTests
opts.SupportedFeatures = EnvoyGatewaySuite.SupportedFeatures
opts.ExemptFeatures = EnvoyGatewaySuite.ExemptFeatures
opts.ConformanceProfiles = sets.New(
suite.GatewayHTTPConformanceProfileName,
suite.GatewayTLSConformanceProfileName,
Expand Down

0 comments on commit a15245e

Please sign in to comment.