Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/1.5] Fix retry logic within devmapper device deactivation #8089

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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