fix: Make Vault sleeps cancelable to prevent leaked goroutines#2148
Open
skoppe wants to merge 1 commit intohashicorp:mainfrom
Open
fix: Make Vault sleeps cancelable to prevent leaked goroutines#2148skoppe wants to merge 1 commit intohashicorp:mainfrom
skoppe wants to merge 1 commit intohashicorp:mainfrom
Conversation
We had our Vault Agents DDoS our Vault cluster due to accumulated leaked goroutines that all waked up at the same time (thousands of them). The agents in question where missing access to a particular secret they were requesting. This meant they restarted the consul template runner after 12 tries (approximately every 5 min). Over the period of 27 days we saw a slow buildup of goroutines which then _all_ suddenly woke up. Initially we suspected authentication renewal (our agent token is 30 days), but that was ruled out. Eventually we found out the `vault_pki` file has a goroutine which sleeps for 90% of a PKI's cert expiry - which is our case was 30 days - and thus slept for 27 days. Critically, on an consul template runner restart these goroutines don't respond to the stop channel, but instead continue sleeping until 90% of the cert is expired. This PR makes the sleep paths in Vault dependencies cancelable so goroutines exit promptly when a runner is stopped.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We had our Vault Agents DDoS our Vault cluster due to accumulated leaked goroutines that all woke up at the same time (thousands of them).
The agents in question were missing access to a particular secret they were requesting. This meant they restarted the consul template runner after 12 tries (approximately every 5 min).
Over the period of 27 days we saw a slow buildup of goroutines which then all suddenly woke up. Initially we suspected authentication renewal (our agent token is 30 days), but that was ruled out.
Eventually we found out the
vault_pkifile has a goroutine which sleeps until 90% of a PKI's cert expiry - which in our case is 30 days - and thus slept until 27 days after cert issuance. Critically, on an consul template runner restart these goroutines don't respond to the stop channel, but instead continue sleeping until 90% of the cert is expired.This PR makes the sleep paths in Vault dependencies cancelable so goroutines exit promptly when a runner is stopped.