Packer: Error downloading Virtualbox Guest Additions checksums

Created on 28 Jul 2019  ·  16Comments  ·  Source: hashicorp/packer

A build of a virtualbox (iso or ovf) template with guest additions mode set to upload returns an error downloading the checksums.
In the error output there is a mkdir command with a path to my packer_cache which appears to have 'C::' appended.

Something weird seems to be happening between the temporary file location and the cache dir as shown in the log section below. Most odd is that only seems to be affecting this one download from what I can tell. I had a look at the code around the checksum download, unfortunately i've not got the chops to figure it out..

2019/07/28 15:37:42 ui: ==> virtualbox-iso: Retrieving Guest additions checksums
2019/07/28 15:37:42 ui: ==> virtualbox-iso: Trying https://download.virtualbox.org/virtualbox/5.2.32/SHA256SUMS
2019/07/28 15:37:42 packer.exe: 2019/07/28 15:37:42 Acquiring lock for: https://download.virtualbox.org/virtualbox/5.2.32/SHA256SUMS (S:\Vagrant\packer_cache\C:\Users\sbcdb\AppData\Local\Temp\packer886137615.lock)
2019/07/28 15:37:42 ui: ==> virtualbox-iso: Trying https://download.virtualbox.org/virtualbox/5.2.32/SHA256SUMS
2019/07/28 15:37:42 ui: ==> virtualbox-iso: Download failed mkdir S:\Vagrant\packer_cache\C:: The filename, directory name, or volume label syntax is incorrect.
2019/07/28 15:37:42 ui error: ==> virtualbox-iso: error downloading Guest additions checksums: [mkdir S:\Vagrant\packer_cache\C:: The filename, directory name, or volume label syntax is incorrect.]
2019/07/28 15:37:42 ui: ==> virtualbox-iso: leaving retrieve loop for Guest additions checksums

When I set the guest_additions_sha256 option explicitly it works fine, the guest additions iso itself is downloads fine and the build continues.

  • Packer version: 1.4.2
  • Host platform: Windows 10 64bit

Created a cut down template, it fails straight away on my setup

  • Additional configuration and information

    • PACKER_CACHE_DIR is configured to S:\Vagrant\packer_cache

    • Also fails if I remove the custom cache dir (uses build dir, same error)

    • VirtualBox version is 5.3.32

    • Doesn't happen with Packer v1.3.5, v1.4.0 fails with a different error (empty checksum)

core regression

All 16 comments

I'm seeing the same thing with the Hyper-V ISO builder after updating to Packer 1.4.2 so I don't believe it is related to a specific builder. Looking at the code changes that have taken place since 1.3.4 (where it worked) there are only 4 commits that could be the issue. I'm thinking it's 9f82b75e57e35784564c25f3f7d5e07fd5495226 which changes the way the builders download files.

The error messages on my side are:

==> hyperv-iso: Creating build directory...
==> hyperv-iso: Retrieving ISO
==> hyperv-iso: Trying http://devinfrastructure.vista.co/artefacts/infrastructure/production/templates/iso/windows/windows_server_1803_updates.iso
==> hyperv-iso: Trying http://devinfrastructure.vista.co/artefacts/infrastructure/production/templates/iso/windows/windows_server_1803_updates.iso?checksum=sha256%3A7250005F78779E57B09928024E8EFDAC41558558D9A58C812D38FD5E4290964F
==> hyperv-iso: Download failed mkdir c:\vcs\tfs\vista\devinfrastructure\Template-Resource.Windows.2016.Core\build\temp\packer-cache\c:: The filename, directory name, or volume label syntax is incorrect.
==> hyperv-iso: error downloading ISO: [mkdir c:\vcs\tfs\vista\devinfrastructure\Template-Resource.Windows.2016.Core\build\temp\packer-cache\c:: The filename, directory name, or volume label syntax is incorrect.]
==> hyperv-iso: leaving retrieve loop for ISO
==> hyperv-iso: Deleting output directory...
==> hyperv-iso: Deleting build directory...
Build 'hyperv-iso' errored: error downloading ISO: [mkdir c:\vcs\tfs\vista\devinfrastructure\Template-Resource.Windows.2016.Core\build\temp\packer-cache\c:: The filename, directory name, or volume label syntax is incorrect.]
==> Some builds didn't complete successfully and had errors:
--> hyperv-iso: error downloading ISO: [mkdir c:\vcs\tfs\vista\devinfrastructure\Template-Resource.Windows.2016.Core\build\temp\packer-cache\c:: The filename, directory name, or volume label syntax is incorrect.]
==> Builds finished but no artifacts were created.

