Cloud-Temple / terraform-provider-cloudtemple

Cloud Temple CSP Terraform Provider
https://cloud-temple.com
Mozilla Public License 2.0
8 stars 1 forks source link

Error when trying to add multiple disk at the same time #139

Open mars4life opened 3 months ago

mars4life commented 3 months ago

Describe the bug An error occurs when I try to add 2 disks at the same time terraform version : 1.6.4 and also with 1.7.5 provider version : v0.13.0-rc.1

Current Behavior

An error occurs (Invalid date) when I try to add 2 disks at the same time. Only 1 disk is added if I reapply the same configuration, the second disk is then added. I think the error is because the disk are added simultaneous , but putting parallelism=1 is not a solution for me.

Expected behavior The 2 disks are added.

Steps to reproduce Steps to reproduce the behavior:

  1. Create a VM
  2. Try to add 2 disks at the same time

Screenshots If applicable, add screenshots to help explain your problem.

Additional context The error message:

Error: failed to create virtual disk, an error occured while waiting for completion of activity "26639178-58e1-42b6-b2b8-1acfd5ccea5f":
│ 
│   Description: Add virtual disk on virtual machine "amb".
│   Tenant ID: "14fx1x21-XXX-4959-XXXX-414x3xx95e6"
│   Created at 2024-04-02 13:00:04.245 +0000 UTC
│   Type: ComputeActivity
│   Tags: compute, vcenter, virtual_disk, create
│
│   Concerned Items:
│     - ID: "7ebbd38d-5f4a-4e26-b702-d0e7b6c9f217"
│       Type: virtual_machine
│     - ID: "e42d6bba-524c-4cc3-9be2-073b14df3f2e"
│       Type: virtual_disk
│
│   State: failed
│     Result:
│     Reason: Invalid Date
│     Started at 2024-04-02T13:00:04.258Z
│     Stopped at 2024-04-02T13:00:07.455Z
│
│   with cloudtemple_compute_virtual_disk.disk1,
│   on test.tf line 77, in resource "cloudtemple_compute_virtual_disk" "disk1":
pbesret commented 3 months ago

Hello Amakou,

This is a know issue of the provider since we cannot create disks at the virtual machine level. What's happening here is that when vSphere receives two (or more) requests to create a virtual disk simultaneously, it processes them sequentially. But if the first disk creation has been too long, it can refuse to process the following disk creation requests considering the situation has changed between the moment it received the request and the one it is able to process it.

One solution we could implement would be to create disks at the virtual machine level (in the cloudtemple_compute_virtual_machine resource) with a new virtual_disks property for example. But this solution would be very time consuming, and we cannot afford it for the moment.

In conclusion, a viable workaround, as you said would be to use the parameter parallelism=1 or to make the cloudtemple_compute_virtual_disk dependent to the previous one.

I'll let your issue open and link it to another one that is related, since we plan to implement a long-term solution in the future.

Thanks for your understanding.

Kind regards, Paul.

mars4life commented 3 months ago

Hello Paul, Thanks for your quick and precise answer. I completely understand that it takes a lot of time to implement a real clean solution. I'll see which workaround I'll implement meantime. KR, Amakou