Skip to content

Commit 89b9190

Browse files
committed
Fix conditions
1 parent 1247ffd commit 89b9190

File tree

7 files changed

+23
-30
lines changed

7 files changed

+23
-30
lines changed

internal/controller/state/conditions/conditions.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ const (
4242
// not yet supported.
4343
RouteReasonUnsupportedField v1.RouteConditionReason = "UnsupportedField"
4444

45-
// RouteConditionUnsupportedField indicates that the Route contains fields that are not yet supported.
46-
// The route is still valid and processed, but these fields are ignored.
47-
RouteConditionUnsupportedField v1.RouteConditionType = "UnsupportedField"
48-
4945
// RouteReasonInvalidGateway is used with the "Accepted" (false) condition when the Gateway the Route
5046
// references is invalid.
5147
RouteReasonInvalidGateway v1.RouteConditionReason = "InvalidGateway"
@@ -74,10 +70,6 @@ const (
7470
// that are not yet supported.
7571
GatewayReasonUnsupportedField v1.GatewayConditionReason = "UnsupportedField"
7672

77-
// GatewayConditionUnsupportedField indicates that the Gateway contains fields that are not yet supported.
78-
// The gateway is still valid and processed, but these fields are ignored.
79-
GatewayConditionUnsupportedField v1.GatewayConditionType = "UnsupportedField"
80-
8173
// GatewayReasonUnsupportedValue is used with GatewayConditionAccepted (false) when a value of a field in a Gateway
8274
// is invalid or not supported.
8375
GatewayReasonUnsupportedValue v1.GatewayConditionReason = "UnsupportedValue"
@@ -370,10 +362,11 @@ func NewRouteUnsupportedValue(msg string) Condition {
370362
}
371363
}
372364

373-
// NewRouteUnsupportedField returns a Condition that indicates that the Route includes an unsupported field.
374-
func NewRouteUnsupportedField(msg string) Condition {
365+
// NewRouteAcceptedUnsupportedField returns a Condition that indicates that the Route is accepted but
366+
// includes an unsupported field.
367+
func NewRouteAcceptedUnsupportedField(msg string) Condition {
375368
return Condition{
376-
Type: string(RouteConditionUnsupportedField),
369+
Type: string(v1.RouteConditionAccepted),
377370
Status: metav1.ConditionTrue,
378371
Reason: string(RouteReasonUnsupportedField),
379372
Message: fmt.Sprintf("The following unsupported parameters were ignored: %s", msg),
@@ -971,11 +964,11 @@ func NewGatewayInvalidParameters(msg string) Condition {
971964
}
972965
}
973966

974-
// NewGatewayUnsupportedField returns a Condition that indicates the Gateway is accepted but
967+
// NewGatewayAcceptedUnsupportedField returns a Condition that indicates the Gateway is accepted but
975968
// contains a field that is not supported.
976-
func NewGatewayUnsupportedField(msg string) Condition {
969+
func NewGatewayAcceptedUnsupportedField(msg string) Condition {
977970
return Condition{
978-
Type: string(GatewayConditionUnsupportedField),
971+
Type: string(v1.GatewayConditionAccepted),
979972
Status: metav1.ConditionTrue,
980973
Reason: string(GatewayReasonUnsupportedField),
981974
Message: fmt.Sprintf("Gateway accepted but the following unsupported parameters were ignored: %s", msg),

internal/controller/state/graph/gateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ func validateUnsupportedGatewayFields(gw *v1.Gateway) []conditions.Condition {
275275
var conds []conditions.Condition
276276

277277
if gw.Spec.AllowedListeners != nil {
278-
conds = append(conds, conditions.NewGatewayUnsupportedField("AllowedListeners"))
278+
conds = append(conds, conditions.NewGatewayAcceptedUnsupportedField("AllowedListeners"))
279279
}
280280

281281
if gw.Spec.BackendTLS != nil {
282-
conds = append(conds, conditions.NewGatewayUnsupportedField("BackendTLS"))
282+
conds = append(conds, conditions.NewGatewayAcceptedUnsupportedField("BackendTLS"))
283283
}
284284

285285
return conds

internal/controller/state/graph/gateway_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ func TestBuildGateway(t *testing.T) {
15611561
},
15621562
},
15631563
Conditions: []conditions.Condition{
1564-
conditions.NewGatewayUnsupportedField("AllowedListeners"),
1564+
conditions.NewGatewayAcceptedUnsupportedField("AllowedListeners"),
15651565
conditions.NewGatewayResolvedRefs(),
15661566
},
15671567
},
@@ -1603,7 +1603,7 @@ func TestBuildGateway(t *testing.T) {
16031603
IPFamily: helpers.GetPointer(ngfAPIv1alpha2.Dual),
16041604
},
16051605
Conditions: []conditions.Condition{
1606-
conditions.NewGatewayUnsupportedField("BackendTLS"),
1606+
conditions.NewGatewayAcceptedUnsupportedField("BackendTLS"),
16071607
conditions.NewGatewayRefInvalid(
16081608
"spec.infrastructure.parametersRef.kind: Unsupported value: \"wrong-kind\": supported values: \"NginxProxy\"",
16091609
),
@@ -1946,7 +1946,7 @@ func TestValidateUnsupportedGatewayFields(t *testing.T) {
19461946
},
19471947
},
19481948
expectedConds: []conditions.Condition{
1949-
conditions.NewGatewayUnsupportedField("AllowedListeners"),
1949+
conditions.NewGatewayAcceptedUnsupportedField("AllowedListeners"),
19501950
},
19511951
},
19521952
{
@@ -1958,8 +1958,8 @@ func TestValidateUnsupportedGatewayFields(t *testing.T) {
19581958
},
19591959
},
19601960
expectedConds: []conditions.Condition{
1961-
conditions.NewGatewayUnsupportedField("AllowedListeners"),
1962-
conditions.NewGatewayUnsupportedField("BackendTLS"),
1961+
conditions.NewGatewayAcceptedUnsupportedField("AllowedListeners"),
1962+
conditions.NewGatewayAcceptedUnsupportedField("BackendTLS"),
19631963
},
19641964
},
19651965
}

internal/controller/state/graph/grpcroute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func processGRPCRouteRules(
267267

268268
// add warning condition for unsupported fields if any
269269
if len(allRulesErrors.warn) > 0 {
270-
conds = append(conds, conditions.NewRouteUnsupportedField(allRulesErrors.warn.ToAggregate().Error()))
270+
conds = append(conds, conditions.NewRouteAcceptedUnsupportedField(allRulesErrors.warn.ToAggregate().Error()))
271271
}
272272

273273
if len(allRulesErrors.invalid) > 0 {

internal/controller/state/graph/grpcroute_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ func TestBuildGRPCRoute(t *testing.T) {
11401140
},
11411141
},
11421142
Conditions: []conditions.Condition{
1143-
conditions.NewRouteUnsupportedField("spec.rules[0].name: Forbidden: Name"),
1143+
conditions.NewRouteAcceptedUnsupportedField("spec.rules[0].name: Forbidden: Name"),
11441144
},
11451145
},
11461146
name: "valid route with unsupported field",
@@ -1175,7 +1175,7 @@ func TestBuildGRPCRoute(t *testing.T) {
11751175
},
11761176
},
11771177
Conditions: []conditions.Condition{
1178-
conditions.NewRouteUnsupportedField("spec.rules[0].name: Forbidden: Name"),
1178+
conditions.NewRouteAcceptedUnsupportedField("spec.rules[0].name: Forbidden: Name"),
11791179
conditions.NewRouteUnsupportedValue(
11801180
"All rules are invalid: [spec.rules[0].matches[0].method.service: Required value: service is required, " +
11811181
"spec.rules[0].matches[0].method.method: Required value: method is required]",
@@ -1571,7 +1571,7 @@ func TestProcessGRPCRouteRules_UnsupportedFields(t *testing.T) {
15711571
},
15721572
expectedValid: true,
15731573
expectedConds: []conditions.Condition{
1574-
conditions.NewRouteUnsupportedField("spec.rules[0].name: Forbidden: Name"),
1574+
conditions.NewRouteAcceptedUnsupportedField("spec.rules[0].name: Forbidden: Name"),
15751575
},
15761576
expectedWarns: 1,
15771577
},
@@ -1587,7 +1587,7 @@ func TestProcessGRPCRouteRules_UnsupportedFields(t *testing.T) {
15871587
},
15881588
expectedValid: true,
15891589
expectedConds: []conditions.Condition{
1590-
conditions.NewRouteUnsupportedField("[spec.rules[0].name: Forbidden: Name, " +
1590+
conditions.NewRouteAcceptedUnsupportedField("[spec.rules[0].name: Forbidden: Name, " +
15911591
"spec.rules[0].sessionPersistence: Forbidden: SessionPersistence]"),
15921592
},
15931593
expectedWarns: 2,

internal/controller/state/graph/httproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func processHTTPRouteRules(
274274

275275
// add warning condition for unsupported fields if any
276276
if len(allRulesErrors.warn) > 0 {
277-
conds = append(conds, conditions.NewRouteUnsupportedField(allRulesErrors.warn.ToAggregate().Error()))
277+
conds = append(conds, conditions.NewRouteAcceptedUnsupportedField(allRulesErrors.warn.ToAggregate().Error()))
278278
valid = true
279279
}
280280

internal/controller/state/graph/httproute_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ func TestBuildHTTPRoute(t *testing.T) {
978978
},
979979
},
980980
Conditions: []conditions.Condition{
981-
conditions.NewRouteUnsupportedField("spec.rules[0].name: Forbidden: Name"),
981+
conditions.NewRouteAcceptedUnsupportedField("spec.rules[0].name: Forbidden: Name"),
982982
},
983983
},
984984
name: "valid route with unsupported field",
@@ -1781,7 +1781,7 @@ func TestProcessHTTPRouteRules_UnsupportedFields(t *testing.T) {
17811781
},
17821782
expectedValid: true,
17831783
expectedConds: []conditions.Condition{
1784-
conditions.NewRouteUnsupportedField("spec.rules[0].name: Forbidden: Name"),
1784+
conditions.NewRouteAcceptedUnsupportedField("spec.rules[0].name: Forbidden: Name"),
17851785
},
17861786
expectedWarns: 1,
17871787
},
@@ -1801,7 +1801,7 @@ func TestProcessHTTPRouteRules_UnsupportedFields(t *testing.T) {
18011801
},
18021802
expectedValid: true,
18031803
expectedConds: []conditions.Condition{
1804-
conditions.NewRouteUnsupportedField("[spec.rules[0].name: Forbidden: Name, spec.rules[0].timeouts: " +
1804+
conditions.NewRouteAcceptedUnsupportedField("[spec.rules[0].name: Forbidden: Name, spec.rules[0].timeouts: " +
18051805
"Forbidden: Timeouts, spec.rules[0].retry: Forbidden: Retry, " +
18061806
"spec.rules[0].sessionPersistence: Forbidden: SessionPersistence]"),
18071807
},

0 commit comments

Comments
 (0)