From c8f8272d77c46b22516bbc372a39d0b70f0c98ea Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 8 Sep 2021 13:28:30 +0530 Subject: [PATCH] rbd: set vaultAuthNamespace to vaultNamespace if empty When we read the csi-kms-connection-details configmap vaultAuthNamespace might not be set when we do the conversion the vaultAuthNamespace might be set to empty key and this commits check for the empty value of vaultAuthNamespace and set the vaultAuthNamespace to vaultNamespace. setting empty value for vaultAuthNamespace happened due to Marshalling at https://github.com/ceph/ceph-csi/blob/devel/ internal/kms/vault_tokens.go#L136-L139. Signed-off-by: Madhu Rajanna (cherry picked from commit 8c8f34cf7a98527ef6fb9324f1da7b0cf50a3445) --- internal/util/vault.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/util/vault.go b/internal/util/vault.go index 79e377650..0ed50245c 100644 --- a/internal/util/vault.go +++ b/internal/util/vault.go @@ -168,11 +168,16 @@ func (vc *vaultConnection) initConnection(config map[string]interface{}) error { if errors.Is(err, errConfigOptionInvalid) { return err } - vaultAuthNamespace := vaultNamespace // optional, same as vaultNamespace + vaultAuthNamespace := "" err = setConfigString(&vaultAuthNamespace, config, "vaultAuthNamespace") if errors.Is(err, errConfigOptionInvalid) { return err } + // if the vaultAuthNamespace key is present and value is empty in config, set + // the optional vaultNamespace. + if vaultAuthNamespace == "" { + vaultAuthNamespace = vaultNamespace + } // set the option if the value was not invalid if firstInit || !errors.Is(err, errConfigOptionMissing) { vaultConfig[api.EnvVaultNamespace] = vaultAuthNamespace