Skip to content

Commit e9719f7

Browse files
committed
Minimize errors
1 parent ede5117 commit e9719f7

File tree

6 files changed

+18
-30
lines changed

6 files changed

+18
-30
lines changed

internal/controller/state/conditions/conditions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func NewRouteUnsupportedField(msg string) Condition {
376376
Type: string(RouteConditionUnsupportedField),
377377
Status: metav1.ConditionTrue,
378378
Reason: string(RouteReasonUnsupportedField),
379-
Message: fmt.Sprintf("Some parameters are ignored due to an error: %s", msg),
379+
Message: fmt.Sprintf("Some parameters are ignored because they are not supported: %s", msg),
380380
}
381381
}
382382

@@ -978,7 +978,7 @@ func NewGatewayUnsupportedField(msg string) Condition {
978978
Type: string(GatewayConditionUnsupportedField),
979979
Status: metav1.ConditionTrue,
980980
Reason: string(GatewayReasonUnsupportedField),
981-
Message: fmt.Sprintf("Gateway is accepted, but some parameters are ignored due to an error: %s", msg),
981+
Message: fmt.Sprintf("Gateway is accepted, but some parameters are ignored because they are not supported: %s", msg),
982982
}
983983
}
984984

internal/controller/state/graph/grpcroute.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ func processGRPCRouteRules(
269269
if len(allRulesErrors.warn) > 0 {
270270
msg := "There are rules with unsupported fields configurations: " + allRulesErrors.warn.ToAggregate().Error()
271271
conds = append(conds, conditions.NewRouteUnsupportedField(msg))
272-
valid = true
273272
}
274273

275274
if len(allRulesErrors.invalid) > 0 {
@@ -463,13 +462,13 @@ func checkForUnsupportedGRPCFields(rule v1.GRPCRouteRule, rulePath *field.Path)
463462
if rule.Name != nil {
464463
ruleErrors = append(ruleErrors, field.Forbidden(
465464
rulePath.Child("name"),
466-
"NGINX Gateway Fabric does not support \"SectionName\" field at the moment",
465+
"rule names are not supported",
467466
))
468467
}
469468
if rule.SessionPersistence != nil {
470469
ruleErrors = append(ruleErrors, field.Forbidden(
471470
rulePath.Child("sessionPersistence"),
472-
"NGINX Gateway Fabric does not support \"SessionPersistence\" field at the moment",
471+
"sessionPersistence is not supported",
473472
))
474473
}
475474

internal/controller/state/graph/grpcroute_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ func TestBuildGRPCRoute(t *testing.T) {
11411141
},
11421142
Conditions: []conditions.Condition{
11431143
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: " +
1144-
"spec.rules[0].name: Forbidden: NGINX Gateway Fabric does not support \"SectionName\" field at the moment"),
1144+
"spec.rules[0].name: Forbidden: rule names are not supported"),
11451145
},
11461146
},
11471147
name: "valid route with unsupported field",
@@ -1177,7 +1177,7 @@ func TestBuildGRPCRoute(t *testing.T) {
11771177
},
11781178
Conditions: []conditions.Condition{
11791179
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: " +
1180-
"spec.rules[0].name: Forbidden: NGINX Gateway Fabric does not support \"SectionName\" field at the moment"),
1180+
"spec.rules[0].name: Forbidden: rule names are not supported"),
11811181
conditions.NewRouteUnsupportedValue(
11821182
"All rules are invalid: [spec.rules[0].matches[0].method.service: Required value: service is required, " +
11831183
"spec.rules[0].matches[0].method.method: Required value: method is required]",
@@ -1574,7 +1574,7 @@ func TestProcessGRPCRouteRules_UnsupportedFields(t *testing.T) {
15741574
expectedValid: true,
15751575
expectedConds: []conditions.Condition{
15761576
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: spec.rules[0].name: " +
1577-
"Forbidden: NGINX Gateway Fabric does not support \"SectionName\" field at the moment"),
1577+
"Forbidden: rule names are not supported"),
15781578
},
15791579
expectedWarns: 1,
15801580
},
@@ -1591,9 +1591,8 @@ func TestProcessGRPCRouteRules_UnsupportedFields(t *testing.T) {
15911591
expectedValid: true,
15921592
expectedConds: []conditions.Condition{
15931593
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: " +
1594-
"[spec.rules[0].name: Forbidden: NGINX Gateway Fabric does not support \"SectionName\" field at the moment, " +
1595-
"spec.rules[0].sessionPersistence: Forbidden: NGINX Gateway Fabric does not support \"SessionPersistence\" " +
1596-
"field at the moment]"),
1594+
"[spec.rules[0].name: Forbidden: rule names are not supported, " +
1595+
"spec.rules[0].sessionPersistence: Forbidden: sessionPersistence is not supported]"),
15971596
},
15981597
expectedWarns: 2,
15991598
},

