cephfs: ceph config filename is now mixed with volume UUID

This commit is contained in:
gman 2018-05-18 18:17:37 +02:00
parent bf89151b87
commit 1a7b365b95
2 changed files with 11 additions and 8 deletions

View File

@ -51,7 +51,7 @@ const cephSecret = `{{.Key}}`
const ( const (
cephConfigRoot = "/etc/ceph" cephConfigRoot = "/etc/ceph"
cephConfigFileName = "ceph.conf" cephConfigFileNameFmt = "ceph.share.%s.conf"
cephKeyringFileNameFmt = "ceph.client.%s.keyring" cephKeyringFileNameFmt = "ceph.client.%s.keyring"
cephSecretFileNameFmt = "ceph.client.%s.secret" cephSecretFileNameFmt = "ceph.client.%s.secret"
) )
@ -85,7 +85,8 @@ type cephConfigWriter interface {
} }
type cephConfigData struct { type cephConfigData struct {
Monitors string Monitors string
VolumeUuid string
} }
func writeCephTemplate(fileName string, m os.FileMode, t *template.Template, data interface{}) error { 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 { func (d *cephConfigData) writeToFile() error {
return writeCephTemplate(cephConfigFileName, 0640, cephConfigTempl, d) return writeCephTemplate(fmt.Sprintf(cephConfigFileNameFmt, d.VolumeUuid), 0640, cephConfigTempl, d)
} }
type cephKeyringData struct { type cephKeyringData struct {
@ -144,6 +145,6 @@ func getCephKeyringPath(userId string) string {
return path.Join(cephConfigRoot, fmt.Sprintf(cephKeyringFileNameFmt, userId)) return path.Join(cephConfigRoot, fmt.Sprintf(cephKeyringFileNameFmt, userId))
} }
func getCephConfPath() string { func getCephConfPath(volUuid string) string {
return path.Join(cephConfigRoot, cephConfigFileName) return path.Join(cephConfigRoot, fmt.Sprintf(cephConfigFileNameFmt, volUuid))
} }

View File

@ -33,10 +33,12 @@ type volumeMounter interface {
type fuseMounter struct{} 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{ args := [...]string{
mountPoint, mountPoint,
"-c", getCephConfPath(volUuid),
"-n", cephEntityClientPrefix + cr.id, "-n", cephEntityClientPrefix + cr.id,
"--keyring", getCephKeyringPath(cr.id),
"-r", volOptions.RootPath, "-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) 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) 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 return err
} }
if err := mountFuse(localVolRoot, cr, volOptions); err != nil { if err := mountFuse(localVolRoot, cr, volOptions, volUuid); err != nil {
return err return err
} }