hashicorp / packer

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

OSX/QEMU - panic: interface conversion: interface {} is nil, not []string #10441

Closed spuder closed 3 years ago

spuder commented 3 years ago

Packer 1.6.5
OSX 10.14

Overview

Packer crashes when building a QEMU image on OSX. The same packer config works fine on linux.

The meat of the error is:

==> Builds finished but no artifacts were created.
2021/01/04 10:16:22 packer-builder-qemu plugin: panic: interface conversion: interface {} is nil, not []string
2021/01/04 10:16:22 packer-builder-qemu plugin: 
2021/01/04 10:16:22 packer-builder-qemu plugin: goroutine 93 [running]:
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).getDeviceAndDriveArgs(0xc00011bf80, 0xc000a98300, 0x5e5bc60, 0xc000796150, 0x0, 0xc00031e100, 0x4, 0x0, 0x0, 0x0)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/builder/qemu/step_run.go:219 +0x1b25
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).getDefaultArgs(0xc00011bf80, 0xc000a98300, 0x5e5bc60, 0xc000796150, 0x3)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/builder/qemu/step_run.go:172 +0x8d7
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).getCommandArgs(0xc00011bf80, 0xc000a98300, 0x5e5bc60, 0xc000796150, 0x0, 0x0, 0xc000796158, 0xc000796270, 0x582a60b)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/builder/qemu/step_run.go:368 +0x4d
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).Run(0xc00011bf80, 0x5e5b060, 0xc000b05780, 0x5e5bc60, 0xc000796150, 0x0)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/builder/qemu/step_run.go:47 +0x37b
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/helper/multistep.(*BasicRunner).Run(0xc0007962d0, 0x5e5b060, 0xc000b05780, 0x5e5bc60, 0xc000796150)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/helper/multistep/basic_runner.go:70 +0x234
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*Builder).Run(0xc000a98300, 0x5e5b060, 0xc000b05780, 0x5e75f60, 0xc0005b5ec0, 0x5de9640, 0xc00011bf60, 0xc0003a7b60, 0xc0000869f8, 0xc0003a7bd0, ...)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/builder/qemu/builder.go:158 +0x11a2
2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/packer/rpc.(*BuilderServer).Run(0xc0007a0140, 0x1, 0xc0003806f0, 0x0, 0x0)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /home/circleci/project/packer/packer/rpc/builder.go:117 +0x1c4
2021/01/04 10:16:22 packer-builder-qemu plugin: reflect.Value.call(0xc0000869c0, 0xc00000e7d0, 0x13, 0x58203ee, 0x4, 0xc0003a7f08, 0x3, 0x3, 0x0, 0x0, ...)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /usr/local/go/src/reflect/value.go:475 +0x8c7
2021/01/04 10:16:22 packer-builder-qemu plugin: reflect.Value.Call(0xc0000869c0, 0xc00000e7d0, 0x13, 0xc0004cdf08, 0x3, 0x3, 0x0, 0x0, 0x0)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /usr/local/go/src/reflect/value.go:336 +0xb9
2021/01/04 10:16:22 packer-builder-qemu plugin: net/rpc.(*service).call(0xc0007a0180, 0xc0000cadc0, 0xc0000728f8, 0xc000072970, 0xc00038c380, 0xc00011a180, 0x49b7300, 0xc0003806ec, 0x18a, 0x48bb600, ...)
2021/01/04 10:16:22 packer-builder-qemu plugin:         /usr/local/go/src/net/rpc/server.go:377 +0x189
2021/01/04 10:16:22 packer-builder-qemu plugin: created by net/rpc.(*Server).ServeCodec
2021/01/04 10:16:22 packer-builder-qemu plugin:         /usr/local/go/src/net/rpc/server.go:474 +0x445
2021/01/04 10:16:22 [INFO] (telemetry) ending qemu
==> Wait completed after 3 seconds 69 milliseconds
2021/01/04 10:16:22 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2021/01/04 10:16:22 machine readable: ubuntu-18.04,error []string{"unexpected EOF"}

Steps to reproduce

PACKER_LOG=1 packer build -var headless=true -only=ubuntu-18.04 ubuntu.json