Let me know if you need anymore information.

Thanks; I'll try to take at look this week.

@SwampDragons Hi Megan ... I think I found the culprit

https://github.com/hashicorp/packer/blob/f97df6721ee3148a9ea2d5c07110a7273868e90b/common/step_download.go#L154

The packer.CachePath method prepends the packer cache directory to the passed path, which results in an invalid path S:\Vagrant\packer_cache\C:\Users\sbcdb\AppData\Local\Temp\packer886137615.lock

https://github.com/hashicorp/packer/blob/f97df6721ee3148a9ea2d5c07110a7273868e90b/packer/cache.go#L33

Yep. I have a patch that'll just use the basename of the file instead, but I want to check what the behavior used to be to make sure it matches.

But that might create file name collisions in the cache directory, because the step step_download_guest_additions.go creates a temporary file name using the tmp.File method

https://github.com/hashicorp/packer/blob/a0a11bd109c249573579b5eab6bbd70104e418de/builder/virtualbox/common/step_download_guest_additions.go#L148

what's basically a thin wrapper for ioutil.TempFile

https://github.com/hashicorp/packer/blob/a0a11bd109c249573579b5eab6bbd70104e418de/packer/tmp/tmp.go#L44

and ioutil.TempFile guarantees filename uniqueness only for the given directory. Perhaps I'm overprotective here, but as you felt uncomfortable with threads sleeping for waiting things to change, I'm only mentioning here that there might be an issue here simply by using the generated tempfile name and appending it to the cache path.

Yeah, good point. Concern about uniqueness is the main reason I haven't opened the PR yet -- I want to do some diving through history and testing out old commits to see what this behavior used to be before it regressed when we implemented go-getter. That'll give me a clearer idea of how comfortable I am with a basename or whether I need to get more creative. I guess the other option is just stripping out any colons.

I'd be done with this already but I broke my windows 10 vm and had to rebuild it yesterday. It gets angry when you try to install virtualbox over hyperv. 😬

Thanks for your patience and your willingness to investigate 👍

I just realized there's a one-line solution for this. Can you validate that this build of PR #7996
https://circleci.com/gh/hashicorp/packer/8932#artifacts/containers/0 solves it for you?

Hi @SwampDragons, I tried this out on the test example I provided and the template I first hit the problem on. Both looking good. Also cleared the cache and ran them again for good measure without any issues.
Thank You!

@SwampDragons Has this been released. I just ran a Packer 1.4.5 build and got this:

==> hyperv-iso: Creating build directory...
==> hyperv-iso: Retrieving ISO
==> hyperv-iso: Trying http://myserver/artefacts/infrastructure/production/templates/iso/linux/ubuntu-16.04.6.iso
==> hyperv-iso: Trying http://myserver/artefacts/infrastructure/production/templates/iso/linux/ubuntu-16.04.6.iso?checksum=sha256%3A16AFB1375372C57471EA5E29803A89A5A6BD1F6AABEA2E5E34AC1AB7EB9786AC
==> hyperv-iso: Download failed mkdir C:\vcs\myrepo\Template-Resource.Linux.Ubuntu.Server\build\temp\packer-cache\C:: The filename, directory name, or volume label syntax is incorrect.
==> hyperv-iso: error downloading ISO: [mkdir C:\vcs\myrepo\Template-Resource.Linux.Ubuntu.Server\build\temp\packer-cache\C:: The filename, directory name, or volume label syntax is incorrect.]
==> hyperv-iso: Deleting output directory...
==> hyperv-iso: Deleting build directory...
Build 'hyperv-iso' errored: error downloading ISO: [mkdir C:\vcs\myrepo\Template-Resource.Linux.Ubuntu.Server\build\temp\packer-cache\C:: The filename, directory name, or volume label syntax is incorrect.]
==> Some builds didn't complete successfully and had errors:
--> hyperv-iso: error downloading ISO: [mkdir C:\vcs\myrepo\Template-Resource.Linux.Ubuntu.Server\build\temp\packer-cache\C:: The filename, directory name, or volume label syntax is incorrect.]
==> Builds finished but no artifacts were created.

