mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #6069 from crosbymichael/dm-errors
Return devmapper errors with additional text
This commit is contained in:
commit
e56cf35c29
1 changed files with 27 additions and 27 deletions
|
@ -327,21 +327,21 @@ func createPool(poolName string, dataFile, metadataFile *os.File) error {
|
|||
|
||||
size, err := GetBlockDeviceSize(dataFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Can't get data size")
|
||||
return fmt.Errorf("Can't get data size %s", err)
|
||||
}
|
||||
|
||||
params := metadataFile.Name() + " " + dataFile.Name() + " 128 32768 1 skip_block_zeroing"
|
||||
if err := task.AddTarget(0, size/512, "thin-pool", params); err != nil {
|
||||
return fmt.Errorf("Can't add target")
|
||||
return fmt.Errorf("Can't add target %s", err)
|
||||
}
|
||||
|
||||
var cookie uint = 0
|
||||
if err := task.SetCookie(&cookie, 0); err != nil {
|
||||
return fmt.Errorf("Can't set cookie")
|
||||
return fmt.Errorf("Can't set cookie %s", err)
|
||||
}
|
||||
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running DeviceCreate (createPool)")
|
||||
return fmt.Errorf("Error running DeviceCreate (createPool) %s", err)
|
||||
}
|
||||
|
||||
UdevWait(cookie)
|
||||
|
@ -357,16 +357,16 @@ func reloadPool(poolName string, dataFile, metadataFile *os.File) error {
|
|||
|
||||
size, err := GetBlockDeviceSize(dataFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Can't get data size")
|
||||
return fmt.Errorf("Can't get data size %s", err)
|
||||
}
|
||||
|
||||
params := metadataFile.Name() + " " + dataFile.Name() + " 128 32768"
|
||||
if err := task.AddTarget(0, size/512, "thin-pool", params); err != nil {
|
||||
return fmt.Errorf("Can't add target")
|
||||
return fmt.Errorf("Can't add target %s", err)
|
||||
}
|
||||
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running DeviceCreate")
|
||||
return fmt.Errorf("Error running DeviceCreate %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -426,15 +426,15 @@ func setTransactionId(poolName string, oldId uint64, newId uint64) error {
|
|||
}
|
||||
|
||||
if err := task.SetSector(0); err != nil {
|
||||
return fmt.Errorf("Can't set sector")
|
||||
return fmt.Errorf("Can't set sector %s", err)
|
||||
}
|
||||
|
||||
if err := task.SetMessage(fmt.Sprintf("set_transaction_id %d %d", oldId, newId)); err != nil {
|
||||
return fmt.Errorf("Can't set message")
|
||||
return fmt.Errorf("Can't set message %s", err)
|
||||
}
|
||||
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running setTransactionId")
|
||||
return fmt.Errorf("Error running setTransactionId %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ func suspendDevice(name string) error {
|
|||
return err
|
||||
}
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running DeviceSuspend: %s", err)
|
||||
return fmt.Errorf("Error running DeviceSuspend %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -458,11 +458,11 @@ func resumeDevice(name string) error {
|
|||
|
||||
var cookie uint = 0
|
||||
if err := task.SetCookie(&cookie, 0); err != nil {
|
||||
return fmt.Errorf("Can't set cookie")
|
||||
return fmt.Errorf("Can't set cookie %s", err)
|
||||
}
|
||||
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running DeviceResume")
|
||||
return fmt.Errorf("Error running DeviceResume %s", err)
|
||||
}
|
||||
|
||||
UdevWait(cookie)
|
||||
|
@ -480,11 +480,11 @@ func createDevice(poolName string, deviceId *int) error {
|
|||
}
|
||||
|
||||
if err := task.SetSector(0); err != nil {
|
||||
return fmt.Errorf("Can't set sector")
|
||||
return fmt.Errorf("Can't set sector %s", err)
|
||||
}
|
||||
|
||||
if err := task.SetMessage(fmt.Sprintf("create_thin %d", *deviceId)); err != nil {
|
||||
return fmt.Errorf("Can't set message")
|
||||
return fmt.Errorf("Can't set message %s", err)
|
||||
}
|
||||
|
||||
dmSawExist = false
|
||||
|
@ -494,7 +494,7 @@ func createDevice(poolName string, deviceId *int) error {
|
|||
*deviceId++
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("Error running createDevice")
|
||||
return fmt.Errorf("Error running createDevice %s", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -508,15 +508,15 @@ func deleteDevice(poolName string, deviceId int) error {
|
|||
}
|
||||
|
||||
if err := task.SetSector(0); err != nil {
|
||||
return fmt.Errorf("Can't set sector")
|
||||
return fmt.Errorf("Can't set sector %s", err)
|
||||
}
|
||||
|
||||
if err := task.SetMessage(fmt.Sprintf("delete %d", deviceId)); err != nil {
|
||||
return fmt.Errorf("Can't set message")
|
||||
return fmt.Errorf("Can't set message %s", err)
|
||||
}
|
||||
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running deleteDevice")
|
||||
return fmt.Errorf("Error running deleteDevice %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ func removeDevice(name string) error {
|
|||
if dmSawBusy {
|
||||
return ErrBusy
|
||||
}
|
||||
return fmt.Errorf("Error running removeDevice")
|
||||
return fmt.Errorf("Error running removeDevice %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -546,19 +546,19 @@ func activateDevice(poolName string, name string, deviceId int, size uint64) err
|
|||
|
||||
params := fmt.Sprintf("%s %d", poolName, deviceId)
|
||||
if err := task.AddTarget(0, size/512, "thin", params); err != nil {
|
||||
return fmt.Errorf("Can't add target")
|
||||
return fmt.Errorf("Can't add target %s", err)
|
||||
}
|
||||
if err := task.SetAddNode(AddNodeOnCreate); err != nil {
|
||||
return fmt.Errorf("Can't add node")
|
||||
return fmt.Errorf("Can't add node %s", err)
|
||||
}
|
||||
|
||||
var cookie uint = 0
|
||||
if err := task.SetCookie(&cookie, 0); err != nil {
|
||||
return fmt.Errorf("Can't set cookie")
|
||||
return fmt.Errorf("Can't set cookie %s", err)
|
||||
}
|
||||
|
||||
if err := task.Run(); err != nil {
|
||||
return fmt.Errorf("Error running DeviceCreate (activateDevice)")
|
||||
return fmt.Errorf("Error running DeviceCreate (activateDevice) %s", err)
|
||||
}
|
||||
|
||||
UdevWait(cookie)
|
||||
|
@ -589,14 +589,14 @@ func createSnapDevice(poolName string, deviceId *int, baseName string, baseDevic
|
|||
if doSuspend {
|
||||
resumeDevice(baseName)
|
||||
}
|
||||
return fmt.Errorf("Can't set sector")
|
||||
return fmt.Errorf("Can't set sector %s", err)
|
||||
}
|
||||
|
||||
if err := task.SetMessage(fmt.Sprintf("create_snap %d %d", *deviceId, baseDeviceId)); err != nil {
|
||||
if doSuspend {
|
||||
resumeDevice(baseName)
|
||||
}
|
||||
return fmt.Errorf("Can't set message")
|
||||
return fmt.Errorf("Can't set message %s", err)
|
||||
}
|
||||
|
||||
dmSawExist = false
|
||||
|
@ -610,7 +610,7 @@ func createSnapDevice(poolName string, deviceId *int, baseName string, baseDevic
|
|||
if doSuspend {
|
||||
resumeDevice(baseName)
|
||||
}
|
||||
return fmt.Errorf("Error running DeviceCreate (createSnapDevice)")
|
||||
return fmt.Errorf("Error running DeviceCreate (createSnapDevice) %s", err)
|
||||
}
|
||||
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue