-
Notifications
You must be signed in to change notification settings - Fork 600
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
[Experimental-Feature] DeliverySpec.RetryAfter #5813
Changes from 9 commits
91b3795
b942a39
fea4cc5
a6d0d35
bfd444b
8e602dc
3f7d714
d227062
692765c
88e75b6
9fc7448
c28795b
6bb059a
6d5ec5f
3e0e3e2
2e71d1d
87be0cc
094a102
1602941
2eab560
5ce88dd
1cab330
5be0e20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,10 @@ import ( | |
"context" | ||
|
||
"github.com/rickb777/date/period" | ||
"knative.dev/eventing/pkg/apis/feature" | ||
"knative.dev/pkg/apis" | ||
duckv1 "knative.dev/pkg/apis/duck/v1" | ||
|
||
"knative.dev/eventing/pkg/apis/feature" | ||
) | ||
|
||
// DeliverySpec contains the delivery options for event senders, | ||
|
@@ -60,6 +61,33 @@ type DeliverySpec struct { | |
// For exponential policy, backoff delay is backoffDelay*2^<numberOfRetries>. | ||
// +optional | ||
BackoffDelay *string `json:"backoffDelay,omitempty"` | ||
|
||
// RetryAfter controls how "Retry-After" header durations are handled for 429 and 503 response codes. | ||
// If not provided, the default behavior is to ignore "Retry-After" headers in responses. | ||
// | ||
// Note: This API is EXPERIMENTAL and might break anytime. For more details: https://github.com/knative/eventing/issues/5811 | ||
// +optional | ||
RetryAfter *RetryAfter `json:"retryAfter,omitempty"` | ||
} | ||
|
||
// RetryAfter contains configuration related to the handling of "Retry-After" headers. | ||
type RetryAfter struct { | ||
// Enabled is a flag indicating whether to respect the "Retry-After" header duration. | ||
// If enabled, the largest of the normal backoff duration and the "Retry-After" | ||
// header value will be used when calculating the next backoff duration. This will | ||
// only be considered when a 429 (Too Many Requests) or 503 (Service Unavailable) | ||
// response code is received and Retry is greater than 0. | ||
Enabled bool `json:"enabled"` | ||
|
||
// MaxDuration is the maximum time to wait before retrying. It is intended as an | ||
// override to protect against excessively large "Retry-After" durations. If provided, | ||
// the value must be greater than 0. If not provided, the largest of the "Retry-After" | ||
// duration and the normal backoff duration will be used. | ||
// More information on Duration format: | ||
// - https://www.iso.org/iso-8601-date-and-time-format.html | ||
// - https://en.wikipedia.org/wiki/ISO_8601 | ||
// +optional | ||
MaxDuration *string `json:"maxDuration,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming we do not toggle (just thinking out loud) and have respecting Setting 🤷 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the idea is that at least in GA it would be always respected and you could opt out by specifying "PT0S" or something similar. |
||
} | ||
|
||
func (ds *DeliverySpec) Validate(ctx context.Context) *apis.FieldError { | ||
|
@@ -101,6 +129,20 @@ func (ds *DeliverySpec) Validate(ctx context.Context) *apis.FieldError { | |
errs = errs.Also(apis.ErrInvalidValue(*ds.BackoffDelay, "backoffDelay")) | ||
} | ||
} | ||
|
||
if ds.RetryAfter != nil { | ||
if feature.FromContext(ctx).IsEnabled(feature.DeliveryRetryAfter) { | ||
if ds.RetryAfter.MaxDuration != nil && *ds.RetryAfter.MaxDuration != "" { | ||
m, me := period.Parse(*ds.RetryAfter.MaxDuration) | ||
if me != nil || m.IsZero() { | ||
errs = errs.Also(apis.ErrInvalidValue(*ds.RetryAfter.MaxDuration, "retryAfter.maxDuration")) | ||
} | ||
} | ||
} else { | ||
errs = errs.Also(apis.ErrDisallowedFields("retryAfter")) | ||
} | ||
} | ||
|
||
return errs | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we always respect the
Retry-After
?I am not really sure I like the toggling here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is stale - based on the original design which has evolved (is evolving in the associated Issue). Yes, everyone was against the "enabled" flag and in the latest design it is gone. I'm waiting to update this PR for the new design to settle - i need to summarize and push for agreement again...