Open volker-raschek opened 2 years ago
I'm facing the same issue. It seems related to the image If I use the openSUSE Tumbleweed JeOS image, the following works fine
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.14"
}
}
}
# base image
resource "libvirt_volume" "tumbleweed" {
name = "tumbleweed"
pool = "default"
source = "http://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-JeOS.x86_64-OpenStack-Cloud.qcow2"
format = "qcow2"
}
If I replace with Leap 15.4 JeOS
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.6.14"
}
}
}
# base image
resource "libvirt_volume" "tumbleweed" {
name = "tumbleweed"
pool = "default"
source = "http://download.opensuse.org/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-JeOS.x86_64-15.4-OpenStack-Cloud-Build6.195.qcow2"
format = "qcow2"
}
following terraform apply
Error: Error while determining image type for http://download.opensuse.org/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-JeOS.x86_64-15.4-OpenStack-Cloud-Build6.195.qcow2: Can't retrieve partial header of resource to determine file type: http://download.opensuse.org/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-JeOS.x86_64-15.4-OpenStack-Cloud-Build6.195.qcow2 - 404 Not Found
and I just checked http://download.opensuse.org/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-JeOS.x86_64-15.4-OpenStack-Cloud-Build6.195.qcow2 and I got a 404 Refreshed the page with image links and a new image was actually available There is actually a 'Current' link to avoid issues with images numbers http://download.opensuse.org/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-JeOS.x86_64-15.4-OpenStack-Cloud-Current.qcow2
Hi, I think this is issue with image hosting and this provider can do nothing/very little about unreliable hosting.
I have the same issue with a Talos unified kernel image:
Error: error while determining image type for https://factory.talos.dev/image/20814cdbf3e618f7ecb37360b08449fcc16712e9ff794e9f3100b563ca808af9/v1.8.1/metal-amd64-secureboot-uki.efi: can't retrieve partial header of resource to determine file type: https://factory.talos.dev/image/20814cdbf3e618f7ecb37360b08449fcc16712e9ff794e9f3100b563ca808af9/v1.8.1/metal-amd64-secureboot-uki.efi - 200 OK
But I don't think, it is related to unrelyable hosting. Instead, it seems like the provider is trying to download only the first 8 bytes from the server, by using the Range
HTTP-Header (See https://github.com/dmacvicar/terraform-provider-libvirt/blob/main/libvirt/volume_image.go#L140 for details.).
Which simply might not be supported by every hoster:
A server that doesn't support range requests may ignore the Range header and return the whole resource with a 200 status code.
I'd suggest, to try to download only the first bytes and if this does not work, simply download the whole image. It needs to be downloaded later anyway, so maybe the provider could simply store it meanwhile, to avoid downloading it twice.
Hi @hansingt , thanks for detailed investigation! You seem to be right, I might create a PR with a fix for it.
Thank you @scabala! I'd create the PR myself, but sadly I'm not that good with Go 🫤
No worries @hansingt, I have went through the code and I think solution is quite simple. Could you check code from PR #1120?
Hi,
I am trying to deploy some Rocky Linux 8.5 VMs. The first time I run it, I always get the error described below. Only when I run it again does the deployment work.
Volker
System Information
Linux distribution
Terraform version
Provider and libvirt versions
Checklist
Description of Issue/Question
Setup
variables
Steps to Reproduce Issue
Additional information:
Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? Have you tried to reproduce the issue without them enabled?