mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-26 00:00:23 +00:00
cephfs: ceph config filename is now mixed with volume UUID
This commit is contained in:
parent
bf89151b87
commit
1a7b365b95
@ -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"
|
||||
)
|
||||
@ -86,6 +86,7 @@ type cephConfigWriter interface {
|
||||
|
||||
type cephConfigData struct {
|
||||
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))
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user