@@ -296,6 +296,14 @@ type HTTPRouteRule struct {
296
296
// +optional
297
297
Timeouts * HTTPRouteTimeouts `json:"timeouts,omitempty"`
298
298
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
+
299
307
// SessionPersistence defines and configures session persistence
300
308
// for the route rule.
301
309
//
@@ -361,6 +369,95 @@ type HTTPRouteTimeouts struct {
361
369
BackendRequest * Duration `json:"backendRequest,omitempty"`
362
370
}
363
371
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
+
364
461
// PathMatchType specifies the semantics of how HTTP paths should be compared.
365
462
// Valid PathMatchType values, along with their support levels, are:
366
463
//
0 commit comments