-
Notifications
You must be signed in to change notification settings - Fork 566
Description
I was trying to write an issue describing what conformance tests should look like for this, and I think.
On the HTTPBackendRef type definition we say that if the referent can't be found or is not allowed by a ReferenceGrant the BackendRef must be dropped from the Gateway.
gateway-api/apis/v1beta1/httproute_types.go
Lines 870 to 879 in 3f4b981
// If the referent cannot be found, this HTTPBackendRef is invalid and must | |
// be dropped from the Gateway. The controller must ensure the | |
// "ResolvedRefs" condition on the Route is set to `status: False` and not | |
// configure this backend in the underlying implementation. | |
// | |
// If there is a cross-namespace reference to an *existing* object | |
// that is not covered by a ReferenceGrant, the controller must ensure the | |
// "ResolvedRefs" condition on the Route is set to `status: False`, | |
// with the "RefNotPermitted" reason and not configure this backend in the | |
// underlying implementation. |
On the BackendRefs field we say "When a BackendRef is invalid, 500 status codes MUST be returned for requests that would have otherwise been routed to an invalid backend." "Invalid" is defined to include both of the scenarios described above.
gateway-api/apis/v1beta1/httproute_types.go
Lines 207 to 218 in 3f4b981
// A BackendRef is considered invalid when it refers to: | |
// | |
// * an unknown or unsupported kind of resource | |
// * a resource that does not exist | |
// * a resource in another namespace when the reference has not been | |
// explicitly allowed by a ReferenceGrant (or equivalent concept). | |
// | |
// When a BackendRef is invalid, 500 status codes MUST be returned for | |
// requests that would have otherwise been routed to an invalid backend. If | |
// multiple backends are specified, and some are invalid, the proportion of | |
// requests that would otherwise have been routed to an invalid backend | |
// MUST receive a 500 status code. |
I think the rationale behind both of these conflicting guidelines makes sense in isolation. Maybe the following guidelines make sense:
- Don't attach a Route to a Gateway if a Route has no valid BackendRefs or include a filter with an invalid reference - this will result in a 404 unless another Route matches.
- Do attach a Route to a Gateway if only a portion of BackendRefs are invalid - this will result in a 500 for traffic that would have otherwise been routed to the invalid BackendRef.
The motivation for 2 is to avoid dropping a Route entirely if someone adds an invalid reference as part of a traffic split, ie send 10% to canary service, but that new reference to canary service is broken. I'm not sure that 2 is worthwhile, so an alternative would be to just say that Routes should not be attached if they contain any invalid references.
Note: I think this is a blocker for v0.5.0, but not v0.5.0-rc1.
I know a lot of people have been involved in this broader discussion around status codes, apologies if I miss anyone here. As always, appreciate anyone's thoughts on this.
/cc @mikemorris @nathancoleman @youngnick @howardjohn @shaneutt