mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
rbd: only load nbd module if not available yet
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
f04af5742d
commit
a0ef9da390
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -153,10 +154,15 @@ func waitForPath(ctx context.Context, pool, image string, maxRetries int, useNbd
|
|||||||
|
|
||||||
// Check if rbd-nbd tools are installed.
|
// Check if rbd-nbd tools are installed.
|
||||||
func checkRbdNbdTools() bool {
|
func checkRbdNbdTools() bool {
|
||||||
_, err := execCommand("modprobe", []string{moduleNbd})
|
// check if the module is loaded or compiled in
|
||||||
if err != nil {
|
_, err := os.Stat(fmt.Sprintf("/sys/module/%s", moduleNbd))
|
||||||
klog.V(3).Infof("rbd-nbd: nbd modprobe failed with error %v", err)
|
if os.IsNotExist(err) {
|
||||||
return false
|
// try to load the module
|
||||||
|
_, err = execCommand("modprobe", []string{moduleNbd})
|
||||||
|
if err != nil {
|
||||||
|
klog.V(3).Infof("rbd-nbd: nbd modprobe failed with error %v", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if _, err := execCommand(rbdTonbd, []string{"--version"}); err != nil {
|
if _, err := execCommand(rbdTonbd, []string{"--version"}); err != nil {
|
||||||
klog.V(3).Infof("rbd-nbd: running rbd-nbd --version failed with error %v", err)
|
klog.V(3).Infof("rbd-nbd: running rbd-nbd --version failed with error %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user