Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update route condition where listener is not found #675

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/gateway-api-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Fields:
* `conditions` - partially supported. Supported (Condition/Status/Reason):
* `Accepted/True/Accepted`
* `Accepted/False/NoMatchingListenerHostname`
* `Accepted/False/NoMatchingParent`
* `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.
* `ResolvedRefs/True/ResolvedRefs`
Expand Down
11 changes: 11 additions & 0 deletions internal/state/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ func NewRouteInvalidGateway() Condition {
}
}

// NewRouteNoMatchingParent returns a Condition that indicates that the Route is not Accepted because
// it specifies a Port and/or SectionName that does not match any Listeners in the Gateway.
func NewRouteNoMatchingParent() Condition {
return Condition{
Type: string(v1beta1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(v1beta1.RouteReasonNoMatchingParent),
Message: "Listener is not found for this parent ref",
}
}

// NewDefaultListenerConditions returns the default Conditions that must be present in the status of a Listener.
func NewDefaultListenerConditions() []Condition {
return []Condition{
Expand Down
4 changes: 1 addition & 3 deletions internal/state/graph/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ func tryToAttachRouteToListeners(
validListeners, listenerExists := findValidListeners(getSectionName(sectionName), listeners)

if !listenerExists {
// FIXME(pleshakov): Add a proper condition once it is available in the Gateway API.
// https://github.com/nginxinc/nginx-kubernetes-gateway/issues/665
return conditions.NewTODO("listener is not found"), false
return conditions.NewRouteNoMatchingParent(), false
}

if len(validListeners) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/state/graph/httproute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ func TestBindRouteToListeners(t *testing.T) {
Gateway: client.ObjectKeyFromObject(gw),
Attachment: &ParentRefAttachmentStatus{
Attached: false,
FailedCondition: conditions.NewTODO("listener is not found"),
FailedCondition: conditions.NewRouteNoMatchingParent(),
AcceptedHostnames: map[string][]string{},
},
},
Expand Down