Which looks like the issue above. Is there anything I need to change to my configuration?
My configuration is:

{
    "variables": {
        "admin_username": "not_really_the_admin",
        "admin_password": "not_really_the_admin_password",

        "cookbook_name": "not_realy_a_cookbook_name",

        "dir_cookbooks_src": "src/cookbooks",
        "dir_cookbooks_vendors": "packages/vendor/cookbooks",
        "dir_deploy": null,
        "dir_http_user": null,
        "dir_scripts_user": null,
        "dir_temp": null,

        "iso_checksum": null,
        "iso_url": null,

        "vm_name": "not_really_a_vm_name",
        "vm_ram_size_in_mb": "1024",
        "vm_switch_name": "this_switch_does_not_exist",
        "vm_switch_vlan": ""
    },
    "builders": [
        {
            "boot_wait": "5s",
            "boot_command": [
                "<enter><wait><f6><esc><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
                "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
                "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
                "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
                "/install/vmlinuz<wait>",
                " auto<wait>",
                " console-setup/ask_detect=false<wait>",
                " console-setup/layoutcode=us<wait>",
                " console-setup/modelcode=pc105<wait>",
                " debconf/frontend=noninteractive<wait>",
                " debian-installer=en_US<wait>",
                " fb=false<wait>",
                " initrd=/install/initrd.gz<wait>",
                " kbd-chooser/method=us<wait>",
                " keyboard-configuration/layout=USA<wait>",
                " keyboard-configuration/variant=USA<wait>",
                " locale=en_US<wait>",
                " netcfg/get_domain=vm<wait>",
                " netcfg/get_hostname=vagrant<wait>",
                " grub-installer/bootdev=/dev/sda<wait>",
                " noapic<wait>",
                " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
                " -- <wait>",
                "<enter><wait>"
            ],
            "communicator": "ssh",
            "disk_block_size": "1",
            "enable_dynamic_memory": false,
            "enable_mac_spoofing": false,
            "enable_secure_boot": false,
            "enable_virtualization_extensions": false,
            "generation": 1,
            "guest_additions_mode": "disable",
            "headless": true,
            "http_directory": "{{ user `dir_http_user` }}",
            "http_port_min": 8150,
            "http_port_max": 8160,
            "iso_url": "{{user `iso_url`}}",
            "iso_checksum_type": "sha256",
            "iso_checksum": "{{user `iso_checksum`}}",
            "iso_target_path": "{{ user `dir_temp` }}/packer/ubuntu.iso",
            "memory": "{{user `vm_ram_size_in_mb`}}",
            "output_directory": "{{ user `dir_temp` }}/{{ user `vm_name` }}",
            "shutdown_command": "echo '{{user `admin_password`}}' | sudo -S -E shutdown -P now",
            "ssh_password": "{{user `admin_password`}}",
            "ssh_timeout": "4h",
            "ssh_username": "{{user `admin_username`}}",
            "switch_name": "{{user `vm_switch_name`}}",
            "type": "hyperv-iso",
            "vm_name": "{{ user `vm_name` }}"
        }
    ],
    "provisioners": [
        {
            "type": "shell",
            "execute_command": "echo '{{user `admin_password`}}' | sudo -S sh {{.Path}}",
            "scripts": [
                "{{ user `dir_scripts_user` }}/ubuntu/scripts/update.sh"
            ]
        },
        {
            "expect_disconnect": false,
            "inline": [
                "echo '{{user `admin_password`}}' | sudo -S -E bash -c 'echo \"{{user `admin_username`}} ALL=(ALL:ALL) NOPASSWD: ALL\" | (EDITOR=\"tee -a\" visudo)'"
            ],
            "type": "shell"
        },
        {
            "expect_disconnect": false,
            "inline": [
                "sudo -E apt-get install --assume-yes curl"
            ],
            "type": "shell"
        },
        {
            "cookbook_paths": [
                "{{ user `dir_cookbooks_vendors` }}"
            ],
            "execute_command": "sudo -E chef-solo --no-color -c {{.ConfigPath}} -j {{.JsonPath}} --chef-license accept-no-persist",
            "guest_os_type": "unix",
            "install_command": "curl -LO https://omnitruck.chef.io/install.sh && {{if .Sudo}}sudo{{end}} bash ./install.sh -v 15.0.300 && rm install.sh",
            "run_list": [
                "{{ user `cookbook_name` }}::default"
            ],
            "type": "chef-solo"
        },
        {
            "expect_disconnect": false,
            "inline": [
                "sudo apt list --installed > /tmp/packages.txt"
            ],
            "type": "shell"
        },
        {
            "destination" : "{{ user `dir_temp` }}/installed_packages.txt",
            "direction" : "download",
            "source" : "/tmp/packages.txt",
            "type" : "file"
        },
        {
            "type": "shell",
            "execute_command": "sudo -E sh {{.Path}}",
            "scripts": [
                "{{ user `dir_scripts_user` }}/ubuntu/scripts/network.sh",
                "{{ user `dir_scripts_user` }}/ubuntu/scripts/cleanup.sh",
                "{{ user `dir_scripts_user` }}/ubuntu/scripts/sysprep.sh"
            ]
        }
    ]
}

