Skip to content

Commit

Permalink
platform/qemu: retry if OEM btrfs filesystem is in use
Browse files Browse the repository at this point in the history
The OEM partition can't be mounted more than once when it's a btrfs
filesystem, because having the same UUID is reserved for RAID usage.
When two kola instances run at the same time there is a possibility
for a race when both shortly want to use the OEM partition.

Use a conditional retry waiter to wait for exclusive access, giving
up after 10 minutes.
  • Loading branch information
pothos committed Aug 6, 2021
1 parent e4a6261 commit d48314d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions platform/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io/ioutil"
"os"
origExec "os/exec"
"path/filepath"
"regexp"
"runtime"
Expand Down Expand Up @@ -125,11 +126,20 @@ func MakeCLDiskTemplate(inputPath string) (output *os.File, result error) {
return nil, fmt.Errorf("failed to get loop device %s: %v", oemdev, err)
}

// mount OEM partition
err = util.Retry(10, 100*time.Millisecond, func() error {
// mount OEM partition, wait for exclusive access to the file system in case some other process also mounted an identical OEM btrfs filesystem
err = util.RetryConditional(600, 1000*time.Millisecond, func(err error) bool {
if exitCode, ok := err.(*origExec.ExitError); ok && exitCode.ProcessState.ExitCode() == 32 {
plog.Noticef("waiting for exclusive access to the OEM btrfs filesystem")
return true
}
return false
}, func() error {
return exec.Command("mount", oemdev, tmpdir).Run()
})
if err != nil {
if exitCode, ok := err.(*origExec.ExitError); ok && exitCode.ProcessState.ExitCode() == 32 {
return nil, fmt.Errorf("timed out waiting to mount the OEM btrfs filesystem exclusively from %s on %s: %v", oemdev, tmpdir, err)
}
return nil, fmt.Errorf("mounting OEM partition %s on %s: %v", oemdev, tmpdir, err)
}
defer func() {
Expand Down

0 comments on commit d48314d

Please sign in to comment.