Skip to content

Commit c46ef9d

Browse files
mikemorrisrobscott
andauthored
apis: add implementation for GEP-1731 HTTPRoute Retries (#3301)
* apis: add implementation for GEP-1731 HTTPRoute Retries * Update apis/v1/httproute_types.go Co-authored-by: Rob Scott <[email protected]> * Update apis/v1/httproute_types.go * remove experimental flags from struct fields * rerun make gen * isolate cel test changes which are needed for CRD gen to pass for some reason * remove inadvertent cel test file * revert linting changes to indentation in cel test files * remove guidance on 600-999 HTTP status code range for retries * remove guidance on 100-399 HTTP status code range for retries disallowed by kubebuilder validation now * regenerate CRDs * move GEP-1731 from implementable to experimental remove duplicate index entry --------- Co-authored-by: Mike Morris <[email protected]> Co-authored-by: Rob Scott <[email protected]>
1 parent 195a1d9 commit c46ef9d

File tree

11 files changed

+495
-7
lines changed

11 files changed

+495
-7
lines changed

apis/applyconfiguration/apis/v1/httprouteretry.go

+63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/applyconfiguration/apis/v1/httprouterule.go

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/applyconfiguration/internal/internal.go

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/applyconfiguration/utils.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1/httproute_types.go

+97
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ type HTTPRouteRule struct {
296296
// +optional
297297
Timeouts *HTTPRouteTimeouts `json:"timeouts,omitempty"`
298298

299+
// Retry defines the configuration for when to retry an HTTP request.
300+
//
301+
// Support: Extended
302+
//
303+
// +optional
304+
// <gateway:experimental>
305+
Retry *HTTPRouteRetry `json:"retry,omitempty"`
306+
299307
// SessionPersistence defines and configures session persistence
300308
// for the route rule.
301309
//
@@ -361,6 +369,95 @@ type HTTPRouteTimeouts struct {
361369
BackendRequest *Duration `json:"backendRequest,omitempty"`
362370
}
363371

372+
// HTTPRouteRetry defines retry configuration for an HTTPRoute.
373+
//
374+
// Implementations SHOULD retry on connection errors (disconnect, reset, timeout,
375+
// TCP failure) if a retry stanza is configured.
376+
type HTTPRouteRetry struct {
377+
// Codes defines the HTTP response status codes for which a backend request
378+
// should be retried.
379+
//
380+
// Support: Extended
381+
//
382+
// +optional
383+
Codes []HTTPRouteRetryStatusCode `json:"codes,omitempty"`
384+
385+
// Attempts specifies the maxmimum number of times an individual request
386+
// from the gateway to a backend should be retried.
387+
//
388+
// If the maximum number of retries has been attempted without a successful
389+
// response from the backend, the Gateway MUST return an error.
390+
//
391+
// When this field is unspecified, the number of times to attempt to retry
392+
// a backend request is implementation-specific.
393+
//
394+
// Support: Extended
395+
//
396+
// +optional
397+
Attempts *int `json:"attempts,omitempty"`
398+
399+
// Backoff specifies the minimum duration a Gateway should wait between
400+
// retry attempts and is represented in Gateway API Duration formatting.
401+
//
402+
// For example, setting the `rules[].retry.backoff` field to the value
403+
// `100ms` will cause a backend request to first be retried approximately
404+
// 100 milliseconds after timing out or receiving a response code configured
405+
// to be retryable.
406+
//
407+
// An implementation MAY use an exponential or alternative backoff strategy
408+
// for subsequent retry attempts, MAY cap the maximum backoff duration to
409+
// some amount greater than the specified minimum, and MAY add arbitrary
410+
// jitter to stagger requests, as long as unsuccessful backend requests are
411+
// not retried before the configured minimum duration.
412+
//
413+
// If a Request timeout (`rules[].timeouts.request`) is configured on the
414+
// route, the entire duration of the initial request and any retry attempts
415+
// MUST not exceed the Request timeout duration. If any retry attempts are
416+
// still in progress when the Request timeout duration has been reached,
417+
// these SHOULD be canceled if possible and the Gateway MUST immediately
418+
// return a timeout error.
419+
//
420+
// If a BackendRequest timeout (`rules[].timeouts.backendRequest`) is
421+
// configured on the route, any retry attempts which reach the configured
422+
// BackendRequest timeout duration without a response SHOULD be canceled if
423+
// possible and the Gateway should wait for at least the specified backoff
424+
// duration before attempting to retry the backend request again.
425+
//
426+
// If a BackendRequest timeout is _not_ configured on the route, retry
427+
// attempts MAY time out after an implementation default duration, or MAY
428+
// remain pending until a configured Request timeout or implementation
429+
// default duration for total request time is reached.
430+
//
431+
// When this field is unspecified, the time to wait between retry attempts
432+
// is implementation-specific.
433+
//
434+
// Support: Extended
435+
//
436+
// +optional
437+
Backoff *Duration `json:"backoff,omitempty"`
438+
}
439+
440+
// HTTPRouteRetryStatusCode defines an HTTP response status code for
441+
// which a backend request should be retried.
442+
//
443+
// Implementations MUST support the following status codes as retryable:
444+
//
445+
// * 500
446+
// * 502
447+
// * 503
448+
// * 504
449+
//
450+
// Implementations MAY support specifying additional discrete values in the
451+
// 500-599 range.
452+
//
453+
// Implementations MAY support specifying discrete values in the 400-499 range,
454+
// which are often inadvisable to retry.
455+
//
456+
// +kubebuilder:validation:Minimum:=400
457+
// +kubebuilder:validation:Maximum:=599
458+
// <gateway:experimental>
459+
type HTTPRouteRetryStatusCode int
460+
364461
// PathMatchType specifies the semantics of how HTTP paths should be compared.
365462
// Valid PathMatchType values, along with their support levels, are:
366463
//

apis/v1/zz_generated.deepcopy.go

+35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)