mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
RBD Plugin: Fix bug in checking command not found error.
This commit is contained in:
parent
6e950cc629
commit
ff639e80e8
@ -27,6 +27,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -43,7 +44,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
imageWatcherStr = "watcher="
|
imageWatcherStr = "watcher="
|
||||||
kubeLockMagic = "kubelet_lock_magic_"
|
kubeLockMagic = "kubelet_lock_magic_"
|
||||||
rbdCmdErr = "executable file not found in $PATH"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// search /sys/bus for rbd device that matches given pool and image
|
// search /sys/bus for rbd device that matches given pool and image
|
||||||
@ -117,9 +117,11 @@ func (util *RBDUtil) MakeGlobalPDName(rbd rbd) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func rbdErrors(runErr, resultErr error) error {
|
func rbdErrors(runErr, resultErr error) error {
|
||||||
if runErr.Error() == rbdCmdErr {
|
if err, ok := runErr.(*exec.Error); ok {
|
||||||
|
if err.Err == exec.ErrNotFound {
|
||||||
return fmt.Errorf("rbd: rbd cmd not found")
|
return fmt.Errorf("rbd: rbd cmd not found")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return resultErr
|
return resultErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,12 +481,14 @@ func (util *RBDUtil) rbdStatus(b *rbdMounter) (bool, string, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if err.Error() == rbdCmdErr {
|
if err, ok := err.(*exec.Error); ok {
|
||||||
|
if err.Err == exec.ErrNotFound {
|
||||||
glog.Errorf("rbd cmd not found")
|
glog.Errorf("rbd cmd not found")
|
||||||
// fail fast if command not found
|
// fail fast if command not found
|
||||||
return false, output, err
|
return false, output, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If command never succeed, returns its last error.
|
// If command never succeed, returns its last error.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user