|
7 | 7 |
|
8 | 8 | libvirt "github.com/digitalocean/go-libvirt"
|
9 | 9 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
10 |
| - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 10 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" |
11 | 11 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
12 | 12 | )
|
13 | 13 |
|
@@ -101,9 +101,9 @@ func resourceLibvirtVolumeCreate(ctx context.Context, d *schema.ResourceData, me
|
101 | 101 |
|
102 | 102 | // Refresh the pool of the volume so that libvirt knows it is
|
103 | 103 | // not longer in use.
|
104 |
| - if err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { |
| 104 | + if err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *retry.RetryError { |
105 | 105 | if err := virConn.StoragePoolRefresh(pool, 0); err != nil {
|
106 |
| - return resource.RetryableError(err) |
| 106 | + return retry.RetryableError(err) |
107 | 107 | }
|
108 | 108 | return nil
|
109 | 109 | }); err != nil {
|
@@ -281,39 +281,39 @@ func resourceLibvirtVolumeRead(ctx context.Context, d *schema.ResourceData, meta
|
281 | 281 | poolName := d.Get("pool").(string)
|
282 | 282 |
|
283 | 283 | var volume libvirt.StorageVol
|
284 |
| - err := resource.RetryContext(ctx, d.Timeout(schema.TimeoutRead), func() *resource.RetryError { |
| 284 | + err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutRead), func() *retry.RetryError { |
285 | 285 | var lookupErr error
|
286 | 286 | volume, lookupErr = virConn.StorageVolLookupByKey(d.Id())
|
287 | 287 | if lookupErr == nil {
|
288 | 288 | return nil
|
289 | 289 | }
|
290 | 290 |
|
291 | 291 | if !isError(lookupErr, libvirt.ErrNoStorageVol) {
|
292 |
| - return resource.NonRetryableError(lookupErr) |
| 292 | + return retry.NonRetryableError(lookupErr) |
293 | 293 | }
|
294 | 294 |
|
295 | 295 | // volume not found, try to start the pool before retry
|
296 | 296 | volPool, err := virConn.StoragePoolLookupByName(poolName)
|
297 | 297 | if err != nil {
|
298 |
| - return resource.NonRetryableError(fmt.Errorf("error retrieving pool %s for volume %s: %w", poolName, d.Id(), err)) |
| 298 | + return retry.NonRetryableError(fmt.Errorf("error retrieving pool %s for volume %s: %w", poolName, d.Id(), err)) |
299 | 299 | }
|
300 | 300 |
|
301 | 301 | active, err := virConn.StoragePoolIsActive(volPool)
|
302 | 302 | if err != nil {
|
303 |
| - return resource.NonRetryableError(fmt.Errorf("error retrieving status of pool %s for volume %s: %w", poolName, d.Id(), err)) |
| 303 | + return retry.NonRetryableError(fmt.Errorf("error retrieving status of pool %s for volume %s: %w", poolName, d.Id(), err)) |
304 | 304 | }
|
305 | 305 |
|
306 | 306 | // pool was already started, nothing else to do
|
307 | 307 | if active == 1 {
|
308 |
| - return resource.NonRetryableError(lookupErr) |
| 308 | + return retry.NonRetryableError(lookupErr) |
309 | 309 | }
|
310 | 310 |
|
311 | 311 | if err := virConn.StoragePoolCreate(volPool, 0); err != nil {
|
312 |
| - return resource.NonRetryableError(fmt.Errorf("error starting pool %s: %w", poolName, err)) |
| 312 | + return retry.NonRetryableError(fmt.Errorf("error starting pool %s: %w", poolName, err)) |
313 | 313 | }
|
314 | 314 |
|
315 | 315 | // pool started successfully, retry
|
316 |
| - return resource.RetryableError(lookupErr) |
| 316 | + return retry.RetryableError(lookupErr) |
317 | 317 | })
|
318 | 318 |
|
319 | 319 | if isError(err, libvirt.ErrNoStorageVol) {
|
|
0 commit comments