hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

Packer 1.5.1 and "panic: interface conversion: interface {} is string, not uint64" error #8533

Closed ruzickap closed 4 years ago

ruzickap commented 4 years ago

Overview of the Issue

I'm trying to build my image using the latest Packer. If I use the packer version 1.4.x the image is successfully built, but Packer 1.5.x is giving me this error:

2019/12/23 00:01:11 [INFO] (telemetry) Starting post-processor vagrant
==> qemu: Running post-processor: vagrant
==> qemu (vagrant): Creating Vagrant box for 'libvirt' provider
    qemu (vagrant): Copying from artifact: windows-10-enterprise-x64-eval-qemu/windows-10-enterprise-x64-eval
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: panic: interface conversion: interface {} is string, not uint64
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: 
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: goroutine 219 [running]:
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/post-processor/vagrant.(*LibVirtProvider).Process(0x6ee3e90, 0x4815640, 0xc0004b0c00, 0x48156a0, 0xc00000c2c0, 0xc000056640, 0x40, 0x0, 0xc000147858, 0x42d681, ...)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /Users/mmarsh/Projects/packer/post-processor/vagrant/libvirt.go:31 +0x927
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/post-processor/vagrant.(*PostProcessor).PostProcessProvider(0xc00057c0f8, 0x410880b, 0x7, 0x47c4200, 0x6ee3e90, 0x4815640, 0xc0004b0c00, 0x48156a0, 0xc00000c2c0, 0x0, ...)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /Users/mmarsh/Projects/packer/post-processor/vagrant/post-processor.go:126 +0x5a7
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/post-processor/vagrant.(*PostProcessor).PostProcess(0xc00057c0f8, 0x47fa500, 0xc0000dc040, 0x4815640, 0xc0004b0c00, 0x48156a0, 0xc00000c2c0, 0x1, 0x203000, 0x28, ...)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /Users/mmarsh/Projects/packer/post-processor/vagrant/post-processor.go:185 +0x11e
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/packer/rpc.(*PostProcessorServer).PostProcess(0xc00041e0c0, 0x1, 0xc0000900b0, 0x0, 0x0)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /Users/mmarsh/Projects/packer/packer/rpc/post_processor.go:109 +0x277
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: reflect.Value.call(0xc00009a600, 0xc00000e0b8, 0x13, 0x41034fe, 0x4, 0xc00017bf18, 0x3, 0x3, 0x0, 0x405400, ...)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /usr/local/go/src/reflect/value.go:460 +0x5f6
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: reflect.Value.Call(0xc00009a600, 0xc00000e0b8, 0x13, 0xc00019bf18, 0x3, 0x3, 0xc000024000, 0xc000050220, 0xc)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /usr/local/go/src/reflect/value.go:321 +0xb4
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: net/rpc.(*service).call(0xc00041e540, 0xc00011c0a0, 0xc0003aa070, 0xc0003aa080, 0xc0003ca300, 0xc00000c440, 0x34cc100, 0xc000050240, 0x18a, 0x3373dc0, ...)
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /usr/local/go/src/net/rpc/server.go:377 +0x16f
2019/12/23 00:02:23 packer-post-processor-vagrant plugin: created by net/rpc.(*Server).ServeCodec
2019/12/23 00:02:23 packer-post-processor-vagrant plugin:       /usr/local/go/src/net/rpc/server.go:474 +0x42b
2019/12/23 00:02:23 [INFO] (telemetry) ending vagrant
2019/12/23 00:02:23 /usr/local/bin/packer: plugin process exited
2019/12/23 00:02:23 Deleting original artifact for build 'qemu'

* Post-processor failed: unexpected EOF
Build 'qemu' errored: 1 error(s) occurred:

* Post-processor failed: unexpected EOF
2019/12/23 00:02:24 machine readable: error-count []string{"1"}

==> Some builds didn't complete successfully and had errors:
--> qemu: 1 error(s) occurred:

* Post-processor failed: unexpected EOF

==> Builds finished but no artifacts were created.
==> Some builds didn't complete successfully and had errors:
2019/12/23 00:02:24 machine readable: qemu,error []string{"1 error(s) occurred:\n\n* Post-processor failed: unexpected EOF"}

* Post-processor failed: unexpected EOF
==> Builds finished but no artifacts were created.
2019/12/23 00:02:24 [INFO] (telemetry) Finalizing.
2019/12/23 00:02:25 waiting for all plugin processes to complete...
2019/12/23 00:02:25 /usr/local/bin/packer: plugin process exited
2019/12/23 00:02:25 /usr/local/bin/packer: plugin process exited
2019/12/23 00:02:25 /usr/local/bin/packer: plugin process exited
2019/12/23 00:02:25 /usr/local/bin/packer: plugin process exited

