fix(database): use LastVaultRotation as reference for schedule-based TTL calculation#31937
Open
wucm667 wants to merge 1 commit into
Open
fix(database): use LastVaultRotation as reference for schedule-based TTL calculation#31937wucm667 wants to merge 1 commit into
wucm667 wants to merge 1 commit into
Conversation
…TTL calculation When using database static roles with a cron-based rotation_schedule, the TTL endpoint returns a refreshed TTL at the cron boundary even though the password has not been rotated yet. This is because NextRotationTime() uses time.Now() as the reference point for calculating the next schedule occurrence, causing the TTL to jump back to the full interval at each cron boundary regardless of whether rotation actually occurred. Fix: use s.LastVaultRotation as the reference point so the TTL accurately reflects the time remaining until the next rotation after the last actual password change. Fixes hashicorp#31918 Signed-off-by: wucm667 <stevenwucongmin@gmail.com>
|
@wucm667 is attempting to deploy a commit to the HashiCorp Team on Vercel. A member of the Team first needs to authorize it. |
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.
Description
When using database static roles with a cron-based
rotation_schedule, the/database/static-creds/<role>endpoint returns a refreshed TTL at each cron boundary even though the password has not actually been rotated yet. This creates an inconsistent state where the TTL resets but the password remains the same.Root Cause
In
NextRotationTime(), the schedule-based rotation branch usestime.Now()as the reference point for calculating the next cron occurrence. This means the TTL jumps back to the full interval at every cron boundary, regardless of whether the password was actually rotated.Fix
Changed
NextRotationTime()to uses.LastVaultRotationas the reference point instead oftime.Now(). This ensures the TTL accurately reflects the time remaining until the next rotation after the last actual password change.Related Issue
Fixes #31918