And my variables file is

{
    "admin_username": "admin",
    "admin_password": "MyAwesomePassword",

    "cookbook_name": "template_resource_linux_ubuntu_server",

    "dir_cookbooks_src": "C:/vcs/myrepo/Template-Resource.Linux.Ubuntu.Server/build/temp/cookbooks",
    "dir_cookbooks_vendors": "C:/vcs/myrepo/Template-Resource.Linux.Ubuntu.Server/berks/cookbooks",
    "dir_deploy": "C:/vcs/myrepo/Template-Resource.Linux.Ubuntu.Server/build/deploy",
    "dir_http_user": "C:/vcs/myrepo/Template-Resource.Linux.Ubuntu.Server/build/temp/http",
    "dir_scripts_user": "C:/vcs/myrepo/Template-Resource.Linux.Ubuntu.Server/build/temp/scripts",
    "dir_temp": "C:/vcs/myrepo/Template-Resource.Linux.Ubuntu.Server/build/temp",

    "iso_checksum": "16AFB1375372C57471EA5E29803A89A5A6BD1F6AABEA2E5E34AC1AB7EB9786AC",
    "iso_url": "http://myserver/artefacts/infrastructure/production/templates/iso/linux/ubuntu-16.04.6.iso",

    "vm_name": "ubuntu-16-04-6",
    "vm_ram_size_in_mb": "1024",
    "vm_switch_name": "LAN",
    "vm_switch_vlan": ""
}

Yes, this should have been released. I'll reopen and investigate again.

@pvandervelde the original issue here is specifically for Guest Additions paths, which you aren't using here. It looks like the ubuntu iso download is failing for a similar reason.

The issue in your case seems to be with

"iso_target_path": "{{ userdir_temp}}/packer/ubuntu.iso",

not being respected proplerly. This is definitely a problem, but a slightly different one than the original issue. I'm investigating now, but in the meantime you can probably work around this bug either by pre-downloading the iso and giving Packer a path to the iso locally, or by removing the iso_target_path option and letting Packer cache the file in its own cache.

@pvandervelde I fixed this in the linked PR; binaries are available at https://circleci.com/gh/hashicorp/packer/22036#artifacts/containers/0

@SwampDragons Thanks for that. I'll try the binary on monday when I'm back in the office (NZ time here).

@SwampDragons I've tried the binaries with the build configuration that failed and it works now :) Thanks heaps

Cool, I'll merge once we've ironed out a couple more internal implementation details. Thanks for verifying.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nikoos picture Nikoos  ·  3Comments

s4mur4i picture s4mur4i  ·  3Comments

jesse-c picture jesse-c  ·  3Comments

mushon4 picture mushon4  ·  3Comments

znerd picture znerd  ·  3Comments