mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-23 21:40:20 +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
|
||||
adminid: admin
|
||||
userid: kubernetes
|
||||
# uncomment the following to use rbd-nbd as mounter on supported nodes
|
||||
#mounter: rbd-nbd
|
||||
reclaimPolicy: Delete
|
||||
|
@ -35,7 +35,7 @@ const (
|
||||
|
||||
var (
|
||||
hostRootFS = "/"
|
||||
useNBD = false
|
||||
hasNBD = false
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -43,7 +43,7 @@ func init() {
|
||||
if len(host) > 0 {
|
||||
hostRootFS = host
|
||||
}
|
||||
useNBD = checkRbdNbdTools()
|
||||
hasNBD = checkRbdNbdTools()
|
||||
}
|
||||
|
||||
func getDevFromImageAndPool(pool, image string) (string, bool) {
|
||||
@ -226,12 +226,15 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
|
||||
image := volOptions.VolName
|
||||
imagePath := fmt.Sprintf("%s/%s", volOptions.Pool, image)
|
||||
|
||||
useNBD := false
|
||||
cmdName := "rbd"
|
||||
moduleName := "rbd"
|
||||
if useNBD {
|
||||
if volOptions.Mounter == "rbd-nbd" && hasNBD {
|
||||
useNBD = true
|
||||
cmdName = "rbd-nbd"
|
||||
moduleName = "nbd"
|
||||
}
|
||||
|
||||
devicePath, found := waitForPath(volOptions.Pool, image, 1, useNBD)
|
||||
if !found {
|
||||
attachdetachMutex.LockKey(string(imagePath))
|
||||
@ -258,7 +261,7 @@ func attachRBDImage(volOptions *rbdVolume, userId string, credentials map[string
|
||||
if err == wait.ErrWaitTimeout {
|
||||
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 {
|
||||
return "", err
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ const (
|
||||
rbdImageWatcherInitDelay = 1 * time.Second
|
||||
rbdImageWatcherFactor = 1.4
|
||||
rbdImageWatcherSteps = 10
|
||||
rbdDefaultMounter = "rbd"
|
||||
)
|
||||
|
||||
type rbdVolume struct {
|
||||
@ -54,6 +55,7 @@ type rbdVolume struct {
|
||||
VolSize int64 `json:"volSize"`
|
||||
AdminId string `json:"adminId"`
|
||||
UserId string `json:"userId"`
|
||||
Mounter string `json:"mounter"`
|
||||
}
|
||||
|
||||
type rbdSnapshot struct {
|
||||
@ -226,6 +228,10 @@ func getRBDVolumeOptions(volOptions map[string]string) (*rbdVolume, error) {
|
||||
if !ok {
|
||||
rbdVol.UserId = rbdDefaultUserId
|
||||
}
|
||||
rbdVol.Mounter, ok = volOptions["mounter"]
|
||||
if !ok {
|
||||
rbdVol.Mounter = rbdDefaultMounter
|
||||
}
|
||||
return rbdVol, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user