-
-
Notifications
You must be signed in to change notification settings - Fork 633
Jitter the ARI Retry-After header amount 20% either side of 6 hours #8576
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -2726,7 +2726,8 @@ func (wfe *WebFrontEndImpl) RenewalInfo(ctx context.Context, logEvent *web.Reque | |
| return | ||
| } | ||
|
|
||
| response.Header().Set(headerRetryAfter, fmt.Sprintf("%d", int(6*time.Hour/time.Second))) | ||
| retryAfter := createJitter(int(6 * time.Hour / time.Second)) | ||
| response.Header().Set(headerRetryAfter, fmt.Sprintf("%d", retryAfter)) | ||
| err = wfe.writeJsonResponse(response, logEvent, http.StatusOK, renewalInfo) | ||
| if err != nil { | ||
| wfe.sendError(response, logEvent, probs.ServerInternal("Error marshalling renewalInfo"), err) | ||
|
|
@@ -2737,3 +2738,17 @@ func (wfe *WebFrontEndImpl) RenewalInfo(ctx context.Context, logEvent *web.Reque | |
| func urlForAuthz(authz core.Authorization, request *http.Request) string { | ||
| return web.RelativeEndpoint(request, fmt.Sprintf("%s%d/%s", authzPath, authz.RegistrationID, authz.ID)) | ||
| } | ||
|
|
||
| // createJitter will return a random integer within a 20% window of the base that is provided. | ||
| // If the jittered amount is a negative number, the jitter is retried until a positive | ||
| // number is generated | ||
| func createJitter(base int) int { | ||
| factor := 0.2 * (2*rand.Float64() - 1) | ||
| jittered := int(float64(base) * (1 + factor)) | ||
|
|
||
| if jittered < 0 { | ||
|
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. Hi, I think that this condition should never be met for positive inputs since then jittered>base*0.8>0. From my understanding of the context, I suggest to remove this branch and adjust the comment. |
||
| return createJitter(base) | ||
| } | ||
|
|
||
| return jittered | ||
| } | ||
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.
Two minor comments: