Fix retry logic within devmapper device deactivation
Signed-off-by: Swagat Bora <sbora@amazon.com>
This commit is contained in:
		| @@ -88,6 +88,15 @@ func NewPoolDevice(ctx context.Context, config *Config) (*PoolDevice, error) { | |||||||
| 	return poolDevice, nil | 	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 { | func retry(ctx context.Context, f func() error) error { | ||||||
| 	var ( | 	var ( | ||||||
| 		maxRetries = 100 | 		maxRetries = 100 | ||||||
| @@ -97,9 +106,8 @@ func retry(ctx context.Context, f func() error) error { | |||||||
|  |  | ||||||
| 	for attempt := 1; attempt <= maxRetries; attempt++ { | 	for attempt := 1; attempt <= maxRetries; attempt++ { | ||||||
| 		retryErr = f() | 		retryErr = f() | ||||||
| 		if retryErr == nil { |  | ||||||
| 			return nil | 		if skipRetry(retryErr) { | ||||||
| 		} else if retryErr != unix.EBUSY { |  | ||||||
| 			return retryErr | 			return retryErr | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Swagat Bora
					Swagat Bora