Avoid RbdDiskManager's DetachDisk never execute again
This commit is contained in:
@@ -57,6 +57,12 @@ const (
|
||||
rbdImageSizeUnitMiB = 1024 * 1024
|
||||
)
|
||||
|
||||
// A struct contains rbd image info.
|
||||
type rbdImageInfo struct {
|
||||
pool string
|
||||
name string
|
||||
}
|
||||
|
||||
func getDevFromImageAndPool(pool, image string) (string, bool) {
|
||||
device, found := getRbdDevFromImageAndPool(pool, image)
|
||||
if found {
|
||||
@@ -789,3 +795,15 @@ func (util *RBDUtil) rbdStatus(b *rbdMounter) (bool, string, error) {
|
||||
return false, output, nil
|
||||
}
|
||||
}
|
||||
|
||||
// getRbdImageInfo try to get rbdImageInfo from deviceMountPath.
|
||||
func getRbdImageInfo(deviceMountPath string) (*rbdImageInfo, error) {
|
||||
deviceMountedPathSeps := strings.Split(filepath.Base(deviceMountPath), "-image-")
|
||||
if len(deviceMountedPathSeps) != 2 {
|
||||
return nil, fmt.Errorf("Can't found devicePath for %s ", deviceMountPath)
|
||||
}
|
||||
return &rbdImageInfo{
|
||||
pool: deviceMountedPathSeps[0],
|
||||
name: deviceMountedPathSeps[1],
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user