From 815d06c8523d5d3368d12394ad1df66c62f98364 Mon Sep 17 00:00:00 2001 From: David Jumani Date: Thu, 30 Oct 2025 13:02:25 -0400 Subject: [PATCH] Update gateway status to include `AttachedListeners` --- apis/v1/gateway_types.go | 18 +++++++++ apis/v1/zz_generated.deepcopy.go | 5 +++ applyconfiguration/apis/v1/gatewaystatus.go | 15 ++++++-- applyconfiguration/internal/internal.go | 3 ++ .../gateway.networking.k8s.io_gateways.yaml | 38 +++++++++++++++++++ .../gateway.networking.k8s.io_gateways.yaml | 38 +++++++++++++++++++ pkg/generated/openapi/zz_generated.openapi.go | 7 ++++ 7 files changed, 121 insertions(+), 3 deletions(-) diff --git a/apis/v1/gateway_types.go b/apis/v1/gateway_types.go index 3b856a1567..d8c13c3d4a 100644 --- a/apis/v1/gateway_types.go +++ b/apis/v1/gateway_types.go @@ -998,6 +998,24 @@ type GatewayStatus struct { // +listMapKey=name // +kubebuilder:validation:MaxItems=64 Listeners []ListenerStatus `json:"listeners,omitempty"` + + // AttachedListeners represents the total number of ListenerSets that have been + // successfully attached to this Gateway. + // + // Successful attachment of a ListenerSets to a Gateway is based solely on the + // combination of the AllowedListeners field on the Gateway + // and the ListenerSets's ParentRefs field. A ListenerSets is successfully attached to + // a Gateway when it is selected by the ListenerSets's AllowedListeners field + // AND the ListenerSets has a valid ParentRef selecting the Gateway + // resource as a parent resource. ListenerSets status does not impact + // successful attachment, i.e. the AttachedListeners field count MUST be set + // for ListenerSets with condition Accepted: false and MUST count successfully + // attached AttachedListeners that may themselves have Accepted: false conditions. + // + // Uses for this field include troubleshooting AttachedListeners attachment and + // measuring blast radius/impact of changes to a Gateway. + // +optional + AttachedListeners *int32 `json:"attachedListeners"` } // GatewayInfrastructure defines infrastructure level attributes about a Gateway instance. diff --git a/apis/v1/zz_generated.deepcopy.go b/apis/v1/zz_generated.deepcopy.go index 174c292702..2351fa752f 100644 --- a/apis/v1/zz_generated.deepcopy.go +++ b/apis/v1/zz_generated.deepcopy.go @@ -985,6 +985,11 @@ func (in *GatewayStatus) DeepCopyInto(out *GatewayStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.AttachedListeners != nil { + in, out := &in.AttachedListeners, &out.AttachedListeners + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewayStatus. diff --git a/applyconfiguration/apis/v1/gatewaystatus.go b/applyconfiguration/apis/v1/gatewaystatus.go index 3e96cd2907..3cf8e2f006 100644 --- a/applyconfiguration/apis/v1/gatewaystatus.go +++ b/applyconfiguration/apis/v1/gatewaystatus.go @@ -25,9 +25,10 @@ import ( // GatewayStatusApplyConfiguration represents a declarative configuration of the GatewayStatus type for use // with apply. type GatewayStatusApplyConfiguration struct { - Addresses []GatewayStatusAddressApplyConfiguration `json:"addresses,omitempty"` - Conditions []metav1.ConditionApplyConfiguration `json:"conditions,omitempty"` - Listeners []ListenerStatusApplyConfiguration `json:"listeners,omitempty"` + Addresses []GatewayStatusAddressApplyConfiguration `json:"addresses,omitempty"` + Conditions []metav1.ConditionApplyConfiguration `json:"conditions,omitempty"` + Listeners []ListenerStatusApplyConfiguration `json:"listeners,omitempty"` + AttachedListeners *int32 `json:"attachedListeners,omitempty"` } // GatewayStatusApplyConfiguration constructs a declarative configuration of the GatewayStatus type for use with @@ -74,3 +75,11 @@ func (b *GatewayStatusApplyConfiguration) WithListeners(values ...*ListenerStatu } return b } + +// WithAttachedListeners sets the AttachedListeners field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AttachedListeners field is set to the value of the last call. +func (b *GatewayStatusApplyConfiguration) WithAttachedListeners(value int32) *GatewayStatusApplyConfiguration { + b.AttachedListeners = &value + return b +} diff --git a/applyconfiguration/internal/internal.go b/applyconfiguration/internal/internal.go index 5fa65d155a..31d551f752 100644 --- a/applyconfiguration/internal/internal.go +++ b/applyconfiguration/internal/internal.go @@ -716,6 +716,9 @@ var schemaYAML = typed.YAMLObject(`types: elementType: namedType: io.k8s.sigs.gateway-api.apis.v1.GatewayStatusAddress elementRelationship: atomic + - name: attachedListeners + type: + scalar: numeric - name: conditions type: list: diff --git a/config/crd/experimental/gateway.networking.k8s.io_gateways.yaml b/config/crd/experimental/gateway.networking.k8s.io_gateways.yaml index 1d27104859..468aa90ccd 100644 --- a/config/crd/experimental/gateway.networking.k8s.io_gateways.yaml +++ b/config/crd/experimental/gateway.networking.k8s.io_gateways.yaml @@ -1363,6 +1363,25 @@ spec: maxItems: 16 type: array x-kubernetes-list-type: atomic + attachedListeners: + description: |- + AttachedListeners represents the total number of ListenerSets that have been + successfully attached to this Gateway. + + Successful attachment of a ListenerSets to a Gateway is based solely on the + combination of the AllowedListeners field on the Gateway + and the ListenerSets's ParentRefs field. A ListenerSets is successfully attached to + a Gateway when it is selected by the ListenerSets's AllowedListeners field + AND the ListenerSets has a valid ParentRef selecting the Gateway + resource as a parent resource. ListenerSets status does not impact + successful attachment, i.e. the AttachedListeners field count MUST be set + for ListenerSets with condition Accepted: false and MUST count successfully + attached AttachedListeners that may themselves have Accepted: false conditions. + + Uses for this field include troubleshooting AttachedListeners attachment and + measuring blast radius/impact of changes to a Gateway. + format: int32 + type: integer conditions: default: - lastTransitionTime: "1970-01-01T00:00:00Z" @@ -2940,6 +2959,25 @@ spec: maxItems: 16 type: array x-kubernetes-list-type: atomic + attachedListeners: + description: |- + AttachedListeners represents the total number of ListenerSets that have been + successfully attached to this Gateway. + + Successful attachment of a ListenerSets to a Gateway is based solely on the + combination of the AllowedListeners field on the Gateway + and the ListenerSets's ParentRefs field. A ListenerSets is successfully attached to + a Gateway when it is selected by the ListenerSets's AllowedListeners field + AND the ListenerSets has a valid ParentRef selecting the Gateway + resource as a parent resource. ListenerSets status does not impact + successful attachment, i.e. the AttachedListeners field count MUST be set + for ListenerSets with condition Accepted: false and MUST count successfully + attached AttachedListeners that may themselves have Accepted: false conditions. + + Uses for this field include troubleshooting AttachedListeners attachment and + measuring blast radius/impact of changes to a Gateway. + format: int32 + type: integer conditions: default: - lastTransitionTime: "1970-01-01T00:00:00Z" diff --git a/config/crd/standard/gateway.networking.k8s.io_gateways.yaml b/config/crd/standard/gateway.networking.k8s.io_gateways.yaml index 0930cff5a9..4f01ed6935 100644 --- a/config/crd/standard/gateway.networking.k8s.io_gateways.yaml +++ b/config/crd/standard/gateway.networking.k8s.io_gateways.yaml @@ -899,6 +899,25 @@ spec: maxItems: 16 type: array x-kubernetes-list-type: atomic + attachedListeners: + description: |- + AttachedListeners represents the total number of ListenerSets that have been + successfully attached to this Gateway. + + Successful attachment of a ListenerSets to a Gateway is based solely on the + combination of the AllowedListeners field on the Gateway + and the ListenerSets's ParentRefs field. A ListenerSets is successfully attached to + a Gateway when it is selected by the ListenerSets's AllowedListeners field + AND the ListenerSets has a valid ParentRef selecting the Gateway + resource as a parent resource. ListenerSets status does not impact + successful attachment, i.e. the AttachedListeners field count MUST be set + for ListenerSets with condition Accepted: false and MUST count successfully + attached AttachedListeners that may themselves have Accepted: false conditions. + + Uses for this field include troubleshooting AttachedListeners attachment and + measuring blast radius/impact of changes to a Gateway. + format: int32 + type: integer conditions: default: - lastTransitionTime: "1970-01-01T00:00:00Z" @@ -2012,6 +2031,25 @@ spec: maxItems: 16 type: array x-kubernetes-list-type: atomic + attachedListeners: + description: |- + AttachedListeners represents the total number of ListenerSets that have been + successfully attached to this Gateway. + + Successful attachment of a ListenerSets to a Gateway is based solely on the + combination of the AllowedListeners field on the Gateway + and the ListenerSets's ParentRefs field. A ListenerSets is successfully attached to + a Gateway when it is selected by the ListenerSets's AllowedListeners field + AND the ListenerSets has a valid ParentRef selecting the Gateway + resource as a parent resource. ListenerSets status does not impact + successful attachment, i.e. the AttachedListeners field count MUST be set + for ListenerSets with condition Accepted: false and MUST count successfully + attached AttachedListeners that may themselves have Accepted: false conditions. + + Uses for this field include troubleshooting AttachedListeners attachment and + measuring blast radius/impact of changes to a Gateway. + format: int32 + type: integer conditions: default: - lastTransitionTime: "1970-01-01T00:00:00Z" diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 0968ead79a..b0466e71c3 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -4567,6 +4567,13 @@ func schema_sigsk8sio_gateway_api_apis_v1_GatewayStatus(ref common.ReferenceCall }, }, }, + "attachedListeners": { + SchemaProps: spec.SchemaProps{ + Description: "AttachedListeners represents the total number of ListenerSets that have been successfully attached to this Gateway.\n\nSuccessful attachment of a ListenerSets to a Gateway is based solely on the combination of the AllowedListeners field on the Gateway and the ListenerSets's ParentRefs field. A ListenerSets is successfully attached to a Gateway when it is selected by the ListenerSets's AllowedListeners field AND the ListenerSets has a valid ParentRef selecting the Gateway resource as a parent resource. ListenerSets status does not impact successful attachment, i.e. the AttachedListeners field count MUST be set for ListenerSets with condition Accepted: false and MUST count successfully attached AttachedListeners that may themselves have Accepted: false conditions.\n\nUses for this field include troubleshooting AttachedListeners attachment and measuring blast radius/impact of changes to a Gateway.", + Type: []string{"integer"}, + Format: "int32", + }, + }, }, }, },