diff --git a/pkg/cephfs/cephconf.go b/pkg/cephfs/cephconf.go index e7652cb53..58ac292e6 100644 --- a/pkg/cephfs/cephconf.go +++ b/pkg/cephfs/cephconf.go @@ -51,7 +51,7 @@ const cephSecret = `{{.Key}}` const ( cephConfigRoot = "/etc/ceph" - cephConfigFileName = "ceph.conf" + cephConfigFileNameFmt = "ceph.share.%s.conf" cephKeyringFileNameFmt = "ceph.client.%s.keyring" cephSecretFileNameFmt = "ceph.client.%s.secret" ) @@ -85,7 +85,8 @@ type cephConfigWriter interface { } type cephConfigData struct { - Monitors string + Monitors string + VolumeUuid string } func writeCephTemplate(fileName string, m os.FileMode, t *template.Template, data interface{}) error { @@ -107,7 +108,7 @@ func writeCephTemplate(fileName string, m os.FileMode, t *template.Template, dat } func (d *cephConfigData) writeToFile() error { - return writeCephTemplate(cephConfigFileName, 0640, cephConfigTempl, d) + return writeCephTemplate(fmt.Sprintf(cephConfigFileNameFmt, d.VolumeUuid), 0640, cephConfigTempl, d) } type cephKeyringData struct { @@ -144,6 +145,6 @@ func getCephKeyringPath(userId string) string { return path.Join(cephConfigRoot, fmt.Sprintf(cephKeyringFileNameFmt, userId)) } -func getCephConfPath() string { - return path.Join(cephConfigRoot, cephConfigFileName) +func getCephConfPath(volUuid string) string { + return path.Join(cephConfigRoot, fmt.Sprintf(cephConfigFileNameFmt, volUuid)) } diff --git a/pkg/cephfs/volumemounter.go b/pkg/cephfs/volumemounter.go index 466c4a34c..7756b5c22 100644 --- a/pkg/cephfs/volumemounter.go +++ b/pkg/cephfs/volumemounter.go @@ -33,10 +33,12 @@ type volumeMounter interface { type fuseMounter struct{} -func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions) error { +func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions, volUuid string) error { args := [...]string{ mountPoint, + "-c", getCephConfPath(volUuid), "-n", cephEntityClientPrefix + cr.id, + "--keyring", getCephKeyringPath(cr.id), "-r", volOptions.RootPath, } @@ -45,7 +47,7 @@ func mountFuse(mountPoint string, cr *credentials, volOptions *volumeOptions) er return fmt.Errorf("cephfs: ceph-fuse failed with following error: %s\ncephfs: ceph-fuse output: %s", err, out) } - if !bytes.Contains(out, []byte("starting fuse"[:])) { + if !bytes.Contains(out, []byte("starting fuse")) { return fmt.Errorf("cephfs: ceph-fuse failed:\ncephfs: ceph-fuse output: %s", out) } @@ -63,7 +65,7 @@ func (m *fuseMounter) mount(mountPoint string, cr *credentials, volOptions *volu return err } - if err := mountFuse(localVolRoot, cr, volOptions); err != nil { + if err := mountFuse(localVolRoot, cr, volOptions, volUuid); err != nil { return err }