Skip to content

Commit

Permalink
[Gateway API 1.2.0] Upgrade Gateway API to 1.2.0-rc2 (#4270)
Browse files Browse the repository at this point in the history
* upgrade Gateway API to 1.2.0

Signed-off-by: Huabing Zhao <[email protected]>

* fix build

Signed-off-by: Huabing Zhao <[email protected]>

* refactory

Signed-off-by: Huabing Zhao <[email protected]>

* skip infrastrucure conformance test

Signed-off-by: Huabing Zhao <[email protected]>

* fix multiple gc test

Signed-off-by: Huabing Zhao <[email protected]>

* fix upgrage test

Signed-off-by: Huabing Zhao <[email protected]>

* fix e2e

Signed-off-by: Huabing Zhao <[email protected]>

* fix license scan

Signed-off-by: Huabing Zhao <[email protected]>

* fix license scan

Signed-off-by: Huabing Zhao <[email protected]>

* use 1.1.2 as the previous version for upgrade test

Signed-off-by: Huabing Zhao <[email protected]>

* fix upgrade test

Signed-off-by: Huabing Zhao <[email protected]>

* upgrade to gateway api v1.2.0-rc2

Signed-off-by: Huabing Zhao <[email protected]>

* fix license check

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

* fix test

Signed-off-by: Huabing Zhao <[email protected]>

---------

Signed-off-by: Huabing Zhao <[email protected]>
  • Loading branch information
zhaohuabing authored Oct 1, 2024
1 parent ffe029b commit db1f437
Show file tree
Hide file tree
Showing 17 changed files with 1,112 additions and 4,399 deletions.
5,357 changes: 1,007 additions & 4,350 deletions charts/gateway-helm/crds/gatewayapi-crds.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/extension-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
google.golang.org/protobuf v1.34.2
k8s.io/apimachinery v0.31.1
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/gateway-api v1.1.0
sigs.k8s.io/gateway-api v1.2.0-rc2
)

