Skip to content

Conflicting guidance when a HTTPRoute refers to an invalid backend #1211

@robscott

Description

@robscott

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.

// 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.

// 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:

  1. 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.
  2. 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

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions