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

Updating HTTP status code documentation to use 404 instead of 503 #1151

Merged
merged 1 commit into from
May 12, 2022
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
29 changes: 22 additions & 7 deletions apis/v1alpha2/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ type HTTPRouteRule struct {
// matching precedence MUST be granted to the first matching rule meeting
// the above criteria.
//
// When no rules matching a request have been successfully attached to the
// parent a request is coming from, a HTTP 404 status code MUST be returned.
//
// +optional
// +kubebuilder:validation:MaxItems=8
// +kubebuilder:default={{path:{ type: "PathPrefix", value: "/"}}}
Expand Down Expand Up @@ -187,13 +190,25 @@ type HTTPRouteRule struct {

// BackendRefs defines the backend(s) where matching requests should be
// sent.

// If unspecified or invalid (refers to a non-existent resource or a Service
// with no endpoints), the rule performs no forwarding. If there are also no
// filters specified that would result in a response being sent, a HTTP 503
// status code is returned. 503 responses must be sent so that the overall
// weight is respected; if an invalid backend is requested to have 80% of
// requests, then 80% of requests must get a 503 instead.
//
// A 404 status code MUST be returned if there are no BackendRefs or filters
// specified that would result in a response being sent.
//
// 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 ReferencePolicy (or equivalent concept).
//
// When a BackendRef is invalid, 404 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 404 status code.
//
// When a BackendRef refers to a Service that has no ready endpoints, it is
// recommended to return a 503 status code.
//
// Support: Core for Kubernetes Service
// Support: Custom for any other resource
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/tlsroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type TLSRouteRule struct {
// a Service with no endpoints), the rule performs no forwarding; if no
// filters are specified that would result in a response being sent, the
// underlying implementation must actively reject request attempts to this
// backend, by rejecting the connection or returning a 503 status code.
// backend, by rejecting the connection or returning a 404 status code.
// Request rejections must respect weight; if an invalid backend is
// requested to have 80% of requests, then 80% of requests must be rejected
// instead.
Expand Down
30 changes: 20 additions & 10 deletions config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 20 additions & 10 deletions config/crd/stable/gateway.networking.k8s.io_httproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/crd/stable/gateway.networking.k8s.io_tlsroutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion conformance/tests/httproute-invalid-reference-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var HTTPRouteInvalidReferencePolicy = suite.ConformanceTest{
Method: "GET",
Path: "/v2",
},
StatusCode: 503,
StatusCode: 404,
})
})
},
Expand Down
2 changes: 1 addition & 1 deletion site-src/v1alpha2/api-types/httproute.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Specifying a core filter multiple times has unspecified or custom conformance.

BackendRefs defines API objects where matching requests should be sent. If
unspecified, the rule performs no forwarding. If unspecified and no filters
are specified that would result in a response being sent, a 503 error code
are specified that would result in a response being sent, a 404 error code
is returned.

The following example forwards HTTP requests for prefix `/bar` to service
Expand Down