hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
94 stars 91 forks source link

CRASH when vsphere-iso is replacing an existing template #311

Closed DonBower closed 10 months ago

DonBower commented 11 months ago

Community Note

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

I have a Packer Script that uploads the result image to a Content Library. The first run, which has a unique name, will work without issue. When I re-run the script, without any changes, packer crashes.

Reproduction Steps

Build a packer script Run the packer script [run is successful] Run the packer script again [run will crash]

Packer version

From packer version

packer version
Packer v1.9.2

Simplified Packer Template

If the file is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

packer-iso "template"
...
  convert_to_template = false
  dynamic "content_library_destination" {
    for_each = local.isMain ? [1] : [1]
    content {
      name        = "my.template.0.1.0-rc"
      library     = "my content library"
      description = "Built by Packer..."
      ovf         = false
      destroy     = true
      skip_import = false
    }
  }
...

Operating system and Environment details

OS, Architecture, and any other information you can provide about the environment. Workstation: Windows 10 21h2, build 19044.3448 with Git-Bash git version 2.42.0.windows.2 vSphere Client version 7.0.3.01400

Log Fragments and crash.log files

per company policy, uploads are forbidden.

nywilken commented 10 months ago

Hi @DonBower thanks for reporting this issue. It may be related to https://github.com/hashicorp/packer-plugin-vsphere/issues/309. I'm moving this issue to the appropriate repository. We will try to take a look as soon as we can.

DonBower commented 10 months ago

What I find interesting about this latest attempt is it says "...Importing VM template rhel8-base-0.3.1-rc, when in fact the name of the template is rhel8-base-0.3.1-rc-vm and the content library name is rhel8-base-0.3.1-rc

==> vsphere-iso.template: Importing VM template rhel8-base-0.3.1-rc to Content Library 'Local Testing Library' as the item 'rhel8-base-0.3.1-rc' with the description 'Packer imported rhel8-base-0.3.1-rc-vm VM template'...
    vsphere-iso.template: Closing sessions ....
Build 'vsphere-iso.template' errored after 19 minutes 56 seconds: unexpected EOF

==> Wait completed after 19 minutes 56 seconds

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso.template: unexpected EOF

==> Builds finished but no artifacts were created.
panic: runtime error: invalid memory address or nil pointer dereference
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x118dd1d]
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: goroutine 212 [running]:
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/driver.(*VirtualMachineDriver).ImportToContentLibrary(0xc000af4460, {{0xc00015f140, 0x3c}, 0x0, {0x0, 0x0, 0x0}, {0xc00062e690, 0x24}, {0xc00074eaa0, ...}, ...})
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/driver/vm.go:945 +0x55d
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common.(*StepImportToContentLibrary).importVmTemplate(0xc000b9e048, 0xc0009fe000?)
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.go:208 +0x1dd
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common.(*StepImportToContentLibrary).Run(0xc000b9e048, {0x2459799?, 0xc000dd61c0?}, {0x29a3da8, 0xc000dcc600})
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/step_import_to_content_library.go:151 +0x2f4
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0xc000dcc6c0, {0x29a38d8, 0xc000dd61c0}, {0x29a3da8, 0xc000dcc600})
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-sdk@v0.4.0/multistep/basic_runner.go:73 +0x2f3
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso.(*Builder).Run(0xc0004f1000, {0x29a38d8, 0xc000dd61c0}, {0x29a64c8?, 0xc000dcc5d0}, {0x29846e0?, 0xc000647840})
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso/builder.go:164 +0x15c3
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*BuilderServer).Run(0xc00015c000, 0x1201f8?, 0xc0001201cc)
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       github.com/hashicorp/packer-plugin-sdk@v0.4.0/rpc/builder.go:120 +0x1e3
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: reflect.Value.call({0xc000142420?, 0xc00013e080?, 0x13?}, {0x2451a45, 0x4}, {0xc000d3cef8, 0x3, 0x3?})
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       reflect/value.go:556 +0x845
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: reflect.Value.Call({0xc000142420?, 0xc00013e080?, 0x0?}, {0xc000b23ef8, 0x3, 0x3})
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       reflect/value.go:339 +0xbf
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: net/rpc.(*service).call(0xc00015c040, 0x0?, 0x0?, 0xc000654050, 0xc000160180, 0x0?, {0x1f55520?, 0xc0001201c8?, 0x0?}, {0x1ed4f40, ...}, ...)
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       net/rpc/server.go:381 +0x226
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin: created by net/rpc.(*Server).ServeCodec
2023/10/17 20:56:08 packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64 plugin:       net/rpc/server.go:478 +0x3fe
2023/10/17 20:56:08 [INFO] (telemetry) ending vsphere-iso.template
2023/10/17 20:56:08 ui error: Build 'vsphere-iso.template' errored after 19 minutes 56 seconds: unexpected EOF
2023/10/17 20:56:08 /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.2.1_x5.0_linux_amd64: plugin process exited