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

ceph: do not fail on keys deletion #8868

Merged
merged 1 commit into from Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/daemon/ceph/osd/kms/vault.go
Expand Up @@ -183,7 +183,7 @@ func buildKeyContext(config map[string]string) map[string]string {
keyContext := map[string]string{secrets.KeyVaultNamespace: config[api.EnvVaultNamespace]}
vaultNamespace, ok := config[api.EnvVaultNamespace]
if !ok || vaultNamespace == "" {
keyContext = nil
keyContext = map[string]string{}
}

return keyContext
Expand Down
24 changes: 24 additions & 0 deletions pkg/daemon/ceph/osd/kms/vault_test.go
Expand Up @@ -157,3 +157,27 @@ func Test_configTLS(t *testing.T) {
assert.NotEqual(t, "vault-client-cert", config["VAULT_CLIENT_CERT"])
assert.NotEqual(t, "vault-client-key", config["VAULT_CLIENT_KEY"])
}

func Test_buildKeyContext(t *testing.T) {
t.Run("no vault namespace, return empty map and assignment is possible", func(t *testing.T) {
config := map[string]string{
"KMS_PROVIDER": "vault",
"VAULT_ADDR": "1.1.1.1",
}
context := buildKeyContext(config)
assert.Len(t, context, 0)
context["foo"] = "bar"
})

t.Run("vault namespace, return 1 single element in the map and assignment is possible", func(t *testing.T) {
config := map[string]string{
"KMS_PROVIDER": "vault",
"VAULT_ADDR": "1.1.1.1",
"VAULT_NAMESPACE": "vault-namespace",
}
context := buildKeyContext(config)
assert.Len(t, context, 1)
context["foo"] = "bar"
assert.Len(t, context, 2)
})
}