mirror of
https://github.com/outbackdingo/debos.git
synced 2026-01-27 18:18:45 +00:00
Merge pull request #524 from jakob-tsd/losetup_retry
ImagePartitionAction: retry losetup.Attach()
This commit is contained in:
@@ -459,9 +459,19 @@ func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error {
|
||||
|
||||
img.Close()
|
||||
|
||||
i.loopDev, err = losetup.Attach(imagePath, 0, false)
|
||||
// losetup.Attach() can fail due to concurrent attaches in other processes
|
||||
retries := 60
|
||||
for t := 1; t <= retries; t++ {
|
||||
i.loopDev, err = losetup.Attach(imagePath, 0, false)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
log.Printf("Setup loop device: try %d/%d failed: %v", t, retries, err)
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to setup loop device")
|
||||
return fmt.Errorf("Failed to setup loop device: %v", err)
|
||||
}
|
||||
context.Image = i.loopDev.Path()
|
||||
i.usingLoop = true
|
||||
|
||||
Reference in New Issue
Block a user