-
Notifications
You must be signed in to change notification settings - Fork 2k
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
keyring: warn if removing a key that was used for encrypting variables #24766
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for doing this @pkazmierczak!
I tested this locally and couldn't get a delete to work even when using the force flag. I believe we need to populate the RPC request force parameter from the HTTP request here in order for the HTTP->RPC translation to handle this new parameter.
It would also be good if we could address the following items:
- The CLI help output doesn't include the new flag option.
- It would be nice to have API and CLI tests to cover this addition as the RPC test did not catch the issue detailed above.
- Document the API and CLI changes.
.changelog/24766.txt
Outdated
@@ -0,0 +1,3 @@ | |||
```release-note:improvement | |||
keyring: Warn if deleting a key previously used to encrypt a variable |
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 it worth expanding on this to note the variable should still exist? It immediately reads to me that the warning applies to any key used in the past.
return wm, err | ||
} | ||
|
||
// KeyringDeleteOptions are parameters for the Delete API | ||
type KeyringDeleteOptions struct { | ||
KeyID string // UUID | ||
Force bool |
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 know not many options have this, but could we add a comment to this explaining what the force boolean does? It means external tool developers have an easy time knowing and understanding.
nomad/keyring_endpoint.go
Outdated
return err | ||
} | ||
if rootKeyInUse && !args.Force { | ||
return fmt.Errorf("root key in use, cannot delete") |
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.
There is no formatting, so we could use the below (the suggestion won't compile as the file also needs the new import):
return fmt.Errorf("root key in use, cannot delete") | |
return errors.New("root key in use, cannot delete") |
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.
yeah force of habit I guess, but errors.New
is a better choice here
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.
Thanks for updating the docs!
@jrasell I addressed all your comments, thanks for the thorough review. |
This PR adds an additional check in the
Keyring.Delete
RPC to make sure we're not trying to delete a key that's been used to encrypt a variable. It also adds a-force
flag for the CLI/API to sidestep that check.Resolves #24591
Internal ref: https://hashicorp.atlassian.net/browse/NET-11829