mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-04 21:14:05 +00:00
fix(vm): timeout when resizing a disk during clone (#1103)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: Koloss5421 <koloss@Magni>
This commit is contained in:
parent
27dbcad5cd
commit
449f9fc31c
@ -16,6 +16,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/avast/retry-go/v4"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox/api"
|
||||
@ -262,12 +263,22 @@ func (c *Client) RebootVMAsync(ctx context.Context, d *RebootRequestBody) (*stri
|
||||
|
||||
// ResizeVMDisk resizes a virtual machine disk.
|
||||
func (c *Client) ResizeVMDisk(ctx context.Context, d *ResizeDiskRequestBody, timeout int) error {
|
||||
taskID, err := c.ResizeVMDiskAsync(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err := retry.Do(func() error {
|
||||
taskID, err := c.ResizeVMDiskAsync(ctx, d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.Tasks().WaitForTask(ctx, *taskID, timeout, 5)
|
||||
//nolint:wrapcheck
|
||||
return c.Tasks().WaitForTask(ctx, *taskID, timeout, 5)
|
||||
},
|
||||
retry.Attempts(3),
|
||||
retry.Delay(1*time.Second),
|
||||
retry.LastErrorOnly(false),
|
||||
retry.RetryIf(func(err error) bool {
|
||||
return strings.Contains(err.Error(), "got timeout")
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error waiting for VM disk resize: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user