Skip to content

Commit

Permalink
Merge pull request #8089 from swagatbora90/backport-1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelkarp authored Feb 11, 2023
2 parents 9e9f4c8 + 0d16d04 commit 7c3b243
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions snapshots/devmapper/pool_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ func NewPoolDevice(ctx context.Context, config *Config) (*PoolDevice, error) {
return poolDevice, nil
}

func skipRetry(err error) bool {
if err == nil {
return true // skip retry if no error
} else if !errors.Is(err, unix.EBUSY) {
return true // skip retry if error is not due to device or resource busy
}
return false
}

func retry(ctx context.Context, f func() error) error {
var (
maxRetries = 100
Expand All @@ -85,9 +94,8 @@ func retry(ctx context.Context, f func() error) error {

for attempt := 1; attempt <= maxRetries; attempt++ {
retryErr = f()
if retryErr == nil {
return nil
} else if retryErr != unix.EBUSY {

if skipRetry(retryErr) {
return retryErr
}

Expand Down

0 comments on commit 7c3b243

Please sign in to comment.