Reproduction Steps

git clone https://github.com/ruzickap/packer-templates.git
cd packer-templates
wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso

NAME=windows-10-enterprise-x64-eval WINDOWS_VERSION=10 VIRTIO_WIN_ISO=virtio-win.iso ISO_CHECKSUM=ab4862ba7d1644c27f27516d24cb21e6b39234eb3301e5f1fb365a78b22f79b3 ISO_URL=https://software-download.microsoft.com/download/pr/18362.30.190401-1528.19h1_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso PACKER_IMAGES_OUTPUT_DIR=/var/tmp/ TMPDIR=/var/tmp/ packer build -only=qemu windows.json

Packer version

Packer v1.5.1 (this issue doesn't happen in Packer version 1.4.x)

Simplified Packer Buildfile

https://github.com/ruzickap/packer-templates/blob/2a68709fa81fd6f270151182e5b4e789937cd434/windows.json

Operating system and Environment details

Fedora 31 (x86_64)

Log Fragments and crash.log files

Full log for Packer 1.5.1: https://pastebin.com/iFBGti7R Full log for Packer 1.4.3 (working): https://pastebin.com/cYWVQJL9

jhalfmoon commented 4 years ago

+1 On Arch Linux.

PatrickLang commented 4 years ago

+1 on Ubuntu 18.04.3 LTS, Packer 1.5.1

Does not occur on Packer 1.4.2 on Windows with hyperv-iso builder but I have not tested 1.5.1 with hyperv-iso yet.

Logs are same:

==> qemu: Running post-processor: vagrant
==> qemu (vagrant): Creating Vagrant box for 'libvirt' provider
    qemu (vagrant): Copying from artifact: windows_2019-qemu/WindowsServer2019
Build 'qemu' errored: 1 error(s) occurred:
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: panic: interface conversion: interface {} is string, not uint64

2019/12/28 00:05:41 packer-post-processor-vagrant plugin: 
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: goroutine 229 [running]:
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/post-processor/vagrant.(*LibVirtProvider).Process(0x6ee3e90, 0x4815640, 0xc0002600c0, 0x48156a0, 0xc00000c0c0, 0xc00055a3a0, 0x14, 0x0, 0xc00021f858, 0x42d681, ...)
* Post-processor failed: unexpected EOF
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /Users/mmarsh/Projects/packer/post-processor/vagrant/libvirt.go:31 +0x927
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/post-processor/vagrant.(*PostProcessor).PostProcessProvider(0xc00000e0e8, 0x410880b, 0x7, 0x47c4200, 0x6ee3e90, 0x4815640, 0xc0002600c0, 0x48156a0, 0xc00000c0c0, 0x0, ...)
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /Users/mmarsh/Projects/packer/post-processor/vagrant/post-processor.go:126 +0x5a7
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/post-processor/vagrant.(*PostProcessor).PostProcess(0xc00000e0e8, 0x47fa500, 0xc0000adac0, 0x4815640, 0xc0002600c0, 0x48156a0, 0xc00000c0c0, 0x1, 0x203000, 0x28, ...)
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /Users/mmarsh/Projects/packer/post-processor/vagrant/post-processor.go:185 +0x11e
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: github.com/hashicorp/packer/packer/rpc.(*PostProcessorServer).PostProcess(0xc0000ac080, 0x1, 0xc0004e00a0, 0x0, 0x0)
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /Users/mmarsh/Projects/packer/packer/rpc/post_processor.go:109 +0x277
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: reflect.Value.call(0xc0000e2840, 0xc00000e730, 0x13, 0x41034fe, 0x4, 0xc0000b5f18, 0x3, 0x3, 0x200, 0x6ecaf38, ...)
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /usr/local/go/src/reflect/value.go:460 +0x5f6
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: reflect.Value.Call(0xc0000e2840, 0xc00000e730, 0x13, 0xc000460f18, 0x3, 0x3, 0xc00055e020, 0x7f0766289210, 0x1)
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /usr/local/go/src/reflect/value.go:321 +0xb4
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: net/rpc.(*service).call(0xc0000ac0c0, 0xc00041a1e0, 0xc000412290, 0xc0004122a0, 0xc000414400, 0xc0002a41a0, 0x34cc100, 0xc00055e120, 0x18a, 0x3373dc0, ...)
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /usr/local/go/src/net/rpc/server.go:377 +0x16f
2019/12/28 00:05:41 packer-post-processor-vagrant plugin: created by net/rpc.(*Server).ServeCodec
2019/12/28 00:05:41 packer-post-processor-vagrant plugin:   /usr/local/go/src/net/rpc/server.go:474 +0x42b
2019/12/28 00:05:41 [INFO] (telemetry) ending vagrant
2019/12/28 00:05:41 /usr/local/bin/packer: plugin process exited
2019/12/28 00:05:41 Deleting original artifact for build 'qemu'

* Post-processor failed: unexpected EOF
2019/12/28 00:05:42 machine readable: error-count []string{"1"}

==> Some builds didn't complete successfully and had errors:
2019/12/28 00:05:42 machine readable: qemu,error []string{"1 error(s) occurred:\n\n* Post-processor failed: unexpected EOF"}

* Post-processor failed: unexpected EOF
==> Builds finished but no artifacts were created.
==> Some builds didn't complete successfully and had errors:
--> qemu: 1 error(s) occurred:

* Post-processor failed: unexpected EOF

==> Builds finished but no artifacts were created.
2019/12/28 00:05:42 [INFO] (telemetry) Finalizing.
2019/12/28 00:05:43 waiting for all plugin processes to complete...
2019/12/28 00:05:43 /usr/local/bin/packer: plugin process exited
2019/12/28 00:05:43 /usr/local/bin/packer: plugin process exited
2019/12/28 00:05:43 /usr/local/bin/packer: plugin process exited
2019/12/28 00:05:43 /usr/local/bin/packer: plugin process exited
2019/12/28 00:05:43 /usr/local/bin/packer: plugin process exited

Packer file: https://github.com/StefanScherer/packer-windows/blob/my/windows_2019.json

@StefanScherer - have you seen this on any other builders you're using?

PatrickLang commented 4 years ago

well, there's definitely a type mismatch between the builder & postprocessor:

The artifact bag is filled out here: https://github.com/hashicorp/packer/blob/0785c2f6fca9c22bf25528e0176042799dd79df9/builder/qemu/builder.go#L730

Using string values such as 40960M provided here: https://github.com/hashicorp/packer/blob/0785c2f6fca9c22bf25528e0176042799dd79df9/builder/qemu/builder.go#L366

Then the post-processor tries to type assert it to string: https://github.com/hashicorp/packer/blob/e4c2216642ef4e34b8d21d88c6c947222bfc131b/post-processor/vagrant/libvirt.go#L31

PatrickLang commented 4 years ago

Testing a fix :)

