mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-21 16:03:32 +01:00
platformtest: retry zpool export if 'pool is busy'
On Ubuntu, something seems to be holding on to the pool for too long.
This commit is contained in:
parent
2e2a8a1d5d
commit
04e03f4d06
@ -37,6 +37,7 @@ func main() {
|
||||
flag.StringVar(&args.CreateArgs.Mountpoint, "mountpoint", "", "")
|
||||
flag.BoolVar(&args.StopAndKeepPoolOnFail, "failure.stop-and-keep-pool", false, "if a test case fails, stop test execution and keep pool as it was when the test failed")
|
||||
flag.StringVar(&args.Run, "run", "", "")
|
||||
flag.DurationVar(&platformtest.ZpoolExportTimeout, "zfs.zpool-export-timeout", platformtest.ZpoolExportTimeout, "")
|
||||
flag.Parse()
|
||||
|
||||
if err := HarnessRun(args); err != nil {
|
||||
|
@ -5,12 +5,17 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
var ZpoolExportTimeout time.Duration = 500 * time.Millisecond
|
||||
|
||||
type Zpool struct {
|
||||
args ZpoolCreateArgs
|
||||
}
|
||||
@ -93,8 +98,23 @@ func (p *Zpool) Name() string { return p.args.PoolName }
|
||||
|
||||
func (p *Zpool) Destroy(ctx context.Context, e Execer) error {
|
||||
|
||||
if err := e.RunExpectSuccessNoOutput(ctx, "zpool", "export", p.args.PoolName); err != nil {
|
||||
return errors.Wrapf(err, "export pool %q", p.args.PoolName)
|
||||
exportDeadline := time.Now().Add(ZpoolExportTimeout)
|
||||
|
||||
for {
|
||||
if time.Now().After(exportDeadline) {
|
||||
return errors.Errorf("could not zpool export (got 'pool is busy'): %s", p.args.PoolName)
|
||||
}
|
||||
err := e.RunExpectSuccessNoOutput(ctx, "zpool", "export", p.args.PoolName)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if strings.Contains(err.Error(), "pool is busy") {
|
||||
runtime.Gosched()
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "export pool %q", p.args.PoolName)
|
||||
}
|
||||
}
|
||||
|
||||
if err := os.Remove(p.args.ImagePath); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user