vatesfr/terraform-provider-xenorchestra

destroy issue

Closed this issue · 6 comments

Hi,

i can't destroy the applied vm, terraform destroy command gives the next error:

_xenorchestra_vm.foobar: Destroying... [id=61884bf6-d2c1-d0de-4dc4-fb6537d72930] 
xenorchestra_vm.foobar: Still destroying... [id=61884bf6-d2c1-d0de-4dc4-fb6537d72930, 10s elapsed]     
│ Error: json: cannot unmarshal bool into Go value of type []interface {}_│

If I try destroy again, it works, but always fail on first attempt.

What details should I share to help the debug?

@dyipon was that all of the error output you received? It would be helpful if you could share your terraform code and provide all of the output of your command (assuming there is more).

This appears to be an issue with newer versions of Xen orchestra. I typically run the provider acceptance tests against two deployments: one that is close to latest xen orchestra (currently 5.93.0) and 5.71.2.

Running any of the acceptance tests against the 5.93.0 XO results in the error mentioned above, while running the same test against 5.71.2 works. It seems the vm.delete RPC call has changed its return type to a boolean value.

The following change gets the tests to pass again, but this would cause versions prior to this change to break

ddelnano@ddelnano-desktop:~/go/src/github.com/ddelnano/terraform-provider-xenorchestra$ git diff
diff --git a/client/vm.go b/client/vm.go
index 8104ba0..f58bb7f 100644
--- a/client/vm.go
+++ b/client/vm.go
@@ -416,7 +416,7 @@ func (c *Client) DeleteVm(id string) error {
        params := map[string]interface{}{
                "id": id,
        }
-       var reply []interface{}
+       var reply bool
        return c.Call("vm.delete", params, &reply)
 }

ddelnano@ddelnano-desktop:~/go/src/github.com/ddelnano/terraform-provider-xenorchestra$ TEST=TestAccXenorchestraVm_createAndPlanWithNonExistantVm make testacc

[ ... ]

=== RUN   TestAccXenorchestraVm_createAndPlanWithNonExistantVm
=== PAUSE TestAccXenorchestraVm_createAndPlanWithNonExistantVm
=== CONT  TestAccXenorchestraVm_createAndPlanWithNonExistantVm
--- PASS: TestAccXenorchestraVm_createAndPlanWithNonExistantVm (110.13s)
PASS
[DEBUG] Running sweeper
ok      github.com/ddelnano/terraform-provider-xenorchestra/xoa 130.734s
testing: warning: no tests to run
PASS
ok      github.com/ddelnano/terraform-provider-xenorchestra/xoa/internal        0.013s [no tests to run]

I need to further investigate when this breaking change was made to see if we can handle both cases.

I believe vatesfr/xen-orchestra@ed09608 could have caused this behavior change.

This will be fixed in v0.23.2, which should be released in the next few days.

This will be released today! Apologies for the delay.