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

Couldn't extract checksum from checksum file in Packer 1.4.5 #8322

Closed Gregory-N-able closed 4 years ago

Gregory-N-able commented 4 years ago

Overview of the Issue

Upgraded Packer.io for Windows (packer.exe) from 1.4.2 to 1.4.5 and kicked off a new, scripted, Hyper-V ISO build. After preparing the build sources, the packer.exe call failed immediately with the error:

hyperv-iso output will be in this color.

1 error(s) occurred:

* Couldn't extract checksum from checksum file

Reverting back to Packer.io version 1.4.2, the build is successful.

Reproduction Steps

From the build system log (we use Packer.io to build an upload-able Azure custom image):

[11/04/19 16:23:27] Calling Packer with the following parameters: [11/04/19 16:23:27] [11/04/19 16:23:27] Image Name: My-Custom-ISO-100 [11/04/19 16:23:27] Disk Size: 100GB [11/04/19 16:23:27] ISO File: C:\Cloud\My-Custom-ISO.iso [11/04/19 16:23:27] ISO Checksum: C:\Cloud\My-Custom-ISO.sha5 [11/04/19 16:23:27] Calling Packer using Command Line: [11/04/19 16:23:27] E:\bin\packer.exe build -force -timestamp-ui -var vm_name="My-Custom-ISO-100" -var iso_url="C:\Cloud\My-Custom-ISO.iso" -var iso_checksum_url="C:\Cloud\My-Custom-ISO.sha5" -var disk_size="102400" -var temp_path="E:\Temp\" "E:\Cloud\Azure\azure.json"

Packer version

E:\bin>packer version
Packer v1.4.2

Your version of Packer is out of date! The latest version
is 1.4.5. You can update by downloading from www.packer.io/downloads.html

Simplified Packer Buildfile

Gist

Operating system and Environment details

E:\bin>ver

Microsoft Windows [Version 10.0.17763.737]`

Log Fragments and crash.log files

I will have to run Packer 1.4.5 in debug once my image build job completes (48 hours) in order to get the requested logs (I reverted to 1.4.2 in order to complete the build job I was trying to run).

azr commented 4 years ago

Hey there @GregorySWI,

I think you should not set iso_checksum_type or set it to "iso_checksum_type": "file", if your cheksum is in a file; the file getter will determine the type for you.

It's all written here.


Edit: Also I see that the error is Couldn't extract checksum from checksum file do you have that checksum file for us to check ? It needs to be in a special format for packer to understand it.

Gregory-N-able commented 4 years ago

Is this a new change? This has been working with this config for over a year. Here is the checksum file:

Gist

I do see the "file" option, but if you notice, we are using the format of the last example in the doc.

I will try changing it to type "file" once the current job completes and update this bug.

dcretin commented 4 years ago

I am also experimenting the same problem with packer 1.4.5 and regular ubuntu checksum file

dcretin commented 4 years ago

Any update on this issue?

azr commented 4 years ago

Hello @GregorySWI; was the issue fixed for you ?

@dcretin Do you have a simplified buildfile for me to try ? ( I simply want to make sure it's the same issue )

dcretin commented 4 years ago

Thank you for looking at this @azr !

Here you are: test-ubuntu-file-hash.zip

azr commented 4 years ago

Hello there; can any of you tell me if the binaries found here fixes this issue ? Thanks !

Sorry it took so much time to circle back to this issue; I was deeply focusing onto something else 🙂

Gregory-N-able commented 4 years ago

Hello there; can any of you tell me if the binaries found here fixes this issue ? Thanks !

Sorry it took so much time to circle back to this issue; I was deeply focusing onto something else 🙂

I tried changing from "iso_checksum_type": "sha512" to "iso_checksum_type": "file" and I get the same cannot read checksum from file error.

Testing the above linked binary for Windows, is the same as well:

`[11/22/19 10:12:11] Calling Packer using Command Line: [11/22/19 10:12:11] E:\bin\packer.exe build -force -timestamp-ui -on-error="abort" -var vm_name="My-Custom-ISO-100.0.0.952-25" -var iso_url="C:\Cloud\My-Custom-ISO-100.0.0.952.iso" -var iso_checksum_url="C:\Cloud\My-Custom-ISO-100.0.0.952.sha5" -var disk_size="25600" -var temp_path="E:\Temp\" "E:\Cloud\Azure\azure.json" hyperv-iso output will be in this color.

1 error(s) occurred:

And the contents of My-Custom-ISO-100.0.0.952.sha5: 56074d7797ff9f94b22cf5a51333d481cbade98e1221fabac9180718d1189a16a4f8862a5ca3e72e8565d01de7da7b6aff601892ff68279e373c23bdf7ebdcbd My-Custom-ISO-100.0.0.952.iso

Gregory-N-able commented 4 years ago

Just tested the new binary file with the "iso_checksum_type": "sha512" value set as well and I recieved the same error as above.

vtolstov commented 4 years ago

this is go getter error, i have templates that worked for more then two years and not it broken by new packer. i'm use checksum url to specify remote checksum file and set checksum type sha1, but with packer 1.4.5 it always failed. and worked fine with packer 1.4.2

vtolstov commented 4 years ago

checksum error happend for this file https://cdimage.debian.org/mirror/cdimage/archive/9.4.0/amd64/iso-cd/SHA1SUMS and not happened for this https://mirror.yandex.ru/archlinux/iso/latest/sha1sums.txt

as you see this is both sha1 checksums

vtolstov commented 4 years ago

please fix the issue and tag release, because 1.4.5 is really broken

vtolstov commented 4 years ago

and if i set iso_checksum_type to file it works, but why i need to change my templates after new release?

vtolstov commented 4 years ago
if cksum == nil || err != nil {                                                       
  errs = append(errs, fmt.Errorf("Couldn't extract checksum from checksum file"))     
} else {                                                                              

why the error is dropped? if cksum is nil return one error, if err != nil append it to errs slice

azr commented 4 years ago

Hello there, sorry I made myself pretty busy with HCL2 and paused in here. I'm taking a look at this now and one way to fix this would be to change:

"iso_checksum_type": "file",
"iso_checksum": "{{user `iso_server`}}/SHA256SUMS",

to

"iso_checksum": "file:{{user `iso_server`}}/SHA256SUMS",

This bug was introduced here: https://github.com/hashicorp/packer/pull/7804

But have also I've bundled #7627 with a fix for this and this should be fixed soon !

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.