Open dmicheneau opened 1 year ago
Hello @dmicheneau ,
I did not really grasp the issue - does the vcd_inserted_media
not handle eject_force = true
for you or what exactly is the request?
If you need to handle this operation in SDK, you could check how it is done in Terraform provider for VCD - https://github.com/vmware/terraform-provider-vcd/blob/main/vcd/resource_vcd_inserted_media.go#L136-L144
BTW. I see this linked issue which got me confused.
The first impression is that the provider cloudavenue
is the same VCD provider (using go-vcloud-director SDK), is it so? What is the reason for building a separate provider? Does it have any specifics?
@dmicheneau why do you need another provider?
Cloudavenue is a light and simplified version of VCD provider for our client. It's rebuilt with the framework terraform and not the sdk. In the example i give, the problem exist with the vcd provider. For the both problem come from api vcloud director.
In the example i give, the problem exist with the vcd provider. For the both problem come from api vcloud director.
Could you elaborate a bit? Does the eject_force
not work in vcd_inserted_media
for you?
Yes, It's not working with resource vcd_inserted_media
and eject_force
to true, you can see in example step describe above.
Hello :) Any update about this issue?
I can't reproduce the issue. Here is what I did
resource "vcd_network_routed" "TestAccVcdVAppVmNetForInsert" {
name = "TestAccVcdVAppVmNetForInsert"
org = "datacloud"
vdc = "nsxt-vdc-datacloud"
edge_gateway = "nsxt-gw-datacloud"
gateway = "10.10.102.1"
static_ip_pool {
start_address = "10.10.102.2"
end_address = "10.10.102.254"
}
}
resource "vcd_vapp" "TestAccVcdVAppForInsert" {
name = "TestAccVcdVAppForInsert"
org = "datacloud"
vdc = "nsxt-vdc-datacloud"
}
resource "vcd_vapp_org_network" "vappNetwork1" {
org = "datacloud"
vdc = "nsxt-vdc-datacloud"
vapp_name = vcd_vapp.TestAccVcdVAppForInsert.name
org_network_name = vcd_network_routed.TestAccVcdVAppVmNetForInsert.name
}
resource "vcd_vapp_vm" "TestAccVcdVAppVmForInsert" {
org = "datacloud"
vdc = "nsxt-vdc-datacloud"
vapp_name = vcd_vapp.TestAccVcdVAppForInsert.name
name = "TestAccVcdVAppVmForInsert"
catalog_name = "cat-datacloud"
template_name = "photon-hw11"
memory = 1024
cpus = 1
power_on = "false"
network {
type = "org"
name = vcd_vapp_org_network.vappNetwork1.org_network_name
ip_allocation_mode = "POOL"
}
}
resource "vcd_catalog_media" "TestAccVcdCatalogMediaBasicForInsert" {
org = "datacloud"
catalog = "cat-datacloud-nsxt-backed"
name = "TestAccVcdCatalogMediaBasicForInsert"
description = "TestAccVcdCatalogMediaBasicDescriptionForInsert"
media_path = "../terraform-provider-vcd/test-resources/test.iso"
upload_piece_size = 5
show_upload_progress = "true"
}
resource "vcd_inserted_media" "TestAccVcdMediaInsertBasic" {
org = "datacloud"
vdc = "nsxt-vdc-datacloud"
catalog = "cat-datacloud-nsxt-backed"
name = "TestAccVcdCatalogMediaBasicForInsert"
vapp_name = vcd_vapp.TestAccVcdVAppForInsert.name
vm_name = vcd_vapp_vm.TestAccVcdVAppVmForInsert.name
depends_on = [vcd_vapp_vm.TestAccVcdVAppVmForInsert, vcd_catalog_media.TestAccVcdCatalogMediaBasicForInsert]
eject_force = "true"
}
After applying all and checking that the inserted media was in the VM as a "CD", I destroyed the inserted media resource
terraform destroy -target=vcd_inserted_media.TestAccVcdMediaInsertBasic
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
vcd_inserted_media.TestAccVcdMediaInsertBasic: Destroying... [id=TestAccVcdVAppForInsert_TestAccVcdVAppVmForInsert_TestAccVcdCatalogMediaBasicForInsert]
vcd_inserted_media.TestAccVcdMediaInsertBasic: Destruction complete after 10s
Destroy complete! Resources: 1 destroyed.
The inserted media was removed from the VM, and I didn't see any waiting tasks in the UI.
We try to recreate the bug on cloudavenue, with provider vcd 3.10.0 and the version of the vcd api on cloudavenue is 37.1.
resource "vcd_inserted_media" "TestAccVcdMediaInsertBasic" {
org = "XXXX"
vdc = "XXXX"
catalog = "XXXXX"
name = "XXXXXX"
vapp_name = "XXXXX"
vm_name = "XXXXX"
eject_force = true
}
We create the ressource then when we try to delete it on the UI, there is a task still waiting for an human interaction
We searched what is respond by the api, it seems that the status of the task is queued
then running
then exceptedAction
When we are searching on the code of vcloud director
https://github.com/vmware/go-vcloud-director/blob/main/govcd/ejecttask.go#L53-59
There is an issue with theses lines which conduct to a manual action at the end.
If you can't reproduce the issue in terraform-provider-vcd
, there is little we can do.
i use the terraform-provider-vcd
in version 3.10 to do this test
Did you try using the script I used above? If not, please provide a complete script that can reproduce the case. And if it does, please add the logs that show the operation being performed.
resource "vcd_inserted_media" "TestAccVcdMediaInsertBasic" {
org = "XXXX"
vdc = "XXXX"
catalog = "XXXXX"
name = "XXXXXX"
vapp_name = "XXXXX"
vm_name = "XXXXX"
eject_force = true
}
i create and delete this ressource arround 40 times and it succeed to delete it without interaction on UI 6 times. Could you try to play ur scripts multiple times in a row to see if the bug is happening
Describe the bug
When we try to destroy the resource vcd_inserted_media we need to do a human intervention to answer Yes to force the ejection. But on Terraform side the intervention seems to be ok
However side UI vCloud Director, you need to make an action:
And give a answer normally manage by the option eject_force.
Reproduction steps
Expected behavior
The attribute eject_force (to true by default) bypass the human intervention.
Additional context
On Api vcloud director 37.0