mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-23 19:05:37 +00:00
After partitioning we now retry the stat prior to formatting
When waiting for devices to refresh a stat can fail with the error message 'stat: /dev/vda1: stat: no such file or directory'. This was observered with empty raw disks (*.img) that was being created by the moby/hyperkit go library. This commit restores the previous logic of refreshing with mdev instead of returning an error. Signed-off-by: dave protasowski <dprotaso@gmail.com>
This commit is contained in:
parent
10bae91564
commit
86f254850d
@ -100,13 +100,15 @@ func refreshDevicesAndWaitFor(awaitedDevice string) error {
|
|||||||
exec.Command("mdev", "-s").Run()
|
exec.Command("mdev", "-s").Run()
|
||||||
|
|
||||||
// wait for device
|
// wait for device
|
||||||
var done bool
|
var (
|
||||||
|
done bool
|
||||||
|
err error
|
||||||
|
stat os.FileInfo
|
||||||
|
)
|
||||||
|
|
||||||
for i := 0; i < timeout; i++ {
|
for i := 0; i < timeout; i++ {
|
||||||
stat, err := os.Stat(awaitedDevice)
|
stat, err = os.Stat(awaitedDevice)
|
||||||
if err != nil {
|
if err == nil && isBlockDevice(&stat) {
|
||||||
return err
|
|
||||||
}
|
|
||||||
if isBlockDevice(&stat) {
|
|
||||||
done = true
|
done = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -114,7 +116,11 @@ func refreshDevicesAndWaitFor(awaitedDevice string) error {
|
|||||||
exec.Command("mdev", "-s").Run()
|
exec.Command("mdev", "-s").Run()
|
||||||
}
|
}
|
||||||
if !done {
|
if !done {
|
||||||
return fmt.Errorf("Error waiting for device %s", awaitedDevice)
|
var statMsg string
|
||||||
|
if err != nil {
|
||||||
|
statMsg = fmt.Sprintf(" - stat returned: %v", err)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("Failed to find block device %s%s", awaitedDevice, statMsg)
|
||||||
}
|
}
|
||||||
// even after the device appears we still have a race
|
// even after the device appears we still have a race
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
Loading…
Reference in New Issue
Block a user