internal/controller/state/graph/httproute.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,25 +537,25 @@ func checkForUnsupportedHTTPFields(rule v1.HTTPRouteRule, rulePath *field.Path)
537537
if rule.Name != nil {
538538
ruleErrors = append(ruleErrors, field.Forbidden(
539539
rulePath.Child("name"),
540-
"NGINX Gateway Fabric does not support \"SectionName\" field at the moment",
540+
"rule names are not supported",
541541
))
542542
}
543543
if rule.Timeouts != nil {
544544
ruleErrors = append(ruleErrors, field.Forbidden(
545545
rulePath.Child("timeouts"),
546-
"NGINX Gateway Fabric does not support \"HTTPRouteTimeouts\" field at the moment",
546+
"timeouts are not supported",
547547
))
548548
}
549549
if rule.Retry != nil {
550550
ruleErrors = append(ruleErrors, field.Forbidden(
551551
rulePath.Child("retry"),
552-
"NGINX Gateway Fabric does not support \"HTTPRouteRetry\" field at the moment",
552+
"retry is not supported",
553553
))
554554
}
555555
if rule.SessionPersistence != nil {
556556
ruleErrors = append(ruleErrors, field.Forbidden(
557557
rulePath.Child("sessionPersistence"),
558-
"NGINX Gateway Fabric does not support \"SessionPersistence\" field at the moment",
558+
"sessionPersistence is not supported",
559559
))
560560
}
561561

internal/controller/state/graph/httproute_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ func TestBuildHTTPRoute(t *testing.T) {
979979
},
980980
Conditions: []conditions.Condition{
981981
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: " +
982-
"spec.rules[0].name: Forbidden: NGINX Gateway Fabric does not support \"SectionName\" field at the moment"),
982+
"spec.rules[0].name: Forbidden: rule names are not supported"),
983983
},
984984
},
985985
name: "valid route with unsupported field",
@@ -1783,7 +1783,7 @@ func TestProcessHTTPRouteRules_UnsupportedFields(t *testing.T) {
17831783
expectedValid: true,
17841784
expectedConds: []conditions.Condition{
17851785
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: spec.rules[0].name: " +
1786-
"Forbidden: NGINX Gateway Fabric does not support \"SectionName\" field at the moment"),
1786+
"Forbidden: rule names are not supported"),
17871787
},
17881788
expectedWarns: 1,
17891789
},
@@ -1804,11 +1804,9 @@ func TestProcessHTTPRouteRules_UnsupportedFields(t *testing.T) {
18041804
expectedValid: true,
18051805
expectedConds: []conditions.Condition{
18061806
conditions.NewRouteUnsupportedField("There are rules with unsupported fields configurations: " +
1807-
"[spec.rules[0].name: Forbidden: NGINX Gateway Fabric does not support \"SectionName\" " +
1808-
"field at the moment, spec.rules[0].timeouts: Forbidden: NGINX Gateway Fabric does not support " +
1809-
"\"HTTPRouteTimeouts\" field at the moment, spec.rules[0].retry: Forbidden: NGINX Gateway Fabric " +
1810-
"does not support \"HTTPRouteRetry\" field at the moment, spec.rules[0].sessionPersistence: Forbidden: " +
1811-
"NGINX Gateway Fabric does not support \"SessionPersistence\" field at the moment]"),
1807+
"[spec.rules[0].name: Forbidden: rule names are not supported, spec.rules[0].timeouts: " +
1808+
"Forbidden: timeouts are not supported, spec.rules[0].retry: Forbidden: retry is not supported, " +
1809+
"spec.rules[0].sessionPersistence: Forbidden: sessionPersistence is not supported]"),
18121810
},
18131811
expectedWarns: 4,
18141812
},

internal/controller/state/graph/route_common.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ type L7RouteSpec struct {
143143
}
144144

145145
type RouteRule struct {
146-
// Name is the name of a section in a Kubernetes resource.
147-
Name *v1.SectionName
148-
// Timeouts defines timeouts that can be configured for an HTTPRoute.
149-
Timeouts *v1.HTTPRouteTimeouts
150-
// Retry defines retry configuration for an HTTPRoute.
151-
Retry *v1.HTTPRouteRetry
152-
// SessionPersistence defines the desired state of SessionPersistence.
153-
SessionPersistence *v1.SessionPersistence
154146
// Matches define the predicate used to match requests to a given action.
155147
Matches []v1.HTTPRouteMatch
156148
// RouteBackendRefs are a wrapper for v1.BackendRef and any BackendRef filters from the HTTPRoute or GRPCRoute.

0 commit comments

Comments
 (0)