-
Notifications
You must be signed in to change notification settings - Fork 788
sending err back to fetch to trigger backoff retry #2136
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
Merged
aswanidutt
merged 15 commits into
main
from
aswanidutt/VAULT-38829-Vault-Agent-retrybackoff-config
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
354e413
sending err back to fetch to trigger retry
aswanidutt 2d77658
adding maxbackoff 5m and maxretries unlimited
aswanidutt d6bb7af
missed view
aswanidutt e1ed626
using cenkalti v4 for retry backoff with jitter
aswanidutt ccec01d
fixing linter
aswanidutt cc275ee
using the default config_retry instead of custom retry
aswanidutt 04b3bfd
cleaning up
aswanidutt 56e76a8
Update dependency/vault_common_test.go
aswanidutt 0474863
Update dependency/vault_common_test.go
aswanidutt 0f8616c
pr feedback
aswanidutt b6a7990
pr feedback comments
aswanidutt 373766d
pr comments update
aswanidutt 211504d
trying to minimize the test case changes wrt formatting
aswanidutt 08a2416
format cleanup
aswanidutt e9f7ae7
adding local variable for seconds convert
aswanidutt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,15 +20,18 @@ func init() { | |
|
|
||
| func TestVaultRenewDuration(t *testing.T) { | ||
| renewable := Secret{LeaseDuration: 100, Renewable: true} | ||
| renewableDur := leaseCheckWait(&renewable).Seconds() | ||
| if renewableDur < 16 || renewableDur >= 34 { | ||
| t.Fatalf("renewable duration is not within 1/6 to 1/3 of lease duration: %f", renewableDur) | ||
| renewableDur, _ := leaseCheckWait(&renewable) | ||
|
Member
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. It's probably still a good idea to check the value of |
||
| renewableDurSec := renewableDur.Seconds() | ||
| if renewableDurSec < 16 || renewableDurSec >= 34 { | ||
| t.Fatalf("renewable duration is not within 1/6 to 1/3 of lease duration: %f", renewableDurSec) | ||
| } | ||
|
|
||
| nonRenewable := Secret{LeaseDuration: 100} | ||
| nonRenewableDur := leaseCheckWait(&nonRenewable).Seconds() | ||
| if nonRenewableDur < 80 || nonRenewableDur > 95 { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableDur) | ||
| nonRenewableDur, _ := leaseCheckWait(&nonRenewable) | ||
| nonRenewableDurSec := nonRenewableDur.Seconds() | ||
|
|
||
| if nonRenewableDurSec < 80 || nonRenewableDurSec > 95 { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableDurSec) | ||
| } | ||
|
|
||
| data := map[string]interface{}{ | ||
|
|
@@ -37,11 +40,11 @@ func TestVaultRenewDuration(t *testing.T) { | |
| } | ||
|
|
||
| nonRenewableRotated := Secret{LeaseDuration: 100, Data: data} | ||
| nonRenewableRotatedDur := leaseCheckWait(&nonRenewableRotated).Seconds() | ||
|
|
||
| nonRenewableRotatedDur, _ := leaseCheckWait(&nonRenewableRotated) | ||
| nonRenewableRotatedDurSec := nonRenewableRotatedDur.Seconds() | ||
| // We expect a 1 second cushion | ||
| if nonRenewableRotatedDur != 31 { | ||
| t.Fatalf("renewable duration is not 31: %f", nonRenewableRotatedDur) | ||
| if nonRenewableRotatedDurSec != 31 { | ||
| t.Fatalf("renewable duration is not 31: %f", nonRenewableRotatedDurSec) | ||
| } | ||
|
|
||
| data = map[string]interface{}{ | ||
|
|
@@ -50,11 +53,24 @@ func TestVaultRenewDuration(t *testing.T) { | |
| } | ||
|
|
||
| nonRenewableRotated = Secret{LeaseDuration: 100, Data: data} | ||
| nonRenewableRotatedDur = leaseCheckWait(&nonRenewableRotated).Seconds() | ||
|
|
||
| nonRenewableRotatedDur, _ = leaseCheckWait(&nonRenewableRotated) | ||
| nonRenewableRotatedDurSeconds := nonRenewableRotatedDur.Seconds() | ||
| // We expect a 1 second cushion | ||
| if nonRenewableRotatedDur != 6 { | ||
| t.Fatalf("renewable duration is not 6: %f", nonRenewableRotatedDur) | ||
| if nonRenewableRotatedDurSeconds != 6 { | ||
| t.Fatalf("renewable duration is not 6: %f", nonRenewableRotatedDurSeconds) | ||
| } | ||
| // Test TTL=0 case - should return error | ||
| data = map[string]interface{}{ | ||
| "rotation_period": json.Number("30"), | ||
| "ttl": json.Number("0"), | ||
| } | ||
| nonRenewableRotatedZero := Secret{LeaseDuration: 100, Data: data} | ||
| _, err := leaseCheckWait(&nonRenewableRotatedZero) | ||
| if err == nil { | ||
| t.Fatalf("expected error for ttl=0, got nil") | ||
| } | ||
| if err.Error() != "vault rotating secret returned ttl=0, will retry" { | ||
| t.Fatalf("expected ttl=0 error message, got: %v", err) | ||
| } | ||
|
|
||
| rawExpiration := time.Now().Unix() + 100 | ||
|
|
@@ -66,9 +82,11 @@ func TestVaultRenewDuration(t *testing.T) { | |
| } | ||
|
|
||
| nonRenewableCert := Secret{LeaseDuration: 100, Data: data} | ||
| nonRenewableCertDur := leaseCheckWait(&nonRenewableCert).Seconds() | ||
| if nonRenewableCertDur < 80 || nonRenewableCertDur > 95 { | ||
| t.Fatalf("non renewable certificate duration is not within 80%% to 95%%: %f", nonRenewableCertDur) | ||
| nonRenewableCertDur, _ := leaseCheckWait(&nonRenewableCert) | ||
| nonRenewableCertDurSec := nonRenewableCertDur.Seconds() | ||
|
|
||
| if nonRenewableCertDurSec < 80 || nonRenewableCertDurSec > 95 { | ||
| t.Fatalf("non renewable certificate duration is not within 80%% to 95%%: %f", nonRenewableCertDurSec) | ||
| } | ||
|
|
||
| t.Run("secret ID handling", func(t *testing.T) { | ||
|
|
@@ -80,10 +98,11 @@ func TestVaultRenewDuration(t *testing.T) { | |
| } | ||
|
|
||
| nonRenewableSecretID := Secret{LeaseDuration: 100, Data: data} | ||
| nonRenewableSecretIDDur := leaseCheckWait(&nonRenewableSecretID).Seconds() | ||
| nonRenewableSecretIDDur, _ := leaseCheckWait(&nonRenewableSecretID) | ||
| nonRenewableSecretIDDurSec := nonRenewableSecretIDDur.Seconds() | ||
|
|
||
| if nonRenewableSecretIDDur < 0.80*(60+1) || nonRenewableSecretIDDur > 0.95*(60+1) { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDur) | ||
| if nonRenewableSecretIDDurSec < 0.80*(60+1) || nonRenewableSecretIDDurSec > 0.95*(60+1) { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDurSec) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -96,10 +115,11 @@ func TestVaultRenewDuration(t *testing.T) { | |
| } | ||
|
|
||
| nonRenewableSecretID := Secret{LeaseDuration: leaseDuration, Data: data} | ||
| nonRenewableSecretIDDur := leaseCheckWait(&nonRenewableSecretID).Seconds() | ||
| nonRenewableSecretIDDur, _ := leaseCheckWait(&nonRenewableSecretID) | ||
| nonRenewableSecretIDDurSec := nonRenewableSecretIDDur.Seconds() | ||
|
|
||
| if nonRenewableSecretIDDur < 0.80*(leaseDuration+1) || nonRenewableSecretIDDur > 0.95*(leaseDuration+1) { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDur) | ||
| if nonRenewableSecretIDDurSec < 0.80*(leaseDuration+1) || nonRenewableSecretIDDurSec > 0.95*(leaseDuration+1) { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDurSec) | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -111,10 +131,11 @@ func TestVaultRenewDuration(t *testing.T) { | |
| } | ||
|
|
||
| nonRenewableSecretID := Secret{LeaseDuration: leaseDuration, Data: data} | ||
| nonRenewableSecretIDDur := leaseCheckWait(&nonRenewableSecretID).Seconds() | ||
| nonRenewableSecretIDDur, _ := leaseCheckWait(&nonRenewableSecretID) | ||
| nonRenewableSecretIDDurSec := nonRenewableSecretIDDur.Seconds() | ||
|
|
||
| if nonRenewableSecretIDDur < 0.80*(leaseDuration+1) || nonRenewableSecretIDDur > 0.95*(leaseDuration+1) { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDur) | ||
| if nonRenewableSecretIDDurSec < 0.80*(leaseDuration+1) || nonRenewableSecretIDDurSec > 0.95*(leaseDuration+1) { | ||
| t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDurSec) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm curious why the
.Seconds()was dropped here? That seems to have forced a lot of changes unrelated to the goal of this PR that I'm not sure are necessary?At this point I'd say either set this back to .Seconds(), or apply the suggestions I made to the rest of TestVaultRenewDuration():
Uh oh!
There was an error while loading. Please reload this page.
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.
.Seconds() dropped because now the leaseCheckWait is returning multiple values not just
durationbut alsoerror. updated with your suggestions to the rest of TestVaultRenewDuration():