1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Devicemapper: ignore Nodata errors when delete thin device

if thin device is deteled and the metadata exists, you can not
delete related containers. This patch ignore Nodata errors for
thin device deletion

Signed-off-by: Liu Hua <sdu.liu@huawei.com>
This commit is contained in:
Liu Hua 2017-10-23 21:00:22 +08:00 committed by Yong Tang
parent c345c53859
commit 8451d03d8e
2 changed files with 13 additions and 3 deletions

View file

@ -67,12 +67,14 @@ var (
ErrBusy = errors.New("Device is Busy") ErrBusy = errors.New("Device is Busy")
ErrDeviceIDExists = errors.New("Device Id Exists") ErrDeviceIDExists = errors.New("Device Id Exists")
ErrEnxio = errors.New("No such device or address") ErrEnxio = errors.New("No such device or address")
ErrEnoData = errors.New("No data available")
) )
var ( var (
dmSawBusy bool dmSawBusy bool
dmSawExist bool dmSawExist bool
dmSawEnxio bool // No Such Device or Address dmSawEnxio bool // No Such Device or Address
dmSawEnoData bool // No data available
) )
type ( type (
@ -708,10 +710,15 @@ func DeleteDevice(poolName string, deviceID int) error {
} }
dmSawBusy = false dmSawBusy = false
dmSawEnoData = false
if err := task.run(); err != nil { if err := task.run(); err != nil {
if dmSawBusy { if dmSawBusy {
return ErrBusy return ErrBusy
} }
if dmSawEnoData {
logrus.Debugf("devicemapper: Device(id: %d) from pool(%s) does not exist", deviceID, poolName)
return nil
}
return fmt.Errorf("devicemapper: Error running DeleteDevice %s", err) return fmt.Errorf("devicemapper: Error running DeleteDevice %s", err)
} }
return nil return nil

View file

@ -55,6 +55,9 @@ func DevmapperLogCallback(level C.int, file *C.char, line, dmErrnoOrClass C.int,
if strings.Contains(msg, "No such device or address") { if strings.Contains(msg, "No such device or address") {
dmSawEnxio = true dmSawEnxio = true
} }
if strings.Contains(msg, "No data available") {
dmSawEnoData = true
}
} }
if dmLogger != nil { if dmLogger != nil {