From 8c8f34cf7a98527ef6fb9324f1da7b0cf50a3445 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 --- internal/kms/vault.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/kms/vault.go b/internal/kms/vault.go index 6a7fc001c..d1e146538 100644 --- a/internal/kms/vault.go +++ b/internal/kms/vault.go @@ -192,11 +192,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