Commit 7eb53ce8 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #48171 from sdkfzv/master

Automatic merge from submit-queue Improve the warning message if the rbd command is not found. **What this PR does / why we need it**: The previous warning msg is not correct if there is no rbd cmd. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note ```
parents 2e6e314a cb388d0c
......@@ -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: failed to lock image %s (maybe locked by other nodes), error %v", b.Image, err)
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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment