mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-26 16:20:28 +00:00
cephfs: pass volume UUIDs where needed
This commit is contained in:
parent
f45ddd7c9d
commit
2fcc252f5c
@ -82,6 +82,7 @@ func storeCephUserCredentials(volUuid string, cr *credentials, volOptions *volum
|
|||||||
UserId: cr.id,
|
UserId: cr.id,
|
||||||
Key: cr.key,
|
Key: cr.key,
|
||||||
RootPath: volOptions.RootPath,
|
RootPath: volOptions.RootPath,
|
||||||
|
VolumeUuid: volUuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if volOptions.ProvisionVolume {
|
if volOptions.ProvisionVolume {
|
||||||
@ -89,14 +90,14 @@ func storeCephUserCredentials(volUuid string, cr *credentials, volOptions *volum
|
|||||||
keyringData.Namespace = getVolumeNamespace(volUuid)
|
keyringData.Namespace = getVolumeNamespace(volUuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
return storeCephCredentials(cr, &keyringData)
|
return storeCephCredentials(volUuid, cr, &keyringData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func storeCephAdminCredentials(cr *credentials) error {
|
func storeCephAdminCredentials(volUuid string, cr *credentials) error {
|
||||||
return storeCephCredentials(cr, &cephFullCapsKeyringData{UserId: cr.id, Key: cr.key})
|
return storeCephCredentials(volUuid, cr, &cephFullCapsKeyringData{UserId: cr.id, Key: cr.key, VolumeUuid: volUuid})
|
||||||
}
|
}
|
||||||
|
|
||||||
func storeCephCredentials(cr *credentials, keyringData cephConfigWriter) error {
|
func storeCephCredentials(volUuid string, cr *credentials, keyringData cephConfigWriter) error {
|
||||||
if err := keyringData.writeToFile(); err != nil {
|
if err := keyringData.writeToFile(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -104,6 +105,7 @@ func storeCephCredentials(cr *credentials, keyringData cephConfigWriter) error {
|
|||||||
secret := cephSecretData{
|
secret := cephSecretData{
|
||||||
UserId: cr.id,
|
UserId: cr.id,
|
||||||
Key: cr.key,
|
Key: cr.key,
|
||||||
|
VolumeUuid: volUuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := secret.writeToFile(); err != nil {
|
if err := secret.writeToFile(); err != nil {
|
||||||
|
@ -88,7 +88,7 @@ func createVolume(volOptions *volumeOptions, adminCr *credentials, volUuid strin
|
|||||||
// Access to cephfs's / is required
|
// Access to cephfs's / is required
|
||||||
volOptions.RootPath = "/"
|
volOptions.RootPath = "/"
|
||||||
|
|
||||||
if err := mountKernel(cephRoot, adminCr, volOptions); err != nil {
|
if err := mountKernel(cephRoot, adminCr, volOptions, volUuid); err != nil {
|
||||||
return fmt.Errorf("error mounting ceph root: %v", err)
|
return fmt.Errorf("error mounting ceph root: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ func purgeVolume(volId string, cr *credentials, volOptions *volumeOptions) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mountKernel(volRoot, cr, volOptions); err != nil {
|
if err := mountKernel(volRoot, cr, volOptions, volUuid); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions, vo
|
|||||||
mountPoint,
|
mountPoint,
|
||||||
"-c", getCephConfPath(volUuid),
|
"-c", getCephConfPath(volUuid),
|
||||||
"-n", cephEntityClientPrefix + cr.id,
|
"-n", cephEntityClientPrefix + cr.id,
|
||||||
"--keyring", getCephKeyringPath(cr.id),
|
"--keyring", getCephKeyringPath(volUuid, cr.id),
|
||||||
"-r", volOptions.RootPath,
|
"-r", volOptions.RootPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ func (m *fuseMounter) mount(mountPoint string, cr *credentials, volOptions *volu
|
|||||||
|
|
||||||
type kernelMounter struct{}
|
type kernelMounter struct{}
|
||||||
|
|
||||||
func mountKernel(mountPoint string, cr *credentials, volOptions *volumeOptions) error {
|
func mountKernel(mountPoint string, cr *credentials, volOptions *volumeOptions, volUuid string) error {
|
||||||
if err := execCommandAndValidate("modprobe", "ceph"); err != nil {
|
if err := execCommandAndValidate("modprobe", "ceph"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ func mountKernel(mountPoint string, cr *credentials, volOptions *volumeOptions)
|
|||||||
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
|
fmt.Sprintf("%s:%s", volOptions.Monitors, volOptions.RootPath),
|
||||||
mountPoint,
|
mountPoint,
|
||||||
"-o",
|
"-o",
|
||||||
fmt.Sprintf("name=%s,secretfile=%s", cr.id, getCephSecretPath(cr.id)),
|
fmt.Sprintf("name=%s,secretfile=%s", cr.id, getCephSecretPath(volUuid, cr.id)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ func (m *kernelMounter) mount(mountPoint string, cr *credentials, volOptions *vo
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mountKernel(localVolRoot, cr, volOptions); err != nil {
|
if err := mountKernel(localVolRoot, cr, volOptions, volUuid); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user