mirror of https://github.com/k3s-io/k3s
Improve the warning message if the rbd command is not found.
parent
11b5956f7a
commit
01b6fc78cd
|
@ -44,6 +44,7 @@ import (
|
|||
const (
|
||||
imageWatcherStr = "watcher="
|
||||
kubeLockMagic = "kubelet_lock_magic_"
|
||||
rbdCmdErr = "executable file not found in $PATH"
|
||||
)
|
||||
|
||||
// search /sys/bus for rbd device that matches given pool and image
|
||||
|
@ -103,6 +104,12 @@ type RBDUtil struct{}
|
|||
func (util *RBDUtil) MakeGlobalPDName(rbd rbd) string {
|
||||
return makePDNameInternal(rbd.plugin.host, rbd.Pool, rbd.Image)
|
||||
}
|
||||
func rbdErrors(runErr, resultErr error) error {
|
||||
if runErr.Error() == rbdCmdErr {
|
||||
return fmt.Errorf("rbd: rbd cmd not found")
|
||||
}
|
||||
return resultErr
|
||||
}
|
||||
|
||||
func (util *RBDUtil) rbdLock(b rbdMounter, lock bool) error {
|
||||
var err error
|
||||
|
@ -269,7 +276,7 @@ func (util *RBDUtil) AttachDisk(b rbdMounter) error {
|
|||
|
||||
// fence off other mappers
|
||||
if err = util.fencing(b); err != nil {
|
||||
return fmt.Errorf("rbd: image %s is locked by other nodes", b.Image)
|
||||
return rbdErrors(err, fmt.Errorf("rbd: failed to lock image %s (maybe locked by other nodes), error %v", b.Image, err))
|
||||
}
|
||||
// rbd lock remove needs ceph and image config
|
||||
// but kubelet doesn't get them from apiserver during teardown
|
||||
|
@ -327,7 +334,7 @@ func (util *RBDUtil) DetachDisk(c rbdUnmounter, mntPath string) error {
|
|||
// rbd unmap
|
||||
_, err = c.plugin.execCommand("rbd", []string{"unmap", device})
|
||||
if err != nil {
|
||||
return fmt.Errorf("rbd: failed to unmap device %s:Error: %v", device, err)
|
||||
return rbdErrors(err, fmt.Errorf("rbd: failed to unmap device %s:Error: %v", device, err))
|
||||
}
|
||||
|
||||
// load ceph and image/pool info to remove fencing
|
||||
|
@ -435,8 +442,12 @@ func (util *RBDUtil) rbdStatus(b *rbdMounter) (bool, error) {
|
|||
output = string(cmd)
|
||||
|
||||
if err != nil {
|
||||
// ignore error code, just checkout output for watcher string
|
||||
glog.Warningf("failed to execute rbd status on mon %s", mon)
|
||||
if err.Error() == rbdCmdErr {
|
||||
glog.Errorf("rbd cmd not found")
|
||||
} else {
|
||||
// ignore error code, just checkout output for watcher string
|
||||
glog.Warningf("failed to execute rbd status on mon %s", mon)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Contains(output, imageWatcherStr) {
|
||||
|
|
Loading…
Reference in New Issue