Skip to content
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

refactor keyring state store methods #23943

Merged
merged 1 commit into from
Sep 12, 2024
Merged

refactor keyring state store methods #23943

merged 1 commit into from
Sep 12, 2024

Conversation

tgross
Copy link
Member

@tgross tgross commented Sep 11, 2024

For #23665 I'm about to make add a lot more code to the state store for the keyring, so I'd like to pull these out to their own file. Also updates the test to use shoenig/test and changes the name of one method to be a little more accurate.

Note for reviewers:

  • I'm backporting this to 1.8.x because it's the LTS but not further than that because with KMS support in 1.8.x the code has changed quite a bit from 1.6.x and 1.7.x.
  • I'd also like to refactor nomad/encrypter.go into its own package but right now that's got a lot of dependencies on server RPC code because of keyring replication and server lifecycle. So I'm punting on that here. Once I've got Store keyring in Raft #23665 ready to ship, I might revisit that decision but I don't want to push up a refactoring PR only to have to push up another one unwinding half of it once I'm done.

For #23665 I'm about to make add a lot more code to the state store for the
keyring, so I'd like to pull these out to their own file. Also updates the test
to use `shoenig/test` and changes the name of one method to be a little more
accurate.
Copy link
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -0,0 +1,196 @@
// Copyright (c) HashiCorp, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bless your heart for moving this to a separate file 🙇‍♂️

key = key.MakeInactive()
}
modified = true
case structs.RootKeyStateRekeying, structs.RootKeyStateDeprecated:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to explicitly case this? why not just skip this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It absolutely could be default: but when you've got a small enum like this I feel like it helps understandability to explicitly list them. If you add a state later it's more obvious that it's missing, rather than simply falling thru the default case and doing nothing.

@tgross tgross merged commit 650e783 into main Sep 12, 2024
19 checks passed
@tgross tgross deleted the keyring-refactor branch September 12, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.8.x backport to 1.8.x release line theme/keyring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants