Skip to content

Commit 18f9c91

Browse files
author
Nick Young
committed
Fix PR comments and update v1beta1 resources
Signed-off-by: Nick Young <ynick@vmware.com>
1 parent 360e25a commit 18f9c91

File tree

4 files changed

+49
-24
lines changed

4 files changed

+49
-24
lines changed

apis/v1alpha2/httproute_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ type HTTPRouteRule struct {
219219
// MUST receive a 500 status code.
220220
//
221221
// For example, if two backends are specified with equal weights, and one is
222-
// invalid, 50 percent of traffic must randomly receive a 500.
222+
// invalid, 50 percent of traffic must receive a 500. Implementations may
223+
// choose how that 50 percent is determined.
223224
//
224225
// When a HTTPBackendRef refers to a Service that has no ready endpoints,
225226
// implementations MAY return a 503 for requests to that backend instead.

apis/v1beta1/httproute_types.go

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -201,26 +201,31 @@ type HTTPRouteRule struct {
201201
// BackendRefs defines the backend(s) where matching requests should be
202202
// sent.
203203
//
204-
// A 500 status code MUST be returned if there are no BackendRefs or filters
205-
// specified that would result in a response being sent.
204+
// Failure behavior here depends on how many BackendRefs are specified and
205+
// how many are invalid.
206206
//
207-
// A BackendRef is considered invalid when it refers to:
207+
// If *all* entries in BackendRefs are invalid, and there are also no filters
208+
// specified in this route rule, *all* traffic which matches this rule MUST
209+
// recieve a 500 status code (exactly).
208210
//
209-
// * an unknown or unsupported kind of resource
210-
// * a resource that does not exist
211-
// * a resource in another namespace when the reference has not been
212-
// explicitly allowed by a ReferenceGrant (or equivalent concept).
211+
// See the HTTPBackendRef definition for the rules about what makes a single
212+
// HTTPBackendRef invalid.
213213
//
214-
// When a BackendRef is invalid, 500 status codes MUST be returned for
214+
// When a HTTPBackendRef is invalid, 500 status codes MUST be returned for
215215
// requests that would have otherwise been routed to an invalid backend. If
216216
// multiple backends are specified, and some are invalid, the proportion of
217217
// requests that would otherwise have been routed to an invalid backend
218218
// MUST receive a 500 status code.
219219
//
220-
// When a BackendRef refers to a Service that has no ready endpoints, it is
221-
// recommended to return a 503 status code.
220+
// For example, if two backends are specified with equal weights, and one is
221+
// invalid, 50 percent of traffic must receive a 500. Implementations may
222+
// choose how that 50 percent is determined.
223+
//
224+
// When a HTTPBackendRef refers to a Service that has no ready endpoints,
225+
// implementations MAY return a 503 for requests to that backend instead.
222226
//
223227
// Support: Core for Kubernetes Service
228+
//
224229
// Support: Custom for any other resource
225230
//
226231
// Support for weight: Core
@@ -874,21 +879,31 @@ type HTTPRequestMirrorFilter struct {
874879
type HTTPBackendRef struct {
875880
// BackendRef is a reference to a backend to forward matched requests to.
876881
//
877-
// If the referent cannot be found, this HTTPBackendRef is invalid and must
878-
// be dropped from the Gateway. The controller must ensure the
879-
// "ResolvedRefs" condition on the Route is set to `status: False` and not
880-
// configure this backend in the underlying implementation.
882+
// A BackendRef can be invalid for the following reasons. In all cases, the
883+
// implementation MUST ensure the `ResolvedRefs` Condition on the Route
884+
// is set to `status: False`, with a Reason and Message that indicate
885+
// what is the cause of the error.
881886
//
882-
// If there is a cross-namespace reference to an *existing* object
883-
// that is not covered by a ReferenceGrant, the controller must ensure the
884-
// "ResolvedRefs" condition on the Route is set to `status: False`,
885-
// with the "RefNotPermitted" reason and not configure this backend in the
886-
// underlying implementation.
887+
// A BackendRef is invalid if:
887888
//
888-
// In either error case, the Message of the `ResolvedRefs` Condition
889-
// should be used to provide more detail about the problem.
889+
// * It refers to an unknown or unsupported kind of resource. In this
890+
// case, the Reason must be set to `InvalidKind` and Message of the
891+
// Condition must explain which kind of resource is unknown or unsupported.
890892
//
891-
// Support: Custom
893+
// * It refers to a resource that does not exist. In this case, the Reason must
894+
// be set to `BackendNotFound` and the Message of the Condition must explain
895+
// which resource does not exist.
896+
//
897+
// * It refers a resource in another namespace when the reference has not been
898+
// explicitly allowed by a ReferenceGrant (or equivalent concept). In this
899+
// case, the Reason must be set to `RefNotPermitted` and the Message of the
900+
// Condition must explain which cross-namespace reference is not allowed.
901+
//
902+
// Support: Core for Kubernetes Service
903+
//
904+
// Support: Custom for any other resource
905+
//
906+
// Support for weight: Core
892907
//
893908
// +optional
894909
BackendRef `json:",inline"`

apis/v1beta1/shared_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ const (
242242
// another namespace, where the object in the other namespace does
243243
// not have a ReferenceGrant explicitly allowing the reference.
244244
RouteReasonRefNotPermitted RouteConditionReason = "RefNotPermitted"
245+
246+
// This reason is used with the "ResolvedRefs" condition when
247+
// one of the Route's rules has a reference to an unknown or unsupported
248+
// Group and/or Kind.
249+
RouteReasonInvalidKind RouteConditionReason = "InvalidKind"
250+
251+
// This reason is used with the "ResolvedRefs" condition when
252+
// one of the Route's rules has a reference to a resource that does not exist.
253+
RouteReasonBackendNotFound RouteConditionReason = "BackendNotFound"
245254
)
246255

247256
// RouteParentStatus describes the status of a route with respect to an

conformance/tests/httproute-invalid-cross-namespace-backend-ref.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var HTTPRouteInvalidCrossNamespaceBackendRef = suite.ConformanceTest{
4646
// The Route must be Attached.
4747
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeReady(t, suite.Client, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
4848

49-
t.Run("HTTPRoute with only a nonexistent BackendRef has a ResolvedRefs Condition with status False and Reason RefNotPermitted", func(t *testing.T) {
49+
t.Run("HTTPRoute with a cross-namespace BackendRef and no ReferenceGrant has a ResolvedRefs Condition with status False and Reason RefNotPermitted", func(t *testing.T) {
5050

5151
resolvedRefsCond := metav1.Condition{
5252
Type: string(v1alpha2.RouteConditionResolvedRefs),

0 commit comments

Comments
 (0)