Repository navigation
Description
Provider: scalecomputing/hypercore
Terraform version: 1.5.7
Provider version: 1.4.0 (also present on main 7cae1ca)
HyperCore: 9.8.5
Summary:
If a VM managed by hypercore_vm is deleted outside Terraform (HyperCore UI, another
tool), every subsequent terraform plan/apply fails with
terraform provider got an unexpected error during execution: VM not found: uuid=<uuid>.
The expected behaviour for a Terraform provider is to remove the resource from state on
Read, so the plan shows it will be created again. Today the only recovery is a manual
terraform state rm.
Reproduction:
resource "hypercore_vm" "r" {
name = "tfrepro"
vcpu = 1
memory = 512
affinity_strategy = {}
}terraform apply→ VM created.- Delete the VM in the HyperCore UI.
terraform plan→
Error: Unexpected error
with hypercore_vm.r, on main.tf line 8, in resource "hypercore_vm" "r":
terraform provider got an unexpected error during execution: VM not found:
uuid=300f0209-ed59-48c3-be4e-ccda26f7ecd4
Expected: hypercore_vm.r will be created.
Cause: HypercoreVMResource.Read calls utils.GetOneVM, which panics when
GET /rest/v1/VirDomain/<uuid> returns no records. HyperCore answers a missing UUID with
HTTP 200 and [], not 404. This is the platform's convention for every resource type
(also measured on VirDomainBlockDevice), so status-code checks cannot detect absence. No resource in the provider calls
resp.State.RemoveResource. With an empty ID, the same path requests
/rest/v1/VirDomain/ (every VM) and panics with multiple VMs found: uuid=.
hypercore_vm_power_state.Read has the same gap (GetOneVMWithError → error).
Suggested fix (tested locally against 9.8.5): in Read, if the ID is empty or the UUID
returns no record, call resp.State.RemoveResource(ctx) and return. Only an empty result
should mean "gone": network/HTTP errors must keep failing, otherwise a transient error
would make Terraform plan a duplicate VM.
// VMExists reports whether exactly one VM has this UUID. HyperCore answers a missing UUID
// with 200 and an empty list; other failures still panic in ListRecords.
func VMExists(uuid string, restClient RestClient) bool {
if uuid == "" {
return false
}
return len(restClient.ListRecords("/rest/v1/VirDomain/"+uuid, map[string]any{}, -1.0, false)) == 1
}// HypercoreVMResource.Read (and HypercoreVMPowerStateResource.Read)
if !utils.VMExists(vm_uuid, restClient) {
resp.State.RemoveResource(ctx)
return
}Other resources (hypercore_disk, hypercore_nic, snapshots, …) likely need the same
treatment, since the 200 [] convention is platform-wide; not checked individually.
Existence must be tested with a GET, not inferred from a DELETE. DELETE is not
consistent: a missing VirDomainBlockDevice → 400 "was not found", a missing
VirDomain → 500, and a RUNNING VirDomain → 400 "must be shut off to perform
this operation" (measured 2026-10-23, HyperCore 9.8.5). That last one is why the
provider's shutdown-before-delete in HypercoreVMResource.Delete is necessary.
Also affects tools that drive the provider programmatically (e.g. Crossplane's Upjet,
which refreshes before the first create): with this bug they cannot create a VM at all.
Activity
Drop a disk from state when it no longer exists (#112)
ddemlow commentedon Oct 23, 2026
Same bug in
hypercore_disk: Read errorsDisk not foundfor a disk deleted outside Terraform. With an empty ID it requests/rest/v1/VirDomainBlockDevice/and panics on the full list (250 records on the test cluster). Reproduced 2026-10-23 on HyperCore 9.8.5. The fix and an acceptance test (fails without the change, passes with it) are now in #116. Other resources (hypercore_nic, snapshots, …) still haven't been checked.