fix: prevent refreshAliasesTask from reverting rotated aliases in aws_kms plugin - #6805
Merged
amartinezfayo merged 4 commits intoApr 27, 2026
Merged
Conversation
…_kms plugin Signed-off-by: angabini <494150+angabini@users.noreply.github.com>
amartinezfayo
left a comment
Member
There was a problem hiding this comment.
Thank you @angabini for this contribution!
| require.Equal(t, "key_id_rotated", *aliasAfter.KeyEntry.KeyID, "alias should not have been reverted to the stale cached key") | ||
| } | ||
|
|
||
| func TestRefreshAliasesDescribeKeyError(t *testing.T) { |
Member
There was a problem hiding this comment.
Maybe we could also add a test for the malformed response branch (where DescribeKey succeeds but returns nil KeyMetadata or nil Arn)?
angabini
requested review from
MarcosDY,
evan2645,
rturner3 and
sorindumitru
as code owners
April 22, 2026 16:37
angabini
added a commit
to angabini/spire
that referenced
this pull request
Apr 22, 2026
Address review feedback on spiffe#6805: the malformed-response branch in refreshAliases now appends to errs so the periodic task surfaces the problem, matching the DescribeKey error path. Adds a unit test that covers the new branch using a new fake-client knob. Signed-off-by: angabini <494150+angabini@users.noreply.github.com> Made-with: Cursor
Address review feedback on spiffe#6805: the malformed-response branch in refreshAliases now appends to errs so the periodic task surfaces the problem, matching the DescribeKey error path. Adds a unit test that covers the new branch using a new fake-client knob. Signed-off-by: angabini <494150+angabini@users.noreply.github.com>
angabini
force-pushed
the
fix-aws-kms-refresh-alias-race
branch
from
April 22, 2026 22:54
6f1991d to
2916541
Compare
amartinezfayo
approved these changes
Apr 27, 2026
amartinezfayo
left a comment
Member
There was a problem hiding this comment.
Thank you @angabini for this contribution!
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.
Pull Request check list
Affected functionality
aws_kmsKeyManager plugin — specifically therefreshAliasesTaskbackground task that periodically refreshes alias timestamps.Description of change
In multi-replica SPIRE server deployments sharing a
key_identifier_value,refreshAliasesTaskon non-leader replicas can revert a KMS alias to a stale cached key after the leader rotates it. If the old key is subsequently scheduled for deletion, the alias ends up pointing to a disabled key, causing all future server startups to crash withFailedPrecondition.This PR adds a
DescribeKeycheck inrefreshAliases()before callingUpdateAlias. If the alias's current target differs from the local cache (indicating a rotation by another replica), the refresh is skipped to avoid reverting the rotation.Which issue this PR fixes
fixes #6804