require (
Expand Down
4 changes: 2 additions & 2 deletions examples/extension-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ k8s.io/utils v0.0.0-20240821151609-f90d01438635 h1:2wThSvJoW/Ncn9TmQEYXRnevZXi2d
k8s.io/utils v0.0.0-20240821151609-f90d01438635/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
sigs.k8s.io/gateway-api v1.2.0-rc2 h1:v7V7JzaBuzwOLWWyyqlkqiqBi3ANBuZGV+uyyKzwmE8=
sigs.k8s.io/gateway-api v1.2.0-rc2/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
k8s.io/kubectl v0.31.1
k8s.io/utils v0.0.0-20240821151609-f90d01438635
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/gateway-api v1.1.0
sigs.k8s.io/gateway-api v1.2.0-rc2
sigs.k8s.io/mcs-api v0.1.0
sigs.k8s.io/yaml v1.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1210,8 +1210,8 @@ sigs.k8s.io/controller-runtime v0.6.1/go.mod h1:XRYBPdbf5XJu9kpS84VJiZ7h/u1hF3gE
sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q=
sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4=
sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI=
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
sigs.k8s.io/gateway-api v1.2.0-rc2 h1:v7V7JzaBuzwOLWWyyqlkqiqBi3ANBuZGV+uyyKzwmE8=
sigs.k8s.io/gateway-api v1.2.0-rc2/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kind v0.8.1/go.mod h1:oNKTxUVPYkV9lWzY6CVMNluVq8cBsyq+UgPJdvA3uu4=
Expand Down
28 changes: 23 additions & 5 deletions internal/gatewayapi/conformance/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
// SkipTests is a list of tests that are skipped in the conformance suite.
var SkipTests = []suite.ConformanceTest{
tests.GatewayStaticAddresses,
tests.GatewayInfrastructure,
}

func skipTestsShortNames(skipTests []suite.ConformanceTest) []string {
Expand All @@ -27,9 +28,26 @@ func skipTestsShortNames(skipTests []suite.ConformanceTest) []string {

// EnvoyGatewaySuite is the conformance suite configuration for the Gateway API.
var EnvoyGatewaySuite = suite.ConformanceOptions{
SupportedFeatures: features.AllFeatures,
ExemptFeatures: sets.New[features.SupportedFeature]().
Insert(features.MeshCoreFeatures.UnsortedList()...).
Insert(features.MeshExtendedFeatures.UnsortedList()...),
SkipTests: skipTestsShortNames(SkipTests),
SupportedFeatures: allFeatures(),
ExemptFeatures: meshFeatures(),
SkipTests: skipTestsShortNames(SkipTests),
}

func allFeatures() sets.Set[features.FeatureName] {
allFeatures := sets.New[features.FeatureName]()
for _, feature := range features.AllFeatures.UnsortedList() {
allFeatures.Insert(feature.Name)
}
return allFeatures
}

func meshFeatures() sets.Set[features.FeatureName] {
meshFeatures := sets.New[features.FeatureName]()
for _, feature := range features.MeshCoreFeatures.UnsortedList() {
meshFeatures.Insert(feature.Name)
}
for _, feature := range features.MeshExtendedFeatures.UnsortedList() {
meshFeatures.Insert(feature.Name)
}
return meshFeatures
}
18 changes: 13 additions & 5 deletions internal/gatewayapi/conformance/support_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ const (
)

// ExtendedFeatures is a list of supported Gateway-API features that are considered Extended.
var ExtendedFeatures = sets.New[features.SupportedFeature]().
Insert(features.GatewayExtendedFeatures.UnsortedList()...).
Insert(features.HTTPRouteExtendedFeatures.UnsortedList()...).
Insert(features.MeshExtendedFeatures.UnsortedList()...)
var ExtendedFeatures = sets.New[features.FeatureName]()

func init() {
featureLists := sets.New[features.Feature]().
Insert(features.GatewayExtendedFeatures.UnsortedList()...).
Insert(features.HTTPRouteExtendedFeatures.UnsortedList()...).
Insert(features.MeshExtendedFeatures.UnsortedList()...)

for _, feature := range featureLists.UnsortedList() {
ExtendedFeatures.Insert(feature.Name)
}
}

// GetTestSupportLevel returns the SupportLevel for a conformance test.
// The support level is determined by the highest support level of the features.
Expand All @@ -44,7 +52,7 @@ func GetTestSupportLevel(test suite.ConformanceTest) SupportLevel {
}

// GetFeatureSupportLevel returns the SupportLevel for a feature.
func GetFeatureSupportLevel(feature features.SupportedFeature) SupportLevel {
func GetFeatureSupportLevel(feature features.FeatureName) SupportLevel {
supportLevel := Core

if ExtendedFeatures.Has(feature) {
Expand Down
1 change: 1 addition & 0 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var (
PathMatchTypeDerefOr = ptr.Deref[gwapiv1.PathMatchType]
GRPCMethodMatchTypeDerefOr = ptr.Deref[gwapiv1.GRPCMethodMatchType]
HeaderMatchTypeDerefOr = ptr.Deref[gwapiv1.HeaderMatchType]
GRPCHeaderMatchTypeDerefOr = ptr.Deref[gwapiv1.GRPCHeaderMatchType]
QueryParamMatchTypeDerefOr = ptr.Deref[gwapiv1.QueryParamMatchType]
)

Expand Down
6 changes: 3 additions & 3 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,13 @@ func (t *Translator) processGRPCRouteRule(grpcRoute *GRPCRouteContext, ruleIdx i
}

for _, headerMatch := range match.Headers {
switch HeaderMatchTypeDerefOr(headerMatch.Type, gwapiv1.HeaderMatchExact) {
case gwapiv1.HeaderMatchExact:
switch GRPCHeaderMatchTypeDerefOr(headerMatch.Type, gwapiv1.GRPCHeaderMatchExact) {
case gwapiv1.GRPCHeaderMatchExact:
irRoute.HeaderMatches = append(irRoute.HeaderMatches, &ir.StringMatch{
Name: string(headerMatch.Name),
Exact: ptr.To(headerMatch.Value),
})
case gwapiv1.HeaderMatchRegularExpression:
case gwapiv1.GRPCHeaderMatchRegularExpression:
if err := regex.Validate(headerMatch.Value); err != nil {
return nil, err
}
Expand Down
13 changes: 10 additions & 3 deletions internal/gatewayapi/status/gatewayclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,19 @@ func getSupportedFeatures(gatewaySuite suite.ConformanceOptions, skippedTests []

ret := sets.New[gwapiv1.SupportedFeature]()
for _, feature := range supportedFeatures.UnsortedList() {
ret.Insert(gwapiv1.SupportedFeature(feature))
ret.Insert(gwapiv1.SupportedFeature{
Name: gwapiv1.FeatureName(feature),
})
}
return sets.List(ret)

var featureList []gwapiv1.SupportedFeature
for feature := range ret {
featureList = append(featureList, feature)
}
return featureList
}

func getUnsupportedFeatures(gatewaySuite suite.ConformanceOptions, skippedTests []suite.ConformanceTest) []features.SupportedFeature {
func getUnsupportedFeatures(gatewaySuite suite.ConformanceOptions, skippedTests []suite.ConformanceTest) []features.FeatureName {
unsupportedFeatures := gatewaySuite.ExemptFeatures.UnsortedList()

for _, skippedTest := range skippedTests {
Expand Down
49 changes: 31 additions & 18 deletions internal/gatewayapi/status/gatewayclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,63 +80,76 @@ func TestGetSupportedFeatures(t *testing.T) {
{
name: "No exempt features",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"),
ExemptFeatures: sets.New[features.SupportedFeature](),
SupportedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute"),
ExemptFeatures: sets.New[features.FeatureName](),
},
expectedResult: []gwapiv1.SupportedFeature{
{Name: "Gateway"},
{Name: "HTTPRoute"},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway", "HTTPRoute"},
},
{
name: "All features exempt",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"),
ExemptFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"),
SupportedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute"),
ExemptFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute"),
},
expectedResult: []gwapiv1.SupportedFeature{},
},
{
name: "Some features exempt",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute", "GRPCRoute"),
ExemptFeatures: sets.New[features.SupportedFeature]("GRPCRoute"),
SupportedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute", "GRPCRoute"),
ExemptFeatures: sets.New[features.FeatureName]("GRPCRoute"),
},
expectedResult: []gwapiv1.SupportedFeature{
{Name: "Gateway"},
{Name: "HTTPRoute"},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway", "HTTPRoute"},
},
{
name: "Some features exempt with skipped tests",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute", "GRPCRoute"),
ExemptFeatures: sets.New[features.SupportedFeature]("GRPCRoute"),
SupportedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute", "GRPCRoute"),
ExemptFeatures: sets.New[features.FeatureName]("GRPCRoute"),
},
skippedTests: []suite.ConformanceTest{
{
Features: []features.SupportedFeature{"HTTPRoute"},
Features: []features.FeatureName{"HTTPRoute"},
},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway"},
expectedResult: []gwapiv1.SupportedFeature{
{Name: "Gateway"},
},
},
{
name: "Core features remain supported with skipped extended tests",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute", "GatewayHTTPListenerIsolation"),
SupportedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute", "GatewayHTTPListenerIsolation"),
},
skippedTests: []suite.ConformanceTest{
{
Features: []features.SupportedFeature{"Gateway", "GatewayHTTPListenerIsolation", "HTTPRoute"},
Features: []features.FeatureName{"Gateway", "GatewayHTTPListenerIsolation", "HTTPRoute"},
},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway", "HTTPRoute"},
expectedResult: []gwapiv1.SupportedFeature{
{Name: "Gateway"},
{Name: "HTTPRoute"},
},
},
{
name: "Core feature removed when skipping core test",
gatewaySuite: suite.ConformanceOptions{
SupportedFeatures: sets.New[features.SupportedFeature]("Gateway", "HTTPRoute"),
SupportedFeatures: sets.New[features.FeatureName]("Gateway", "HTTPRoute"),
},
skippedTests: []suite.ConformanceTest{
{
Features: []features.SupportedFeature{"HTTPRoute"},
Features: []features.FeatureName{"HTTPRoute"},
},
},
expectedResult: []gwapiv1.SupportedFeature{"Gateway"},
expectedResult: []gwapiv1.SupportedFeature{
{Name: "Gateway"},
},
},
}

Expand Down
7 changes: 7 additions & 0 deletions osv-scanner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ name = "stdlib"
ecosystem = "Go"
license.override = ["BSD-3-Clause"]
reason = "Unidentified license, remove once https://github.com/google/deps.dev/issues/86 is resolved"

[[PackageOverrides]]
name = "sigs.k8s.io/gateway-api"
version = "1.2.0-rc2"
ecosystem = "Go"
license.override = ["Apache-2.0"]
reason = "https://github.com/envoyproxy/gateway/actions/runs/11065210699/job/30744231458?pr=4270"
2 changes: 1 addition & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestE2E(t *testing.T) {
RunTest: *flags.RunTest,
// SupportedFeatures cannot be empty, so we set it to SupportGateway
// All e2e tests should leave Features empty.
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway),
SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway),
SkipTests: []string{
tests.GatewayInfraResourceTest.ShortName, // https://github.com/envoyproxy/gateway/issues/3191
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/merge_gateways/merge_gateways_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestMergeGateways(t *testing.T) {
RunTest: *flags.RunTest,
// SupportedFeatures cannot be empty, so we set it to SupportGateway
// All e2e tests should leave Features empty.
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway),
SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway),
SkipTests: []string{},
})
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/multiple_gc/multiple_gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (

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

c, cfg := kubetest.NewClient(t)

if flags.RunTest != nil && *flags.RunTest != "" {
Expand All @@ -50,7 +49,7 @@ func TestMultipleGC(t *testing.T) {
RunTest: *flags.RunTest,
// SupportedFeatures cannot be empty, so we set it to SupportGateway
// All e2e tests should leave Features empty.
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway),
SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway),
SkipTests: []string{},
})
if err != nil {
Expand All @@ -76,13 +75,14 @@ func TestMultipleGC(t *testing.T) {
privateGatewaySuiteGatewayClassName := "private"
privateGatewaySuite, err := suite.NewConformanceTestSuite(suite.ConformanceOptions{
Client: c,
RestConfig: cfg,
GatewayClassName: privateGatewaySuiteGatewayClassName,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
RunTest: *flags.RunTest,
// SupportedFeatures cannot be empty, so we set it to SupportGateway
// All e2e tests should leave Features empty.
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway),
SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway),
SkipTests: []string{},
})
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions test/e2e/tests/eg_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var EGUpgradeTest = suite.ConformanceTest{
depNS := "envoy-gateway-system"
lastVersionTag := os.Getenv("last_version_tag")
if lastVersionTag == "" {
// Use v1.0.2 instead of v1.1.2 due to https://github.com/envoyproxy/gateway/issues/4336
lastVersionTag = "v1.0.2" // Default version tag if not specified
}

Expand Down Expand Up @@ -274,13 +275,14 @@ func migrateChartCRDs(actionConfig *action.Configuration, gatewayChart *chart.Ch
}

for _, crd := range crds {
if crd.Name == "backendtlspolicies.gateway.networking.k8s.io" {
if crd.Name == "backendtlspolicies.gateway.networking.k8s.io" ||
crd.Name == "grpcroutes.gateway.networking.k8s.io" {
newVersion, err := getGWAPIVersion(crd.Object)
if err != nil {
return err
}
// https://gateway-api.sigs.k8s.io/guides/?h=upgrade#v11-upgrade-notes
if newVersion == "v1.1.0" {
if newVersion == "v1.2.0-rc2" {
helper := resource.NewHelper(crd.Client, crd.Mapping)
existingCRD, err := helper.Get(crd.Namespace, crd.Name)
if kerrors.IsNotFound(err) {
Expand All @@ -294,7 +296,7 @@ func migrateChartCRDs(actionConfig *action.Configuration, gatewayChart *chart.Ch
}

if existingVersion == "v1.0.0" {
// Delete the existing instance of the BTLS CRD
// Delete the existing instance of the BTLS and GRPCRoute CRDs
_, errs := actionConfig.KubeClient.Delete([]*resource.Info{crd})
if errs != nil {
return fmt.Errorf("failed to delete backendtlspolicies: %s", util.MultipleErrors("", errs))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/upgrade/eg_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestEGUpgrade(t *testing.T) {
ManifestFS: []fs.FS{e2e.UpgradeManifests},
RunTest: *flags.RunTest,
BaseManifests: "upgrade/manifests.yaml",
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway),
SupportedFeatures: sets.New[features.FeatureName](features.SupportGateway),
SkipTests: []string{},
})
if err != nil {
Expand Down

0 comments on commit db1f437

Please sign in to comment.