StefanScherer commented 4 years ago

@PatrickLang I ran a hyperv-iso packer build of a Windows 10 Home Insider machine with Packer 1.5.1 and it worked fine. I saw your PR fixing the libvirt postprocessor 👍

v4n6 commented 4 years ago

I fixed this issue ca. a week ago. I just had no time to create a PR. Then I saw, that it was already fixed by Patrick. When I was about to reject my changes and apply Patrick's fix, I realized that we provided two different solutions. After some consideration I decided to create another PR for the same issue. To my mind, it's all about finding a better solution. So, better two PRs than none ;).

This PR fixes qemu builder not the libvirt post-processor. I consider "DiskSize" artifact attribute returned by qemu builder as a part of its public interface. Leaving it as a string introduces backward incompatible change and breaks libvirt post-processor and potentially other custom functionality that uses this attribute. Hence, this fix leaves the "disk_size" configuration property intact (string suitable for qemu) and changes "DiskSize" artifact attribute back to unit64. This way, no other code changes are required in post processors and no another parsing and validation of DiskSize string is necessary in post-processors.

PatrickLang commented 4 years ago

thanks @sergeymorozov . I'm ok with either approach.

PatrickLang commented 4 years ago

Here's the change to the DiskSize type: https://github.com/hashicorp/packer/pull/7546/files . Looks like it was intentional for 1.5.x

PatrickLang commented 4 years ago

/assign @SwampDragons cc @kondor6c

What do you two think since you changed the type & reviewed it?

rgl commented 4 years ago

Oh I've also fixed this in https://github.com/hashicorp/packer/pull/8567... now we have two choices.

SwampDragons commented 4 years ago

Hi, thanks for your patience! I was on vacation and only just returned. I'll take a look at the proposed fixes and choose one today.

PatrickLang commented 4 years ago

3 choices :) https://github.com/hashicorp/packer/pull/8544 https://github.com/hashicorp/packer/pull/8553 https://github.com/hashicorp/packer/pull/8567

SwampDragons commented 4 years ago

Closed in #8567 :)

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.