Skip to content

Commit 8b900ae

Browse files
committed
Update route condition where listener is not found
1 parent 8a19254 commit 8b900ae

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

docs/gateway-api-compatibility.md

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Fields:
118118
* `conditions` - partially supported. Supported (Condition/Status/Reason):
119119
* `Accepted/True/Accepted`
120120
* `Accepted/False/NoMatchingListenerHostname`
121+
* `Accepted/False/NoMatchingParent`
121122
* `Accepted/False/UnsupportedValue`: Custom reason for when the HTTPRoute includes an invalid or unsupported value.
122123
* `Accepted/False/InvalidListener`: Custom reason for when the HTTPRoute references an invalid listener.
123124
* `ResolvedRefs/True/ResolvedRefs`

internal/state/conditions/conditions.go

+11
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ func NewRouteInvalidGateway() Condition {
201201
}
202202
}
203203

204+
// NewRouteNoMatchingParent returns a Condition that indicates that the Route is not Accepted because
205+
// it specifies a Port and/or SectionName that does not match any Listeners in the Gateway.
206+
func NewRouteNoMatchingParent() Condition {
207+
return Condition{
208+
Type: string(v1beta1.RouteConditionAccepted),
209+
Status: metav1.ConditionFalse,
210+
Reason: string(v1beta1.RouteReasonNoMatchingParent),
211+
Message: "Listener is not found for this parent ref",
212+
}
213+
}
214+
204215
// NewDefaultListenerConditions returns the default Conditions that must be present in the status of a Listener.
205216
func NewDefaultListenerConditions() []Condition {
206217
return []Condition{

internal/state/graph/httproute.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,7 @@ func tryToAttachRouteToListeners(
317317
validListeners, listenerExists := findValidListeners(getSectionName(sectionName), listeners)
318318

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

325323
if len(validListeners) == 0 {

internal/state/graph/httproute_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ func TestBindRouteToListeners(t *testing.T) {
841841
Gateway: client.ObjectKeyFromObject(gw),
842842
Attachment: &ParentRefAttachmentStatus{
843843
Attached: false,
844-
FailedCondition: conditions.NewTODO("listener is not found"),
844+
FailedCondition: conditions.NewRouteNoMatchingParent(),
845845
AcceptedHostnames: map[string][]string{},
846846
},
847847
},

0 commit comments

Comments
 (0)