-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Log DB Rotations #31402
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
Log DB Rotations #31402
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
CI Results: |
Build Results: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we see the before and after log snippets for the relevant plugins?
return b.rotateRootCredentials(ctx, req, name) | ||
resp, err = b.rotateRootCredentials(ctx, req, name) | ||
if err != nil { | ||
b.Logger().Error("failed to rotate root credential", "path", req.Path, "err", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be consistent and either use err
or error
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i decided to use "err" since it's generally more common for use to use it, particularly in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per discussion, i updated this to error.
@@ -236,7 +242,7 @@ func (b *databaseBackend) pathRotateRoleCredentialsUpdate() framework.OperationF | |||
// this item back on the queue. The err should still be returned at the end | |||
// of this method. | |||
if err != nil { | |||
b.logger.Warn("unable to rotate credentials in rotate-role", "error", err) | |||
b.logger.Error("unable to rotate credentials in rotate-role", "rotationID", name, "error", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is name
actually the rotationID? Should we use req.RotationID
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i was torn about using rotationID, since I don't think we actually have a rotationID if the request didn't come from the rotation manager.
I used rotationID here because the values will end up being the same or similar since they come from the same place, but it might be more accurate to use "path" or "name" instead, with the understanding that the log will become "rotationID" when the logging comes from the rotation manager in the future.
item.Priority = role.StaticAccount.NextRotationTimeFromInput(resp.RotationTime).Unix() | ||
nextRotationTime := role.StaticAccount.NextRotationTimeFromInput(resp.RotationTime).Unix() | ||
ttl := nextRotationTime - time.Now().Unix() | ||
b.Logger().Info("rotated credential in rotate-role", "rotationID", name, "TTL", ttl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is name
actually the rotationID? Should we use req.RotationID
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i was torn about using rotationID, since I don't think we actually have a rotationID if the request didn't come from the rotation manager.
I used rotationID here because the values will end up being the same or similar since they come from the same place, but it might be more accurate to use "path" or "name" instead, with the understanding that the log will become "rotationID" when the logging comes from the rotation manager in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've swapped this text to "path" when we have access to that, "name" otherwise
Switching the "err" statement to just use the string, i.e., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the log snippets! Could we see some for auto-rotations on root creds? Ideally, including all rotation manager logs too. |
Sure, enterprise rotations (i.e., rotation manager rotations) are at https://github.com/hashicorp/vault-enterprise/pull/8412, but here's an example log (using my testing plugin):
or in a failure
|
Thanks! I think that confirms that rotationID and req.Path can't be used interchangeably in all situations. LGTM |
Small update to log DB credential rotations at the caller level with a general Error/Info on failure/success.
Here's some sample logs for
Manually triggered root rotation:
failure:
Manually triggered static rotation:
failure:
Static role periodic rotation:
(success)
(failure)