Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with the LXD remote 'images' #464

Closed
gicamm opened this issue May 23, 2024 · 3 comments · Fixed by #461
Closed

problem with the LXD remote 'images' #464

gicamm opened this issue May 23, 2024 · 3 comments · Fixed by #461
Assignees
Labels

Comments

@gicamm
Copy link

gicamm commented May 23, 2024

Hi,
I'm having a problem with the lxd remote 'images'.

+----------------------+---------------------------------------------------+---------------+-------------+--------+--------+--------+ | NAME | URL | PROTOCOL | AUTH TYPE | PUBLIC | STATIC | GLOBAL | +----------------------+---------------------------------------------------+---------------+-------------+--------+--------+--------+ | images | https://images.lxd.canonical.com | simplestreams | none | YES | NO | NO |
I'm using LXD 5.21.1 LTS, Teraform v1.8.3 and the latest lxd provider v2.0.0.

When I use 'ubuntu', everything is fine.

  resource "lxd_cached_image" "test" {
    remote = "myremote"
    source_remote = "ubuntu"
    source_image  = "18.04"
    type = "virtual-machine"
    copy_aliases = "true"
  }

Instead, I get errors every time I try to use the 'images'.
when I use images:centos/8-Stream/cloud

  resource "lxd_cached_image" "test" {
    remote = "myremote"
    source_remote = "images"
    source_image  = "centos/8-Stream/cloud"
    type = "virtual-machine"
    copy_aliases = "true"
}

Failed remote image download: Failed getting remote image info: Failed getting image: The requested image couldn't be found for fingerprint "5fd1d5b1cc37f0693c80e2561fc67cd3cf3dca14b2c1179f8a9846c4eb3850e7"

The same thing happens with the 'lxd_instance' as below:

resource "lxd_instance" "myinstance" {
  remote = "myremote"
  name = "test"
  type = "virtual-machine"
  image     = "images:centos/8-Stream/cloud"                                
  profiles  = ["default"]
  wait_for_network = "true"
}

When I try to download the image manually with the client, it works.
lxc image copy images:centos/8-Stream/cloud local: --vm

Can you help me with this?
Thank you

@MusicDin
Copy link
Member

Hi, thanks for reaching out.

Default image servers are hardcoded in the lxd/lxc/config.go. However, the current version of the provider is not using the latest LXD dependency, therefore, the images remote is still missing.

There is an open PR (#461), but it cannot be merged yet, because we have a small regression in LXD that is causing latest LXD client to be incompatible with older LXD versions (see canonical/lxd#13373 (comment)). This is being actively worked on, so I'm expecting the images remote to be included in the next release of the provider.


As a temporary workaround, a new remote can be added using lxc:

lxc remote add images-tmp https://images.lxd.canonical.com --protocol simplestreams

The above command will insert the remote into the local config, which can than be used from Terraform.

provider "lxd" {}

resource "lxd_instance" "instance" {
  name  = "test"
  image = "images-tmp:alpine/edge"
}

Please note that this workaround should be used with caution. If remote images-tmp is later replaced with images (in Terraform config), Terraform will try to recreate the instance. Therefore, the remote needs to be manually adjusted in terraform.state to prevent recreation of the instances.

@gicamm
Copy link
Author

gicamm commented May 23, 2024

Hi, thanks for your reply. You have made my day.

@gicamm
Copy link
Author

gicamm commented May 29, 2024

It works fine now.
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants