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

Default distro_series "focal" causing deployment failure in cases where focal image does not exist #132

Closed
vishvikkrishnan opened this issue Dec 14, 2023 · 0 comments
Assignees
Labels
bug Something isn't working triaged Triaged to be addressed in a given cycle

Comments

@vishvikkrishnan
Copy link

The maas_vm_host resource type causes an error during terraform apply when trying to deploy a machine in MAAS without the "focal" image. Consequently, it is currently not possible to deploy a pre-registered MAAS machine with any image other than "focal" using the machine param:

Terraform will perform the following actions:

  # maas_vm_host.infra_2_lxd_host will be created
  + resource "maas_vm_host" "infra_2_lxd_host" {
      + cpu_over_commit_ratio         = (known after apply)
      + default_macvlan_mode          = (known after apply)
      + id                            = (known after apply)
      + machine                       = "cos-2"
      + memory_over_commit_ratio      = (known after apply)
      + name                          = "infra-2-lxd-host"
      + pool                          = (known after apply)
      + resources_cores_total         = (known after apply)
      + resources_local_storage_total = (known after apply)
      + resources_memory_total        = (known after apply)
      + tags                          = (known after apply)
      + type                          = "lxd"
      + zone                          = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

maas_vm_host.infra_2_lxd_host: Creating...
╷
│ Error: ServerError: 400 Bad Request ({"distro_series": ["'focal' is not a valid distro_series.  It should be one of: '', 'ubuntu/jammy'."]})
│ 
│   with maas_vm_host.infra_2_lxd_host,
│   on main.tf line 16, in resource "maas_vm_host" "infra_2_lxd_host":
│   16: resource "maas_vm_host" "infra_2_lxd_host" {
╵

MAAS only has the jammy image by default. Configuration used:

resource "maas_vm_host" "infra_2_lxd_host" {
  type = "lxd"
  name = "infra-2-lxd-host"
  machine = "cos-2" #machine is pre-registered in MAAS
}

This is because the default "distro_series" is hardcoded to "focal" in the source file.

In this scenario, the machine to be deployed is stuck in the Allocated state, and even a terraform destroy does not restore the machine back to the Ready state. This leads to loss of idempotence between the Terraform actions and the existing state recorded by Terraform. For instance, running terraform destroy subsequent to the above error indicates nothing to destoy:

No changes. No objects need to be destroyed.

Either you have not created any objects yet or the existing objects were already deleted outside of Terraform.

Destroy complete! Resources: 0 destroyed.

However, re-running terraform apply complains about a different error (the machine is no longer available to allocate by MAAS as it is already stuck in the Allocated state):

Error: ServerError: 409 Conflict (No machine with system ID 4qxcte available.)

Expected Behavior:
It should be possible to deploy the default image configured in the MAAS settings or provide a custom "distro_series" param during machine deploy via the maas_vm_host resource (using the machine param).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Triaged to be addressed in a given cycle
Projects
None yet
Development

No branches or pull requests

2 participants