From 3b74c011eec7717ef446459efa20a726dc844d21 Mon Sep 17 00:00:00 2001 From: Niraj Yadav Date: Wed, 27 Nov 2024 15:59:43 +0530 Subject: [PATCH] cephfs: use userid and keys for provisioning This patch modifies the code to use userID and userKey for provisioning of both static and dynamic PVs. In case user credentials are not found admin credentials are used as a fallback and for backwards compatibility. Signed-off-by: Niraj Yadav --- e2e/cephfs_helper.go | 8 ++++---- internal/util/credentials.go | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/e2e/cephfs_helper.go b/e2e/cephfs_helper.go index 6deb976d10a..077e4d67ceb 100644 --- a/e2e/cephfs_helper.go +++ b/e2e/cephfs_helper.go @@ -127,10 +127,10 @@ func createCephfsSecret(f *framework.Framework, secretName, userName, userKey st if secretName != "" { sc.Name = secretName } - sc.StringData["adminID"] = userName - sc.StringData["adminKey"] = userKey - delete(sc.StringData, "userID") - delete(sc.StringData, "userKey") + sc.StringData["userID"] = userName + sc.StringData["userKey"] = userKey + delete(sc.StringData, "adminID") + delete(sc.StringData, "adminKey") sc.Namespace = cephCSINamespace _, err = f.ClientSet.CoreV1().Secrets(cephCSINamespace).Create(context.TODO(), &sc, metav1.CreateOptions{}) diff --git a/internal/util/credentials.go b/internal/util/credentials.go index fae403c2347..db613ba3054 100644 --- a/internal/util/credentials.go +++ b/internal/util/credentials.go @@ -110,6 +110,11 @@ func NewUserCredentials(secrets map[string]string) (*Credentials, error) { // NewAdminCredentials creates new admin credentials from secret. func NewAdminCredentials(secrets map[string]string) (*Credentials, error) { + // Use userID and userKey if found else fallback to adminID and adminKey + if cred, err := newCredentialsFromSecret(credUserID, credUserKey, secrets); err == nil { + return cred, nil + } + return newCredentialsFromSecret(credAdminID, credAdminKey, secrets) }