Packer config

```json { "builders": [ { "name": "ubuntu-18.04", "disk_discard": "unmap", "disk_image": true, "disk_interface": "virtio", "disk_size": "5120M", "http_directory": "http", "iso_checksum": "file:http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS", "iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img", "qemuargs": [ [ "-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/" ] ], "ssh_password": "packerpassword", "ssh_username": "packer", "type": "qemu", "disk_compression": true, "vm_name": "bionic-server-cloudimg-amd64-custom.qcow2", "headless": "{{ user `headless` }}" }, { "name": "ubuntu-20.04", "disk_discard": "unmap", "disk_image": true, "disk_interface": "virtio", "disk_size": "5120M", "http_directory": "http", "iso_checksum": "file:http://cloud-images.ubuntu.com/releases/focal/release/SHA256SUMS", "iso_url": "http://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img", "qemuargs": [ [ "-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/" ] ], "ssh_password": "packerpassword", "ssh_username": "packer", "ssh_handshake_attempts": 20, "type": "qemu", "memory": 1024, "disk_compression": true, "vm_name": "focal-server-cloudimg-amd64-custom.qcow2", "headless": "{{ user `headless` }}" } ], "provisioners": [ ], "post-processors": [ { "type": "manifest" } ], "variables": { "accelerator": "kvm", "headless": "false", "opennebula_addon_context": "5.10.0" } } ```

Logs

