Skip to content

Commit a9dbdca

Browse files
authored
Replace TODO route condition with an Accepted/False condition (#2228)
Problem: When a route references a Gateway that is ignored, NGF adds the TODO condition: "The condition for this has not been implemented yet: Gateway is ignored. " This does not communicate to the user that the route is not accepted because the Gateway it references is ignored. Solution: Change this condition to be Accepted/False/GatewayIgnored.
1 parent efea992 commit a9dbdca

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

internal/mode/static/state/change_processor_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,11 @@ var _ = Describe("ChangeProcessor", func() {
886886
expGraph.Routes[routeKey2] = expRouteHR2
887887
expGraph.Routes[routeKey2].ParentRefs[0].Attachment = &graph.ParentRefAttachmentStatus{
888888
AcceptedHostnames: map[string][]string{},
889-
FailedCondition: staticConds.NewTODO("Gateway is ignored"),
889+
FailedCondition: staticConds.NewRouteNotAcceptedGatewayIgnored(),
890890
}
891891
expGraph.Routes[routeKey2].ParentRefs[1].Attachment = &graph.ParentRefAttachmentStatus{
892892
AcceptedHostnames: map[string][]string{},
893-
FailedCondition: staticConds.NewTODO("Gateway is ignored"),
893+
FailedCondition: staticConds.NewRouteNotAcceptedGatewayIgnored(),
894894
}
895895
expGraph.ReferencedSecrets[client.ObjectKeyFromObject(diffNsTLSSecret)] = &graph.Secret{
896896
Source: diffNsTLSSecret,

internal/mode/static/state/conditions/conditions.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,20 @@ const (
8585
// PolicyMessageTelemetryNotEnabled is a message used with the PolicyReasonNginxProxyConfigNotSet reason
8686
// when telemetry is not enabled in the NginxProxy resource.
8787
PolicyMessageTelemetryNotEnabled = "Telemetry is not enabled in the NginxProxy resource"
88+
89+
// GatewayIgnoredReason is used with v1.RouteConditionAccepted when the route references a Gateway that is ignored
90+
// by NGF.
91+
GatewayIgnoredReason v1.RouteConditionReason = "GatewayIgnored"
8892
)
8993

90-
// NewTODO returns a Condition that can be used as a placeholder for a condition that is not yet implemented.
91-
func NewTODO(msg string) conditions.Condition {
94+
// NewRouteNotAcceptedGatewayIgnored returns a Condition that indicates that the Route is not accepted by the Gateway
95+
// because the Gateway is ignored by NGF.
96+
func NewRouteNotAcceptedGatewayIgnored() conditions.Condition {
9297
return conditions.Condition{
93-
Type: "TODO",
94-
Status: metav1.ConditionTrue,
95-
Reason: "TODO",
96-
Message: fmt.Sprintf("The condition for this has not been implemented yet: %s", msg),
98+
Type: string(v1.RouteConditionAccepted),
99+
Status: metav1.ConditionFalse,
100+
Reason: string(GatewayIgnoredReason),
101+
Message: "The Gateway is ignored by the controller",
97102
}
98103
}
99104

internal/mode/static/state/graph/route_common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func bindRouteToListeners(
301301
referencesWinningGw := ref.Gateway.Namespace == gw.Source.Namespace && ref.Gateway.Name == gw.Source.Name
302302

303303
if !referencesWinningGw {
304-
attachment.FailedCondition = staticConds.NewTODO("Gateway is ignored")
304+
attachment.FailedCondition = staticConds.NewRouteNotAcceptedGatewayIgnored()
305305
continue
306306
}
307307

internal/mode/static/state/graph/route_common_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ func TestBindRouteToListeners(t *testing.T) {
687687
SectionName: hr.Spec.ParentRefs[0].SectionName,
688688
Attachment: &ParentRefAttachmentStatus{
689689
Attached: false,
690-
FailedCondition: staticConds.NewTODO("Gateway is ignored"),
690+
FailedCondition: staticConds.NewRouteNotAcceptedGatewayIgnored(),
691691
AcceptedHostnames: map[string][]string{},
692692
},
693693
},

site/content/overview/gateway-api-compatibility.md

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ See the [static-mode]({{< relref "/reference/cli-help.md#static-mode">}}) comman
173173
- `Accepted/False/UnsupportedValue`: Custom reason for when the HTTPRoute includes an invalid or unsupported value.
174174
- `Accepted/False/InvalidListener`: Custom reason for when the HTTPRoute references an invalid listener.
175175
- `Accepted/False/GatewayNotProgrammed`: Custom reason for when the Gateway is not Programmed. HTTPRoute can be valid and configured, but will maintain this status as long as the Gateway is not Programmed.
176+
- `Accepted/False/GatewayIgnored`: Custom reason for when the Gateway is ignored by NGINX Gateway Fabric. NGINX Gateway Fabric only supports one Gateway.
176177
- `ResolvedRefs/True/ResolvedRefs`
177178
- `ResolvedRefs/False/InvalidKind`
178179
- `ResolvedRefs/False/RefNotPermitted`

0 commit comments

Comments
 (0)