Skip to content

Commit

Permalink
Replace TODO route condition with Accepted/False
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-osborn committed Jul 11, 2024
1 parent 0edd3a8 commit 896d62d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/mode/static/state/change_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 11 additions & 6 deletions internal/mode/static/state/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/state/graph/route_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/mode/static/state/graph/route_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
},
},
Expand Down
1 change: 1 addition & 0 deletions site/content/overview/gateway-api-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit 896d62d

Please sign in to comment.