-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Rework agent retry config, extend it to cover proxy cache as well #11113
Conversation
…ch only has num_retries field; if num_retries is 0 or absent, default it to 12 for backwards compat. Configured retries are used for both templating and api proxy, though if template requests go through proxy (currently requires persistence enabled) we'll only configure retries for the latter to avoid duplicate retrying. Though there is some duplicate retrying already because whenever the template server does a retry when not going through the proxy, the Vault client it uses allows for two behind-the-scenes retries for some 400/500 http error codes. Missing: tests for proxy retries; tests for retries with persistent cache.
…ose startedCh instead of writing non-deterministically to it.
…efault NumRetries.
@@ -193,8 +188,19 @@ func LoadConfig(path string) (*Config, error) { | |||
return nil, errwrap.Wrapf("error parsing 'vault':{{err}}", err) | |||
} | |||
|
|||
if err := parseRetry(result, list); err != nil { | |||
return nil, errwrap.Wrapf("error parsing 'retry': {{err}}", err) | |||
if result.Vault == nil { |
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.
Can this ever be nil if we're always assigning it within parseVault
(L236, result.Vault = &v
)?
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.
It can be nil if there's no vault{}
stanza.
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.
Ah, I see. We could perform the assignment first within that func (similar to what we do in here), but I'll leave that up to you.
if result.Vault.Retry == nil { | ||
result.Vault.Retry = &Retry{} | ||
} | ||
switch result.Vault.Retry.NumRetries { | ||
case 0: | ||
result.Vault.Retry.NumRetries = ctconfig.DefaultRetryAttempts | ||
case -1: | ||
result.Vault.Retry.NumRetries = 0 |
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.
Can we move this logic into parseRetry
?
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 had it there initially, I just moved it out in the most recent commits so that we could have a consistent default behaviour even when there's no vault{}
or no vault.retry{}
stanza.
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.
That's fair. I was trying to think if we could keep the assignment/modification of result.Vault.Retry
within its parseRetry
func.
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.
Looking good! Left a few additional minor comments.
// is enabled. The templating engine and the cache have some inconsistencies | ||
// that need to be fixed for 1.7x/1.8 |
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.
Can you expand on the specific inconsitencies (backoff behavior, and perhaps turn the comment into a // TODO:
?
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 don't know what they are, I'm just citing a slack convo with Jason. I just put this comment in here because I was surprised that persistence was related to template use of cache, and decided to put his reply in here for the sake of others who might be similarly confused.
Co-authored-by: Calvin Leung Huang <[email protected]>
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.
Can you add a CL entry for this change, and maybe backlink/mention the PR that the added template_retry
in this PR's description?
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.
LGTM and tested great with persistent caching.
Will do |
…1113) Remove template_retry config section. Add new vault.retry section which only has num_retries field; if num_retries is 0 or absent, default it to 12 for backwards compat with pre-1.7 template retrying. Setting num_retries=-1 disables retries. Configured retries are used for both templating and api proxy, though if template requests go through proxy (currently requires persistence enabled) we'll only configure retries for the latter to avoid duplicate retrying. Though there is some duplicate retrying already because whenever the template server does a retry when not going through the proxy, the Vault client it uses allows for 2 behind-the-scenes retries for some 400/500 http error codes.
…1113) (#11136) Remove template_retry config section. Add new vault.retry section which only has num_retries field; if num_retries is 0 or absent, default it to 12 for backwards compat with pre-1.7 template retrying. Setting num_retries=-1 disables retries. Configured retries are used for both templating and api proxy, though if template requests go through proxy (currently requires persistence enabled) we'll only configure retries for the latter to avoid duplicate retrying. Though there is some duplicate retrying already because whenever the template server does a retry when not going through the proxy, the Vault client it uses allows for 2 behind-the-scenes retries for some 400/500 http error codes.
A side-effect from this PR that I noticed while working on #11711 is that moving template retry to be performed by the cache's client doesn't always behave the same as the internal retry via
vs
|
Remove template_retry config section. Add new vault.retry section which only has num_retries field; if num_retries is 0 or absent, default it to 12 for backwards compat.
Configured retries are used for both templating and api proxy, though if template requests go through proxy (currently requires persistence enabled) we'll only configure retries for the latter to avoid duplicate retrying. Though there is some duplicate retrying already because whenever the template server does a retry when not going through the proxy, the Vault client it uses allows for two behind-the-scenes retries for some 400/500 http error codes.