Skip to content

Commit

Permalink
cephfs: use userid and keys for provisioning
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
black-dragon74 committed Nov 27, 2024
1 parent 630c97a commit 3b74c01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions e2e/cephfs_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})

Expand Down
5 changes: 5 additions & 0 deletions internal/util/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 3b74c01

Please sign in to comment.