Skip to content

fix(database): use LastVaultRotation as reference for schedule-based TTL calculation#31937

Open
wucm667 wants to merge 1 commit into
hashicorp:mainfrom
wucm667:fix/vault-static-creds-ttl-mismatch
Open

fix(database): use LastVaultRotation as reference for schedule-based TTL calculation#31937
wucm667 wants to merge 1 commit into
hashicorp:mainfrom
wucm667:fix/vault-static-creds-ttl-mismatch

Conversation

@wucm667

@wucm667 wucm667 commented May 1, 2026

Copy link
Copy Markdown

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 uses time.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 use s.LastVaultRotation as the reference point instead of time.Now(). This ensures the TTL accurately reflects the time remaining until the next rotation after the last actual password change.

Related Issue

Fixes #31918

…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 wucm667 requested a review from a team as a code owner May 1, 2026 02:04
@vercel

vercel Bot commented May 1, 2026

Copy link
Copy Markdown

@wucm667 is attempting to deploy a commit to the HashiCorp Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. secret/database labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

secret/database size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static DB creds: TTL resets before password rotation when using rotation_schedule (SQL Server)

1 participant