``` PACKER_LOG=1 packer build -var headless=true -only=ubuntu-18.04 ubuntu.json 2021/01/04 10:16:18 [INFO] Packer version: 1.6.5 [go1.15.3 darwin amd64] 2021/01/04 10:16:18 Checking 'PACKER_CONFIG' for a config file path 2021/01/04 10:16:18 'PACKER_CONFIG' not set; checking the default config file path 2021/01/04 10:16:18 Attempting to open config file: /Users/spencer.owen/.packerconfig 2021/01/04 10:16:18 [WARN] Config file doesn't exist: /Users/spencer.owen/.packerconfig 2021/01/04 10:16:18 Setting cache directory: /Users/spencer.owen/Resilio/packer/OpenNebula/ubuntu/packer_cache 2021/01/04 10:16:18 Creating plugin client for path: /usr/local/bin/packer 2021/01/04 10:16:18 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-qemu"} 2021/01/04 10:16:18 Waiting for RPC address for: /usr/local/bin/packer 2021/01/04 10:16:18 packer-builder-qemu plugin: [INFO] Packer version: 1.6.5 [go1.15.3 darwin amd64] 2021/01/04 10:16:18 packer-builder-qemu plugin: Checking 'PACKER_CONFIG' for a config file path 2021/01/04 10:16:18 packer-builder-qemu plugin: 'PACKER_CONFIG' not set; checking the default config file path 2021/01/04 10:16:18 packer-builder-qemu plugin: Attempting to open config file: /Users/spencer.owen/.packerconfig 2021/01/04 10:16:18 packer-builder-qemu plugin: [WARN] Config file doesn't exist: /Users/spencer.owen/.packerconfig 2021/01/04 10:16:18 packer-builder-qemu plugin: Setting cache directory: /Users/spencer.owen/Resilio/packer/OpenNebula/ubuntu/packer_cache 2021/01/04 10:16:18 packer-builder-qemu plugin: args: []string{"packer-builder-qemu"} 2021/01/04 10:16:18 packer-builder-qemu plugin: Plugin address: unix /var/folders/q4/rc1whsg538dcccrn5w3d9w0w0000gp/T/packer-plugin874672985 2021/01/04 10:16:18 packer-builder-qemu plugin: Waiting for connection... 2021/01/04 10:16:18 Received unix RPC address for /usr/local/bin/packer: addr is /var/folders/q4/rc1whsg538dcccrn5w3d9w0w0000gp/T/packer-plugin874672985 2021/01/04 10:16:18 packer-builder-qemu plugin: Serving a plugin connection... 2021/01/04 10:16:18 Creating plugin client for path: /usr/local/bin/packer 2021/01/04 10:16:18 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-post-processor-manifest"} 2021/01/04 10:16:18 Waiting for RPC address for: /usr/local/bin/packer 2021/01/04 10:16:18 packer-post-processor-manifest plugin: [INFO] Packer version: 1.6.5 [go1.15.3 darwin amd64] 2021/01/04 10:16:18 packer-post-processor-manifest plugin: Checking 'PACKER_CONFIG' for a config file path 2021/01/04 10:16:18 packer-post-processor-manifest plugin: 'PACKER_CONFIG' not set; checking the default config file path 2021/01/04 10:16:18 packer-post-processor-manifest plugin: Attempting to open config file: /Users/spencer.owen/.packerconfig 2021/01/04 10:16:18 packer-post-processor-manifest plugin: [WARN] Config file doesn't exist: /Users/spencer.owen/.packerconfig 2021/01/04 10:16:18 packer-post-processor-manifest plugin: Setting cache directory: /Users/spencer.owen/Resilio/packer/OpenNebula/ubuntu/packer_cache 2021/01/04 10:16:18 packer-post-processor-manifest plugin: args: []string{"packer-post-processor-manifest"} 2021/01/04 10:16:18 packer-post-processor-manifest plugin: Plugin address: unix /var/folders/q4/rc1whsg538dcccrn5w3d9w0w0000gp/T/packer-plugin204452077 2021/01/04 10:16:18 packer-post-processor-manifest plugin: Waiting for connection... 2021/01/04 10:16:18 Received unix RPC address for /usr/local/bin/packer: addr is /var/folders/q4/rc1whsg538dcccrn5w3d9w0w0000gp/T/packer-plugin204452077 2021/01/04 10:16:18 packer-post-processor-manifest plugin: Serving a plugin connection... 2021/01/04 10:16:18 Preparing build: ubuntu-18.04 2021/01/04 10:16:18 packer-builder-qemu plugin: use detected accelerator: tcg 2021/01/04 10:16:18 packer-builder-qemu plugin: MemorySize 0 is too small, using default: 512 2021/01/04 10:16:18 packer-builder-qemu plugin: CpuCount 0 too small, using default: 1 2021/01/04 10:16:19 Build debug mode: false 2021/01/04 10:16:19 Force build: false 2021/01/04 10:16:19 On error: ubuntu-18.04: output will be in this color. 2021/01/04 10:16:19 Waiting on builds to complete... 2021/01/04 10:16:19 Starting build run: ubuntu-18.04 2021/01/04 10:16:19 Running builder: qemu 2021/01/04 10:16:19 [INFO] (telemetry) Starting builder qemu 2021/01/04 10:16:19 packer-builder-qemu plugin: Qemu path: /usr/local/bin/qemu-system-x86_64, Qemu Image page: /usr/local/bin/qemu-img ==> ubuntu-18.04: Retrieving ISO 2021/01/04 10:16:19 packer-builder-qemu plugin: Acquiring lock for: http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img?checksum=sha256%3Af136639410c31008a49c57ea8963923773d0cafe2834c7e59a8dacd326c640f3 (/Users/spencer.owen/Resilio/packer/OpenNebula/ubuntu/packer_cache/8c972d51a2f4b69dab49df8d96cb34db133d3b05.iso.lock) ==> ubuntu-18.04: Trying http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img ==> ubuntu-18.04: Trying http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img?checksum=sha256%3Af136639410c31008a49c57ea8963923773d0cafe2834c7e59a8dacd326c640f3 2021/01/04 10:16:20 packer-builder-qemu plugin: Leaving retrieve loop for ISO 2021/01/04 10:16:20 packer-builder-qemu plugin: No floppy files specified. Floppy disk will not be made. 2021/01/04 10:16:20 packer-builder-qemu plugin: No CD files specified. CD disk will not be made. ==> ubuntu-18.04: http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img?checksum=sha256%3Af136639410c31008a49c57ea8963923773d0cafe2834c7e59a8dacd326c640f3 => /Users/spencer.owen/Resilio/packer/OpenNebula/ubuntu/packer_cache/8c972d51a2f4b69dab49df8d96cb34db133d3b05.iso ==> ubuntu-18.04: Copying hard drive... 2021/01/04 10:16:20 packer-builder-qemu plugin: Executing qemu-img: []string{"convert", "-O", "qcow2", "/Users/spencer.owen/Resilio/packer/OpenNebula/ubuntu/packer_cache/8c972d51a2f4b69dab49df8d96cb34db133d3b05.iso", "output-ubuntu-18.04/bionic-server-cloudimg-amd64-custom.qcow2"} 2021/01/04 10:16:22 packer-builder-qemu plugin: stdout: 2021/01/04 10:16:22 packer-builder-qemu plugin: stderr: ==> ubuntu-18.04: Resizing hard drive... 2021/01/04 10:16:22 packer-builder-qemu plugin: Executing qemu-img: []string{"resize", "-f", "qcow2", "output-ubuntu-18.04/bionic-server-cloudimg-amd64-custom.qcow2", "5120M"} 2021/01/04 10:16:22 packer-builder-qemu plugin: stdout: Image resized. 2021/01/04 10:16:22 packer-builder-qemu plugin: stderr: 2021/01/04 10:16:22 packer-builder-qemu plugin: Found available port: 8353 on IP: 0.0.0.0 ==> ubuntu-18.04: Starting HTTP server on port 8353 2021/01/04 10:16:22 packer-builder-qemu plugin: Looking for available communicator (SSH, WinRM, etc) port between 2222 and 4444 2021/01/04 10:16:22 packer-builder-qemu plugin: Found available port: 3890 on IP: 127.0.0.1 ==> ubuntu-18.04: Found port for communicator (SSH, WinRM, etc): 3890. 2021/01/04 10:16:22 packer-builder-qemu plugin: Looking for available port between 5900 and 6000 on 127.0.0.1 ==> ubuntu-18.04: Looking for available port between 5900 and 6000 on 127.0.0.1 2021/01/04 10:16:22 packer-builder-qemu plugin: Found available port: 5903 on IP: 127.0.0.1 2021/01/04 10:16:22 packer-builder-qemu plugin: Found available VNC port: 5903 on IP: 127.0.0.1 2021/01/04 10:16:22 packer-builder-qemu plugin: Qemu --version output: QEMU emulator version 5.1.0 2021/01/04 10:16:22 packer-builder-qemu plugin: Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers 2021/01/04 10:16:22 packer-builder-qemu plugin: Qemu version: 5.1.0 ==> ubuntu-18.04: Starting VM, booting disk image ubuntu-18.04: view the screen of the VM, connect via VNC without a password to ubuntu-18.04: vnc://127.0.0.1:3 2021/01/04 10:16:22 packer-builder-qemu plugin: Qemu Builder has no floppy files, not attaching a floppy. ubuntu-18.04: The VM will be run headless, without a GUI. If you want to ubuntu-18.04: view the screen of the VM, connect via VNC without a password to ubuntu-18.04: vnc://127.0.0.1:3 2021/01/04 10:16:22 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:5903: use of closed network connection 2021/01/04 10:16:22 packer-builder-qemu plugin: failed to unlock port lockfile: close tcp 127.0.0.1:3890: use of closed network connection Build 'ubuntu-18.04' errored after 3 seconds 68 milliseconds: unexpected EOF ==> Wait completed after 3 seconds 69 milliseconds ==> Some builds didn't complete successfully and had errors: --> ubuntu-18.04: unexpected EOF ==> Builds finished but no artifacts were created. 2021/01/04 10:16:22 packer-builder-qemu plugin: panic: interface conversion: interface {} is nil, not []string 2021/01/04 10:16:22 packer-builder-qemu plugin: 2021/01/04 10:16:22 packer-builder-qemu plugin: goroutine 93 [running]: 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).getDeviceAndDriveArgs(0xc00011bf80, 0xc000a98300, 0x5e5bc60, 0xc000796150, 0x0, 0xc00031e100, 0x4, 0x0, 0x0, 0x0) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/builder/qemu/step_run.go:219 +0x1b25 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).getDefaultArgs(0xc00011bf80, 0xc000a98300, 0x5e5bc60, 0xc000796150, 0x3) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/builder/qemu/step_run.go:172 +0x8d7 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).getCommandArgs(0xc00011bf80, 0xc000a98300, 0x5e5bc60, 0xc000796150, 0x0, 0x0, 0xc000796158, 0xc000796270, 0x582a60b) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/builder/qemu/step_run.go:368 +0x4d 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*stepRun).Run(0xc00011bf80, 0x5e5b060, 0xc000b05780, 0x5e5bc60, 0xc000796150, 0x0) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/builder/qemu/step_run.go:47 +0x37b 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/helper/multistep.(*BasicRunner).Run(0xc0007962d0, 0x5e5b060, 0xc000b05780, 0x5e5bc60, 0xc000796150) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/helper/multistep/basic_runner.go:70 +0x234 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/builder/qemu.(*Builder).Run(0xc000a98300, 0x5e5b060, 0xc000b05780, 0x5e75f60, 0xc0005b5ec0, 0x5de9640, 0xc00011bf60, 0xc0003a7b60, 0xc0000869f8, 0xc0003a7bd0, ...) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/builder/qemu/builder.go:158 +0x11a2 2021/01/04 10:16:22 packer-builder-qemu plugin: github.com/hashicorp/packer/packer/rpc.(*BuilderServer).Run(0xc0007a0140, 0x1, 0xc0003806f0, 0x0, 0x0) 2021/01/04 10:16:22 packer-builder-qemu plugin: /home/circleci/project/packer/packer/rpc/builder.go:117 +0x1c4 2021/01/04 10:16:22 packer-builder-qemu plugin: reflect.Value.call(0xc0000869c0, 0xc00000e7d0, 0x13, 0x58203ee, 0x4, 0xc0003a7f08, 0x3, 0x3, 0x0, 0x0, ...) 2021/01/04 10:16:22 packer-builder-qemu plugin: /usr/local/go/src/reflect/value.go:475 +0x8c7 2021/01/04 10:16:22 packer-builder-qemu plugin: reflect.Value.Call(0xc0000869c0, 0xc00000e7d0, 0x13, 0xc0004cdf08, 0x3, 0x3, 0x0, 0x0, 0x0) 2021/01/04 10:16:22 packer-builder-qemu plugin: /usr/local/go/src/reflect/value.go:336 +0xb9 2021/01/04 10:16:22 packer-builder-qemu plugin: net/rpc.(*service).call(0xc0007a0180, 0xc0000cadc0, 0xc0000728f8, 0xc000072970, 0xc00038c380, 0xc00011a180, 0x49b7300, 0xc0003806ec, 0x18a, 0x48bb600, ...) 2021/01/04 10:16:22 packer-builder-qemu plugin: /usr/local/go/src/net/rpc/server.go:377 +0x189 2021/01/04 10:16:22 packer-builder-qemu plugin: created by net/rpc.(*Server).ServeCodec 2021/01/04 10:16:22 packer-builder-qemu plugin: /usr/local/go/src/net/rpc/server.go:474 +0x445 2021/01/04 10:16:22 [INFO] (telemetry) ending qemu ==> Wait completed after 3 seconds 69 milliseconds 2021/01/04 10:16:22 machine readable: error-count []string{"1"} ==> Some builds didn't complete successfully and had errors: 2021/01/04 10:16:22 machine readable: ubuntu-18.04,error []string{"unexpected EOF"} ==> Builds finished but no artifacts were created. 2021/01/04 10:16:22 [INFO] (telemetry) Finalizing. 2021/01/04 10:16:22 /usr/local/bin/packer: plugin process exited 2021/01/04 10:16:23 waiting for all plugin processes to complete... 2021/01/04 10:16:23 /usr/local/bin/packer: plugin process exited```

There is no crash.log that I can see,

nywilken commented 3 years ago

Hi there @spuder thanks for reaching out. I believe this issue was resolved in Packer v1.6.6.

Does upgrading to the latest version of Packer resolve the problem for you?

spuder commented 3 years ago

Yes, just upgraded to 1.6.6 and it is working now, Thank you. Sorry for the noise.

ghost commented 3 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.