Skip to content

introduce jitter to secret rotation grace ratio to smooth resource consumption #52102

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
merged 4 commits into from
Jul 18, 2024

Conversation

tkellen
Copy link
Contributor

@tkellen tkellen commented Jul 17, 2024

When running large fleets of pods deployed at the same time, the lack of jitter in mTLS workload certificate renewal can result in unnecessarily spike-y resource consumption (e.g. 100s of proxies renewing simultaneously). This PR is a quick and dirty suggested resolution for discussion. If something like this would be considered for inclusion I will happily write tests and modify documentation where needed. Your thoughts requested!

  • Ambient
  • Configuration Infrastructure
  • Docs
  • Dual Stack
  • Installation
  • Networking
  • Performance and Scalability
  • Extensions and Telemetry
  • Security
  • Test and Release
  • User Experience
  • Developer Infrastructure
  • Upgrade
  • Multi Cluster
  • Virtual Machine
  • Control Plane Revisions

@istio-policy-bot
Copy link

😊 Welcome @tkellen! This is either your first contribution to the Istio istio repo, or it's been
a while since you've been here.

You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 17, 2024
@istio-testing
Copy link
Collaborator

Hi @tkellen. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@howardjohn
Copy link
Member

Overall idea looks good I think

Copy link
Contributor

@keithmattix keithmattix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I'm also +1 to this idea pending @howardjohn's comments and some tests

@istio-testing istio-testing added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 18, 2024
@tkellen tkellen force-pushed the jitter-grace-ratio branch from 6aaf620 to 6e45601 Compare July 18, 2024 06:54
@tkellen
Copy link
Contributor Author

tkellen commented Jul 18, 2024

Thanks ya'll! Updated per your comments and added some tests.

@hanxiaop
Copy link
Member

/ok-to-test

@istio-testing istio-testing added ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. and removed needs-ok-to-test labels Jul 18, 2024
var rotateTime = func(secret security.SecretItem, graceRatio float64) time.Duration {
var rotateTime = func(secret security.SecretItem, graceRatio float64, graceRatioJitter float64) time.Duration {
// stagger rotation times to prevent large fleets of clients from renewing at the same moment.
jitter := (rand.Float64() * graceRatioJitter) * float64(rand.IntN(3)-1)
Copy link
Contributor Author

@tkellen tkellen Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter isn't happy about math/rand/v2. What do ya'll think? Do we care about using crypo/rand for this purpose? I can update if so, or just put // # nosec G402 - cyrpto/rand is not worth the cost here on this line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just opting out here is fine

@tkellen tkellen force-pushed the jitter-grace-ratio branch from 9b960d4 to ab046da Compare July 18, 2024 10:41
var rotateTime = func(secret security.SecretItem, graceRatio float64) time.Duration {
var rotateTime = func(secret security.SecretItem, graceRatio float64, graceRatioJitter float64) time.Duration {
// stagger rotation times to prevent large fleets of clients from renewing at the same moment.
jitter := (rand.Float64() * graceRatioJitter) * float64(rand.IntN(3)-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just opting out here is fine

@tkellen tkellen force-pushed the jitter-grace-ratio branch from ab046da to 1bf49e0 Compare July 18, 2024 22:40
@istio-testing istio-testing merged commit e023232 into istio:master Jul 18, 2024
27 checks passed
@tkellen tkellen deleted the jitter-grace-ratio branch July 18, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/perf and scalability area/security ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants