Skip to content

Commit a695068

Browse files
authored
fix(gateway): tolerate missing SupportedVersion condition (#486)
Signed-off-by: Roel de Cort <roel.decort@adfinis.com>
1 parent f5451a9 commit a695068

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

internal/controller/openbaocluster/status_gateway_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,35 @@ func TestSetGatewayIntegrationReadyCondition_FastContract(t *testing.T) {
114114
wantReason: ReasonGatewayIntegrationReady,
115115
wantMessageIn: "prerequisites are satisfied",
116116
},
117+
{
118+
name: "gateway integration ready when class omits SupportedVersion condition",
119+
cluster: func() *openbaov1alpha1.OpenBaoCluster {
120+
cluster := newOpenBaoClusterStatusTestObject()
121+
cluster.Spec.Gateway = &openbaov1alpha1.GatewayConfig{
122+
Enabled: true,
123+
Hostname: "bao.example.test",
124+
GatewayRef: openbaov1alpha1.GatewayReference{
125+
Name: "shared-gateway",
126+
Namespace: "gateway-system",
127+
},
128+
}
129+
disabled := false
130+
cluster.Spec.Gateway.BackendTLS = &openbaov1alpha1.BackendTLSConfig{Enabled: &disabled}
131+
return cluster
132+
}(),
133+
objects: []client.Object{
134+
newGateway([]gatewayv1.Listener{{
135+
Name: "https",
136+
Protocol: gatewayv1.HTTPSProtocolType,
137+
Port: 443,
138+
}}, programmedTrue),
139+
newGatewayClass([]string{"HTTPRoute"}, acceptedTrue),
140+
},
141+
wantPresent: true,
142+
wantStatus: metav1.ConditionTrue,
143+
wantReason: ReasonGatewayIntegrationReady,
144+
wantMessageIn: "prerequisites are satisfied",
145+
},
117146
{
118147
name: "gateway capabilities unknown when class omits features",
119148
cluster: func() *openbaov1alpha1.OpenBaoCluster {

internal/service/networking/gateway_integration.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ func validateGatewayClassAccepted(gatewayClass *gatewayv1.GatewayClass) error {
178178

179179
func validateGatewayClassSupportedVersion(gatewayClass *gatewayv1.GatewayClass) error {
180180
supportedVersion := meta.FindStatusCondition(gatewayClass.Status.Conditions, string(gatewayv1.GatewayClassConditionStatusSupportedVersion))
181-
if supportedVersion == nil || supportedVersion.Status == metav1.ConditionUnknown {
181+
if supportedVersion == nil {
182+
return nil
183+
}
184+
if supportedVersion.Status == metav1.ConditionUnknown {
182185
return fmt.Errorf("%w: GatewayClass %q has not yet reported SupportedVersion=True", ErrGatewayClassPending, gatewayClass.Name)
183186
}
184187
if supportedVersion.Status == metav1.ConditionFalse {

internal/service/networking/gateway_integration_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,31 @@ func TestValidateGatewayIntegration(t *testing.T) {
102102
newGatewayClass([]gatewayv1.FeatureName{gatewayFeatureHTTPRoute, gatewayFeatureBackendTLSPolicy}, acceptedTrue, supportedVersionTrue),
103103
},
104104
},
105+
{
106+
name: "termination path tolerates class without SupportedVersion condition",
107+
cluster: func() *openbaov1alpha1.OpenBaoCluster {
108+
cluster := newMinimalCluster("example", "default")
109+
cluster.Spec.Gateway = &openbaov1alpha1.GatewayConfig{
110+
Enabled: true,
111+
Hostname: "bao.example.test",
112+
GatewayRef: openbaov1alpha1.GatewayReference{
113+
Name: "shared-gateway",
114+
Namespace: "gateway-system",
115+
},
116+
}
117+
disabled := false
118+
cluster.Spec.Gateway.BackendTLS = &openbaov1alpha1.BackendTLSConfig{Enabled: &disabled}
119+
return cluster
120+
}(),
121+
objects: []client.Object{
122+
newGateway([]gatewayv1.Listener{{
123+
Name: "https",
124+
Protocol: gatewayv1.HTTPSProtocolType,
125+
Port: 443,
126+
}}, programmedTrue),
127+
newGatewayClass([]gatewayv1.FeatureName{gatewayFeatureHTTPRoute}, acceptedTrue),
128+
},
129+
},
105130
{
106131
name: "listener mismatch is explicit",
107132
cluster: func() *openbaov1alpha1.OpenBaoCluster {

0 commit comments

Comments
 (0)