Skip to content

Commit

Permalink
update to latest Gateway API commit
Browse files Browse the repository at this point in the history
- Update to v1beta1 ReferenceGrant
- HTTPRequestHeaderFilter -> HTTPHeaderFilter
- GatewayConditionScheduled -> GatewayConditionAccepted
- ListenerConditionDetached -> ListenerConditionAccepted

Updates projectcontour#4555.
Updates projectcontour#4738.

Signed-off-by: Steve Kriss <krisss@vmware.com>
  • Loading branch information
skriss committed Nov 7, 2022
1 parent 6e469c9 commit f4aa89d
Show file tree
Hide file tree
Showing 29 changed files with 6,931 additions and 2,034 deletions.
1 change: 1 addition & 0 deletions .github/workflows/prbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
GOPROXY: https://proxy.golang.org/
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GO_VERSION: 1.19.2
GATEWAY_API_VERSION: 0b19b47246a587fa7fb33b3432ab8907ea1ba8b0
jobs:
lint:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 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 @@ -806,7 +805,7 @@ func (s *Server) setupGatewayAPI(contourConfiguration contour_api_v1alpha1.Conto
}

// 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
2,697 changes: 2,196 additions & 501 deletions examples/gateway/00-crds.yaml

Large diffs are not rendered by default.

2,697 changes: 2,196 additions & 501 deletions examples/render/contour-gateway-provisioner.yaml

Large diffs are not rendered by default.

2,697 changes: 2,196 additions & 501 deletions examples/render/contour-gateway.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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-20220728103510-ee6ede2d64ed
sigs.k8s.io/controller-runtime v0.12.1
sigs.k8s.io/controller-tools v0.7.0
sigs.k8s.io/gateway-api v0.5.1
sigs.k8s.io/gateway-api v0.5.1-0.20221105015014-0b19b47246a5
sigs.k8s.io/kustomize/kyaml v0.10.17
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,8 @@ sigs.k8s.io/controller-tools v0.6.0/go.mod h1:baRMVPrctU77F+rfAuH2uPqW93k6yQnZA2
sigs.k8s.io/controller-tools v0.7.0 h1:iZIz1vEcavyEfxjcTLs1WH/MPf4vhPCtTKhoHqV8/G0=
sigs.k8s.io/controller-tools v0.7.0/go.mod h1:bpBAo0VcSDDLuWt47evLhMLPxRPxMDInTEH/YbdeMK0=
sigs.k8s.io/gateway-api v0.3.0/go.mod h1:Wb8bx7QhGVZxOSEU3i9vw/JqTB5Nlai9MLMYVZeDmRQ=
sigs.k8s.io/gateway-api v0.5.1-0.20221105015014-0b19b47246a5 h1:6pTW6EG5WwL2x9aRpdEvFxXxstDlnSi8w0hoMEzr4iM=
sigs.k8s.io/gateway-api v0.5.1-0.20221105015014-0b19b47246a5/go.mod h1:x0AP6gugkFV8fC/oTlnOMU0pnmuzIR8LfIPRVUjxSqA=
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/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=
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 f4aa89d

Please sign in to comment.