mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
add rbd-nbd mounter in storage class
Signed-off-by: Huamin Chen <hchen@redhat.com>
This commit is contained in:
parent
6f3625b11e
commit
30a5d9a6e7
@ -25,4 +25,6 @@ parameters:
|
|||||||
# Ceph users for operating RBD
|
# Ceph users for operating RBD
|
||||||
adminid: admin
|
adminid: admin
|
||||||
userid: kubernetes
|
userid: kubernetes
|
||||||
|
# uncomment the following to use rbd-nbd as mounter on supported nodes
|
||||||
|
#mounter: rbd-nbd
|
||||||
reclaimPolicy: Delete
|
reclaimPolicy: Delete
|
||||||
|
@ -35,7 +35,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
hostRootFS = "/"
|
hostRootFS = "/"
|
||||||
useNBD = false
|
hasNBD = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -43,7 +43,7 @@ func init() {
|
|||||||
if len(host) > 0 {
|
if len(host) > 0 {
|
||||||
hostRootFS = host
|
hostRootFS = host
|
||||||
}
|
}
|
||||||
useNBD = checkRbdNbdTools()
|
hasNBD = checkRbdNbdTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDevFromImageAndPool(pool, image string) (string, bool) {
|
func getDevFromImageAndPool(pool, image string) (string, bool) {
|
||||||
@ -226,12 +226,15 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
|
|||||||
image := volOptions.VolName
|
image := volOptions.VolName
|
||||||
imagePath := fmt.Sprintf("%s/%s", volOptions.Pool, image)
|
imagePath := fmt.Sprintf("%s/%s", volOptions.Pool, image)
|
||||||
|
|
||||||
|
useNBD := false
|
||||||
cmdName := "rbd"
|
cmdName := "rbd"
|
||||||
moduleName := "rbd"
|
moduleName := "rbd"
|
||||||
if useNBD {
|
if volOptions.Mounter == "rbd-nbd" && hasNBD {
|
||||||
|
useNBD = true
|
||||||
cmdName = "rbd-nbd"
|
cmdName = "rbd-nbd"
|
||||||
moduleName = "nbd"
|
moduleName = "nbd"
|
||||||
}
|
}
|
||||||
|
|
||||||
devicePath, found := waitForPath(volOptions.Pool, image, 1, useNBD)
|
devicePath, found := waitForPath(volOptions.Pool, image, 1, useNBD)
|
||||||
if !found {
|
if !found {
|
||||||
attachdetachMutex.LockKey(string(imagePath))
|
attachdetachMutex.LockKey(string(imagePath))
|
||||||
@ -258,7 +261,7 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
|
|||||||
if err == wait.ErrWaitTimeout {
|
if err == wait.ErrWaitTimeout {
|
||||||
return "", fmt.Errorf("rbd image %s is still being used", imagePath)
|
return "", fmt.Errorf("rbd image %s is still being used", imagePath)
|
||||||
}
|
}
|
||||||
// return error if any other errors were encountered during wating for the image to becme avialble
|
// return error if any other errors were encountered during wating for the image to become available
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ const (
|
|||||||
rbdImageWatcherInitDelay = 1 * time.Second
|
rbdImageWatcherInitDelay = 1 * time.Second
|
||||||
rbdImageWatcherFactor = 1.4
|
rbdImageWatcherFactor = 1.4
|
||||||
rbdImageWatcherSteps = 10
|
rbdImageWatcherSteps = 10
|
||||||
|
rbdDefaultMounter = "rbd"
|
||||||
)
|
)
|
||||||
|
|
||||||
type rbdVolume struct {
|
type rbdVolume struct {
|
||||||
@ -54,6 +55,7 @@ type rbdVolume struct {
|
|||||||
VolSize int64 `json:"volSize"`
|
VolSize int64 `json:"volSize"`
|
||||||
AdminId string `json:"adminId"`
|
AdminId string `json:"adminId"`
|
||||||
UserId string `json:"userId"`
|
UserId string `json:"userId"`
|
||||||
|
Mounter string `json:"mounter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type rbdSnapshot struct {
|
type rbdSnapshot struct {
|
||||||
@ -226,6 +228,10 @@ func getRBDVolumeOptions(volOptions map[string]string) (*rbdVolume, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
rbdVol.UserId = rbdDefaultUserId
|
rbdVol.UserId = rbdDefaultUserId
|
||||||
}
|
}
|
||||||
|
rbdVol.Mounter, ok = volOptions["mounter"]
|
||||||
|
if !ok {
|
||||||
|
rbdVol.Mounter = rbdDefaultMounter
|
||||||
|
}
|
||||||
return rbdVol, nil
|
return rbdVol, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user