-
Notifications
You must be signed in to change notification settings - Fork 265
CNTRLPLANE-3237: Introduce kms to kms migration #2192
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||
| "strconv" | ||||||||||||||||||||||||||||||||||||||||||||||||
| "strings" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| configv1 "github.com/openshift/api/config/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/openshift/api/features" | ||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/openshift/library-go/pkg/operator/configobserver/featuregates" | ||||||||||||||||||||||||||||||||||||||||||||||||
| corev1 "k8s.io/api/core/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -34,6 +35,27 @@ func KeyIDFromProviderConfigSecretDataKey(dataKey string) (string, bool, error) | |||||||||||||||||||||||||||||||||||||||||||||||
| return keyID, true, nil | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // NeedsNewKey returns true if the KMS provider configuration has changed | ||||||||||||||||||||||||||||||||||||||||||||||||
| // in a way that requires creating a new encryption key and migrating storage. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Only fields that affect the Key Encryption Key (KEK) trigger migration. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Fields like KMSPluginImage, TLS, and Authentication are non-migration fields. | ||||||||||||||||||||||||||||||||||||||||||||||||
| func NeedsNewKey(latest, current *configv1.KMSConfig) bool { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this could be internal to the key_controller. won't be used by the preflight-checker.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. So NeedsNewKey will return true, key_controller interacts with pre-flight checker.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we missing a nil check for both params? |
||||||||||||||||||||||||||||||||||||||||||||||||
| if latest.Type != current.Type { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO: Integrate this with pre-flight checker | ||||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| if latest.Type == configv1.VaultKMSProvider { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if latest.Vault.VaultAddress != current.Vault.VaultAddress || | ||||||||||||||||||||||||||||||||||||||||||||||||
| latest.Vault.VaultNamespace != current.Vault.VaultNamespace || | ||||||||||||||||||||||||||||||||||||||||||||||||
| latest.Vault.TransitMount != current.Vault.TransitMount || | ||||||||||||||||||||||||||||||||||||||||||||||||
| latest.Vault.TransitKey != current.Vault.TransitKey { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add nil-safety to At Line 17, Suggested fix func NeedsNewKey(latest, current *configv1.KMSConfig) bool {
+ if latest == nil || current == nil {
+ return latest != current
+ }
if latest.Type != current.Type {
// TODO: Integrate this with pre-flight checker
return true
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KMSConfig can not be nil if encryption mode is KMS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO: Integrate this with pre-flight checker | ||||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // AddKMSPluginVolumeAndMountToPodSpec conditionally adds the KMS plugin volume mount to the specified container. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // It assumes the pod spec does not already contain the KMS volume or mount; no deduplication is performed. | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Deprecated: this is a temporary solution to get KMS TP v1 out. We should come up with a different approach afterwards. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
how could we e2e test this change ? :)
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.
We'll update kms plugin deployment in library-go with the fake Vault kms plugin. We'll have actual Vault kms plugin coming from stepregistry. We'll move from one to another :)
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.
ah, there is simpler way: We have already run multiple kms plugins (km-1.sock, kms-2.sock, etc.). We'll just migrate from one to another.