Skip to content

Commit

Permalink
Bump Gateway API to 0.6.0-rc.1 (#4929)
Browse files Browse the repository at this point in the history
* drop support for ReferencePolicy (#4830)

Drops support for ReferencePolicy which
has been replaced by ReferenceGrant in
Gateway API.

* update to latest Gateway API commit (#4839)

- Update to v1beta1 ReferenceGrant
- HTTPRequestHeaderFilter -> HTTPHeaderFilter
- GatewayConditionScheduled -> GatewayConditionAccepted
- ListenerConditionDetached -> ListenerConditionAccepted

* updates for SupportedFeatures changes (#4844)

* replace Gateway/Listener Ready conditions with Programmed (#4849)

Replaces the "Ready" condition used for Gateways
and Listeners with "Programmed".

* update to Gateway API v0.6.0-rc1 (#4891)

* Use generics for Gateway API pointer helpers (#4905)

Can get rid of our existing gatewayapi package helpers for getting
pointers to gateway api types based on primitive types

Also found some more instances of v1alpha2 package being used where we
should switch to v1beta1

Fixes #4555 
Fixes #4699 
Fixes #4848 

Signed-off-by: Steve Kriss <krisss@vmware.com>
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Co-authored-by: Steve Kriss <krisss@vmware.com>
  • Loading branch information
sunjayBhatia and skriss authored Dec 14, 2022
1 parent ee13679 commit e7a8a0d
Show file tree
Hide file tree
Showing 48 changed files with 8,652 additions and 3,042 deletions.
4 changes: 4 additions & 0 deletions changelogs/unreleased/4830-skriss-deprecation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Gateway API: ReferencePolicy no longer supported (use ReferenceGrant instead)

In Gateway API, ReferencePolicy's rename to ReferenceGrant has been fully completed.
Contour now only supports ReferenceGrant, and does not support ReferencePolicy resources in any way.
8 changes: 1 addition & 7 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
gatewayapi_v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
)

Expand Down Expand Up @@ -805,13 +804,8 @@ func (s *Server) setupGatewayAPI(contourConfiguration contour_api_v1alpha1.Conto
s.log.WithError(err).Fatal("failed to create tlsroute-controller")
}

// Inform on ReferencePolicies.
if err := informOnResource(&gatewayapi_v1alpha2.ReferencePolicy{}, eventHandler, mgr.GetCache()); err != nil {
s.log.WithError(err).WithField("resource", "referencepolicies").Fatal("failed to create informer")
}

// Inform on ReferenceGrants.
if err := informOnResource(&gatewayapi_v1alpha2.ReferenceGrant{}, eventHandler, mgr.GetCache()); err != nil {
if err := informOnResource(&gatewayapi_v1beta1.ReferenceGrant{}, eventHandler, mgr.GetCache()); err != nil {
s.log.WithError(err).WithField("resource", "referencegrants").Fatal("failed to create informer")
}

Expand Down
1 change: 0 additions & 1 deletion examples/contour/02-role-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ rules:
- gateways
- httproutes
- referencegrants
- referencepolicies
- tlsroutes
verbs:
- get
Expand Down
1 change: 0 additions & 1 deletion examples/gateway-provisioner/01-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ rules:
- gateways
- httproutes
- referencegrants
- referencepolicies
- tlsroutes
verbs:
- get
Expand Down
3,161 changes: 2,556 additions & 605 deletions examples/gateway/00-crds.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6986,7 +6986,6 @@ rules:
- gateways
- httproutes
- referencegrants
- referencepolicies
- tlsroutes
verbs:
- get
Expand Down
3,162 changes: 2,556 additions & 606 deletions examples/render/contour-gateway-provisioner.yaml

Large diffs are not rendered by default.

3,162 changes: 2,556 additions & 606 deletions examples/render/contour-gateway.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6986,7 +6986,6 @@ rules:
- gateways
- httproutes
- referencegrants
- referencepolicies
- tlsroutes
verbs:
- get
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
k8s.io/utils v0.0.0-20220922133306-665eaaec4324
sigs.k8s.io/controller-runtime v0.13.1
sigs.k8s.io/controller-tools v0.10.0
sigs.k8s.io/gateway-api v0.5.1
sigs.k8s.io/gateway-api v0.6.0-rc1
sigs.k8s.io/kustomize/kyaml v0.13.10
)

Expand Down Expand Up @@ -118,7 +118,6 @@ require (
github.com/subosito/gotenv v1.4.0 // indirect
github.com/tsaarni/x500dn v0.0.0-20210331182804-14283c7f5a16 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.4.0 // indirect
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91 h1:tnebWN09GYg9OLPss1KXj8txwZc6X6uMr6VFdcGNbHw=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
Expand Down Expand Up @@ -1036,8 +1035,8 @@ sigs.k8s.io/controller-runtime v0.13.1 h1:tUsRCSJVM1QQOOeViGeX3GMT3dQF1eePPw6sEE
sigs.k8s.io/controller-runtime v0.13.1/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI=
sigs.k8s.io/controller-tools v0.10.0 h1:0L5DTDTFB67jm9DkfrONgTGmfc/zYow0ZaHyppizU2U=
sigs.k8s.io/controller-tools v0.10.0/go.mod h1:uvr0EW6IsprfB0jpQq6evtKy+hHyHCXNfdWI5ONPx94=
sigs.k8s.io/gateway-api v0.5.1 h1:EqzgOKhChzyve9rmeXXbceBYB6xiM50vDfq0kK5qpdw=
sigs.k8s.io/gateway-api v0.5.1/go.mod h1:x0AP6gugkFV8fC/oTlnOMU0pnmuzIR8LfIPRVUjxSqA=
sigs.k8s.io/gateway-api v0.6.0-rc1 h1:ierhK6SIK8pSibB+gkr+aG8cWLez/M7iD9dQIqLALxU=
sigs.k8s.io/gateway-api v0.6.0-rc1/go.mod h1:+3QMzP775JFKArHqiwk/kzItMRXW9CKPXcO8QcuXvvk=
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kustomize/kyaml v0.13.10 h1:htPMvrk7ZDfTDyrgXIm/2mfmcYJHEmRb6s+yCLgtNms=
Expand Down
14 changes: 7 additions & 7 deletions internal/controller/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (r *gatewayReconciler) gatewayClassHasMatchingController(obj client.Object)
}

// Reconcile finds all the Gateways for the GatewayClass with an "Accepted: true" condition.
// It passes the oldest such Gateway to the DAG for processing, and sets a "Scheduled: false"
// It passes the oldest such Gateway to the DAG for processing, and sets an "Accepted: false"
// condition on all other Gateways for the accepted GatewayClass.
func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
r.log.WithField("namespace", request.Namespace).WithField("name", request.Name).Info("reconciling gateway")
Expand Down Expand Up @@ -257,7 +257,7 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req
}
}

// Set the "Scheduled" condition to false for all gateways
// Set the "Accepted" condition to false for all gateways
// except the oldest. The oldest will have its status set
// by the DAG processor, so don't set it here.
for _, gw := range gatewaysForClass {
Expand All @@ -275,12 +275,12 @@ func (r *gatewayReconciler) Reconcile(ctx context.Context, request reconcile.Req
panic(fmt.Sprintf("unsupported object type %T", obj))
}

return setGatewayNotScheduled(gw.DeepCopy())
return setGatewayNotAccepted(gw.DeepCopy())
}),
})
} else {
// this branch makes testing easier by not going through the StatusUpdater.
copy := setGatewayNotScheduled(gw.DeepCopy())
copy := setGatewayNotAccepted(gw.DeepCopy())
if err := r.client.Status().Update(context.Background(), copy); err != nil {
r.log.WithError(err).Error("error updating gateway status")
return reconcile.Result{}, fmt.Errorf("error updating status of gateway %s/%s: %v", gw.Namespace, gw.Name, err)
Expand All @@ -306,9 +306,9 @@ func isAccepted(gatewayClass *gatewayapi_v1beta1.GatewayClass) bool {
return false
}

func setGatewayNotScheduled(gateway *gatewayapi_v1beta1.Gateway) *gatewayapi_v1beta1.Gateway {
func setGatewayNotAccepted(gateway *gatewayapi_v1beta1.Gateway) *gatewayapi_v1beta1.Gateway {
newCond := metav1.Condition{
Type: "Scheduled",
Type: string(gatewayapi_v1beta1.GatewayConditionAccepted),
Status: metav1.ConditionFalse,
Reason: "OlderGatewayExists",
Message: "An older Gateway exists for the accepted GatewayClass",
Expand All @@ -319,7 +319,7 @@ func setGatewayNotScheduled(gateway *gatewayapi_v1beta1.Gateway) *gatewayapi_v1b
for i := range gateway.Status.Conditions {
cond := &gateway.Status.Conditions[i]

if cond.Type != "Scheduled" {
if cond.Type != string(gatewayapi_v1beta1.GatewayConditionAccepted) {
continue
}

Expand Down
Loading

0 comments on commit e7a8a0d

Please sign in to comment.