Closed fsdrw08 closed 4 months ago
Hi there,
v1.2.0 not able to create vhd, after terraform apply, command output shows resource added, but there is no vhd create actually/
terraform apply
Terraform v1.6.6
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
2024-02-02T17:14:06.187+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout= | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:81 char:30 | + if ($vhdPath -and Test-Path $($vhdPath.FullName)) { | + ~ | You must provide a value expression following the '-and' operator. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:81 char:31 | + if ($vhdPath -and Test-Path $($vhdPath.FullName)) { | + ~~~~~~~~~ | Unexpected token 'Test-Path' in expression or statement. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:81 char:31 | + if ($vhdPath -and Test-Path $($vhdPath.FullName)) { | + ~~~~~~~~~ | Missing closing ')' after expression in 'if' statement. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:70 char:27 | + get-item *.7z | % { | + ~ | Missing closing '}' in statement block or type definition. | At C:\Users\root\AppData\Local 2024-02-02T17:14:06.190+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout= | \Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:40 char:13 | + process { | + ~ | Missing closing '}' in statement block or type definition. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:33 char:27 | + function Expand-Downloads { | + ~ | Missing closing '}' in statement block or type definition. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:81 char:61 | + if ($vhdPath -and Test-Path $($vhdPath.FullName)) { | + ~ | Unexpected token ')' in expression or statement. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:83 char:6 | + } else { | + ~~~~ | Unexpected token 'else' in expression or statement. | At C:\Users\root\AppData\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:89 char:9 | + } | + ~ | Unexpected token '}' in expression or statement. | At C:\Users\root\AppDat 2024-02-02T17:14:06.191+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout= | a\Local\Temp\shell-terraform-2bnyfas1R7OMWjaw0JeXU00Qw2W.ps1:106 char:30 | + if ($vhdPath -and Test-Path $($vhdPath.FullName)) { | + ~ | You must provide a value expression following the '-and' operator. | Not all parse errors were reported. Correct the reported errors and try again. | + CategoryInfo : ParserError: (:) [], ParseException | + FullyQualifiedErrorId : ExpectedValueExpression 2024-02-02T17:14:06.545+0800 [INFO] provider.terraform-provider-hyperv_1.2.0.exe: [hyperv][create] created hyperv vhd: &schema.ResourceData{schema:map[string]*schema.Schema{"block_size":(*schema.Schema)(0xc0003983c0), "exists":(*schema.Schema)(0xc000398780), "logical_sector_size":(*schema.Schema)(0xc000398500), "parent_path":(*schema.Schema)(0xc000398140), "path":(*schema.Schema)(0xc000397a40), "physical_sector_size":(*schema.Schema)(0xc000398640), "size":(*schema.Schema)(0xc000398280), "source":(*schema.Schema)(0xc000397b80), "source_disk":(*schema.Schema)(0xc000397e00), "source_vm":(*schema.Schema)(0xc000397cc0), "vhd_type":(*schema.Schema)(0xc000398000)}, config:(*terraform.ResourceConfig)(nil), state:(*terraform.InstanceState)(0xc0002cb5f0), diff:(*terraform.InstanceDiff)(0xc000411b00), meta:map[string]interface {}(nil), timeouts:(*schema.ResourceTimeout)(0xc00048bad0), providerMeta:cty.Value{ty:cty.Type{typeImpl:cty.typeObject{typeImplSigil:cty.typeImplSigil{}, AttrTypes:map[string]cty.Type{}}}, v:interface {}(nil)}, multiReader:(*schema.MultiLevelFieldReader)(0xc00010f3c0), setWriter:(*schema.MapFieldWriter)(0xc00041d110), newState:(*terraform.InstanceState)(0xc0001b0b60), partial:false, once:sync.Once{done:0x1, m:sync.Mutex{state:0, sema:0x0}}, isNew:true, panicOnError:false}: timestamp="2024-02-02T17:14:06.545+0800" 2024-02-02T17:14:06.546+0800 [INFO] provider.terraform-provider-hyperv_1.2.0.exe: [hyperv][read] reading hyperv vhd: &schema.ResourceData{schema:map[string]*schema.Schema{"block_size":(*schema.Schema)(0xc0003983c0), "exists":(*schema.Schema)(0xc000398780), "logical_sector_size":(*schema.Schema)(0xc000398500), "parent_path":(*schema.Schema)(0xc000398140), "path":(*schema.Schema)(0xc000397a40), "physical_sector_size":(*schema.Schema)(0xc000398640), "size":(*schema.Schema)(0xc000398280), "source":(*schema.Schema)(0xc000397b80), "source_disk":(*schema.Schema)(0xc000397e00), "source_vm":(*schema.Schema)(0xc000397cc0), "vhd_type":(*schema.Schema)(0xc000398000)}, config:(*terraform.ResourceConfig)(nil), state:(*terraform.InstanceState)(0xc0002cb5f0), diff:(*terraform.InstanceDiff)(0xc000411b00), meta:map[string]interface {}(nil), timeouts:(*schema.ResourceTimeout)(0xc00048bad0), providerMeta:cty.Value{ty:cty.Type{typeImpl:cty.typeObject{typeImplSigil:cty.typeImplSigil{}, AttrTypes:map[string]cty.Type{}}}, v:interface {}(nil)}, multiReader:(*schema.MultiLevelFieldReader)(0xc00010f3c0), setWriter:(*schema.MapFieldWriter)(0xc00041d110), newState:(*terraform.InstanceState)(0xc0001b0b60), partial:false, once:sync.Once{done:0x1, m:sync.Mutex{state:0, sema:0x0}}, isNew:true, panicOnError:false}: timestamp="2024-02-02T17:14:06.545+0800" 2024-02-02T17:14:06.547+0800 [DEBUG] provider.terraform-provider-hyperv_1.2.0.exe: Running script with result: $ErrorActionPreference = 'Stop' $path='C:/ProgramData/Microsoft/Windows/Virtual Hard Disks/Dev-CentOS/Dev-CentOS.vhdx' $vhdObject = $null if (Test-Path $path) { $vhdObject = Get-VHD -path $path | %{ @{ Path=$_.Path; BlockSize=$_.BlockSize; LogicalSectorSize=$_.LogicalSectorSize; PhysicalSectorSize=$_.PhysicalSectorSize; ParentPath=$_.ParentPath; FileSize=$_.FileSize; Size=$_.Size; MinimumSize=$_.MinimumSize; Attached=$_.Attached; DiskNumber=$_.DiskNumber; Number=$_.Number; FragmentationPercentage=$_.FragmentationPercentage; Alignment=$_.Alignment; DiskIdentifier=$_.DiskIdentifier; VhdType=$_.VhdType; VhdFormat=$_.VhdFormat; }} } if ($vhdObject){ $vhd = ConvertTo-Json -InputObject $vhdObject $vhd } else { "{}" }: timestamp="2024-02-02T17:14:06.545+0800" 2024-02-02T17:14:06.551+0800 [DEBUG] provider.terraform-provider-hyperv_1.2.0.exe: Uploading shell wrapper for command from [C:\Users\WindomWu\AppData\Local\Temp\shell-terraform-2bnygCTk3U7InnPUCTut9zMSkQE.ps13294281615] to [$env:TEMP\shell-terraform-2bnygCTk3U7InnPUCTut9zMSkQE.ps1]: timestamp="2024-02-02T17:14:06.547+0800" hyperv_vhd.name: Still creating... [10s elapsed] 2024-02-02T17:14:06.927+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout=C:\Users\root\AppData\Local\Temp\terraform-2bnygIZBfINtFmW3CH1ijY8aWlL 2024-02-02T17:14:07.295+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout=C:\Users\root\AppData\Local\Temp\shell-terraform-2bnygCTk3U7InnPUCTut9zMSkQE.ps1 2024-02-02T17:14:07.807+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout=C:\Users\root\AppData\Local\Temp\shell-terraform-2bnygCTk3U7InnPUCTut9zMSkQE.ps1 2024-02-02T17:14:08.190+0800 [DEBUG] provider.terraform-provider-hyperv_1.2.0.exe: Building elevated command wrapper for: C:\Users\root\AppData\Local\Temp\shell-terraform-2bnygCTk3U7InnPUCTut9zMSkQE.ps1: timestamp="2024-02-02T17:14:08.190+0800" 2024-02-02T17:14:08.212+0800 [DEBUG] provider.terraform-provider-hyperv_1.2.0.exe: Uploading shell wrapper for command from [C:\Users\WindomWu\AppData\Local\Temp\elevated-shell-terraform-2bnygZPD88ovP1iBOZfjUsdEWmI.ps13950962599] to [$env:TEMP\elevated-shell-terraform-2bnygZPD88ovP1iBOZfjUsdEWmI.ps1]: timestamp="2024-02-02T17:14:08.211+0800" 2024-02-02T17:14:08.607+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout=C:\Users\root\AppData\Local\Temp\terraform-2bnygS56ghbxBz0wxyna47HlQvg 2024-02-02T17:14:08.985+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout=C:\Users\root\AppData\Local\Temp\elevated-shell-terraform-2bnygZPD88ovP1iBOZfjUsdEWmI.ps1 2024-02-02T17:14:09.511+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout=C:\Users\root\AppData\Local\Temp\elevated-shell-terraform-2bnygZPD88ovP1iBOZfjUsdEWmI.ps1 2024-02-02T17:14:11.021+0800 [WARN] unexpected data: registry.terraform.io/taliesins/hyperv:stdout={} 2024-02-02T17:14:11.404+0800 [INFO] provider.terraform-provider-hyperv_1.2.0.exe: [hyperv][read] retrieved vhd: {Path: BlockSize:0 LogicalSectorSize:0 PhysicalSectorSize:0 ParentPath: FileSize:0 Size:0 MinimumSize:0 Attached:false DiskNumber:0 Number:0 FragmentationPercentage:0 Alignment:0 DiskIdentifier: VhdType:Unknown VhdFormat:Unknown}: timestamp="2024-02-02T17:14:11.404+0800" 2024-02-02T17:14:11.405+0800 [WARN] Provider "provider[\"registry.terraform.io/taliesins/hyperv\"]" produced an unexpected new value for hyperv_vhd.name, but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations: - .path: was cty.StringVal("C:/ProgramData/Microsoft/Windows/Virtual Hard Disks/Dev-CentOS/Dev-CentOS.vhdx"), but now cty.StringVal("") - .vhd_type: was cty.StringVal("Dynamic"), but now cty.StringVal("Unknown") 2024-02-02T17:14:11.405+0800 [INFO] provider.terraform-provider-hyperv_1.2.0.exe: [hyperv][read] unable to retrieved vhd: C:/ProgramData/Microsoft/Windows/Virtual Hard Disks/Dev-CentOS/Dev-CentOS.vhdx: timestamp="2024-02-02T17:14:11.404+0800" hyperv_vhd.name: Creation complete after 14s [id=C:/ProgramData/Microsoft/Windows/Virtual Hard Disks/Dev-CentOS/Dev-CentOS.vhdx]
If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.
crash.log
What should have happened?
What actually happened?
Please list the steps required to reproduce the issue, for example:
main.tf
terraform { required_providers { hyperv = { source = "taliesins/hyperv" version = ">=1.2.0" } } } provider "hyperv" { host = var.hyperv.host port = var.hyperv.port user = var.hyperv.user password = var.hyperv.password https = true insecure = true use_ntlm = true # tls_server_name = "" # cacert_path = "" # cert_path = "" # key_path = "" script_path = "C:/Temp/terraform_%RAND%.cmd" timeout = "30s" }
resource "hyperv_vhd" "name" { path = join("/", [ var.vhd_dir, "${var.vm_name}${local.count}", join("", ["${var.vm_name}", ".vhdx"]) ] ) source = var.source_disk }
2. `terraform apply`
it may cause by this change https://github.com/taliesins/terraform-provider-hyperv/commit/1a94deb4371cf85d37551bc35e119f185ecbcc23
I had create a PR for this bug, please approve and merge it, thanks @taliesins
Hi there,
v1.2.0 not able to create vhd, after
terraform apply
, command output shows resource added, but there is no vhd create actually/Terraform Version
Terraform v1.6.6
Affected Resource(s)
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Debug Output
Panic Output
If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the
crash.log
.Expected Behavior
What should have happened?
Actual Behavior
What actually happened?
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
main.tf
resource "hyperv_vhd" "name" { path = join("/", [ var.vhd_dir, "${var.vm_name}${local.count}", join("", ["${var.vm_name}", ".vhdx"]) ] ) source = var.source_disk }