From 896d62df43e6df24043a3068dd73d4678d83b44c Mon Sep 17 00:00:00 2001 From: Kate Osborn Date: Thu, 11 Jul 2024 11:57:32 -0600 Subject: [PATCH] Replace TODO route condition with Accepted/False --- .../mode/static/state/change_processor_test.go | 4 ++-- .../mode/static/state/conditions/conditions.go | 17 +++++++++++------ .../mode/static/state/graph/route_common.go | 2 +- .../static/state/graph/route_common_test.go | 2 +- .../overview/gateway-api-compatibility.md | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/internal/mode/static/state/change_processor_test.go b/internal/mode/static/state/change_processor_test.go index 103f1e9a42..4b88aeb7de 100644 --- a/internal/mode/static/state/change_processor_test.go +++ b/internal/mode/static/state/change_processor_test.go @@ -886,11 +886,11 @@ var _ = Describe("ChangeProcessor", func() { expGraph.Routes[routeKey2] = expRouteHR2 expGraph.Routes[routeKey2].ParentRefs[0].Attachment = &graph.ParentRefAttachmentStatus{ AcceptedHostnames: map[string][]string{}, - FailedCondition: staticConds.NewTODO("Gateway is ignored"), + FailedCondition: staticConds.NewRouteNotAcceptedGatewayIgnored(), } expGraph.Routes[routeKey2].ParentRefs[1].Attachment = &graph.ParentRefAttachmentStatus{ AcceptedHostnames: map[string][]string{}, - FailedCondition: staticConds.NewTODO("Gateway is ignored"), + FailedCondition: staticConds.NewRouteNotAcceptedGatewayIgnored(), } expGraph.ReferencedSecrets[client.ObjectKeyFromObject(diffNsTLSSecret)] = &graph.Secret{ Source: diffNsTLSSecret, diff --git a/internal/mode/static/state/conditions/conditions.go b/internal/mode/static/state/conditions/conditions.go index aa32a3076a..bb53854c68 100644 --- a/internal/mode/static/state/conditions/conditions.go +++ b/internal/mode/static/state/conditions/conditions.go @@ -85,15 +85,20 @@ const ( // PolicyMessageTelemetryNotEnabled is a message used with the PolicyReasonNginxProxyConfigNotSet reason // when telemetry is not enabled in the NginxProxy resource. PolicyMessageTelemetryNotEnabled = "Telemetry is not enabled in the NginxProxy resource" + + // GatewayIgnoredReason is used with v1.RouteConditionAccepted when the route references a Gateway that is ignored + // by NGF. + GatewayIgnoredReason v1.RouteConditionReason = "GatewayIgnored" ) -// NewTODO returns a Condition that can be used as a placeholder for a condition that is not yet implemented. -func NewTODO(msg string) conditions.Condition { +// NewRouteNotAcceptedGatewayIgnored returns a Condition that indicates that the Route is not accepted by the Gateway +// because the Gateway is ignored by NGF. +func NewRouteNotAcceptedGatewayIgnored() conditions.Condition { return conditions.Condition{ - Type: "TODO", - Status: metav1.ConditionTrue, - Reason: "TODO", - Message: fmt.Sprintf("The condition for this has not been implemented yet: %s", msg), + Type: string(v1.RouteConditionAccepted), + Status: metav1.ConditionFalse, + Reason: string(GatewayIgnoredReason), + Message: "The Gateway is ignored by the controller", } } diff --git a/internal/mode/static/state/graph/route_common.go b/internal/mode/static/state/graph/route_common.go index cbf16027cb..8fe32a96c4 100644 --- a/internal/mode/static/state/graph/route_common.go +++ b/internal/mode/static/state/graph/route_common.go @@ -301,7 +301,7 @@ func bindRouteToListeners( referencesWinningGw := ref.Gateway.Namespace == gw.Source.Namespace && ref.Gateway.Name == gw.Source.Name if !referencesWinningGw { - attachment.FailedCondition = staticConds.NewTODO("Gateway is ignored") + attachment.FailedCondition = staticConds.NewRouteNotAcceptedGatewayIgnored() continue } diff --git a/internal/mode/static/state/graph/route_common_test.go b/internal/mode/static/state/graph/route_common_test.go index 3eb96f6f69..51f7c268a2 100644 --- a/internal/mode/static/state/graph/route_common_test.go +++ b/internal/mode/static/state/graph/route_common_test.go @@ -687,7 +687,7 @@ func TestBindRouteToListeners(t *testing.T) { SectionName: hr.Spec.ParentRefs[0].SectionName, Attachment: &ParentRefAttachmentStatus{ Attached: false, - FailedCondition: staticConds.NewTODO("Gateway is ignored"), + FailedCondition: staticConds.NewRouteNotAcceptedGatewayIgnored(), AcceptedHostnames: map[string][]string{}, }, }, diff --git a/site/content/overview/gateway-api-compatibility.md b/site/content/overview/gateway-api-compatibility.md index 45b4449015..50c118a41e 100644 --- a/site/content/overview/gateway-api-compatibility.md +++ b/site/content/overview/gateway-api-compatibility.md @@ -173,6 +173,7 @@ See the [static-mode]({{< relref "/reference/cli-help.md#static-mode">}}) comman - `Accepted/False/UnsupportedValue`: Custom reason for when the HTTPRoute includes an invalid or unsupported value. - `Accepted/False/InvalidListener`: Custom reason for when the HTTPRoute references an invalid listener. - `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. + - `Accepted/False/GatewayIgnored`: Custom reason for when the Gateway is ignored by NGINX Gateway Fabric. NGINX Gateway Fabric only supports one Gateway. - `ResolvedRefs/True/ResolvedRefs` - `ResolvedRefs/False/InvalidKind` - `ResolvedRefs/False/RefNotPermitted`