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

bug: maas_machine resource leaves unsuccessfully added machines in New state instead of deleting them #153

Open
vishvikkrishnan opened this issue Feb 9, 2024 · 1 comment
Labels
triaged Triaged to be addressed in a given cycle

Comments

@vishvikkrishnan
Copy link

The maas_machine resource does not remove unsuccessfully added machines (with a wrong 'power_address', previously existing 'pxe_mac_address', or duplicate 'hostname'), resulting in those machines showing as New in MAAS. The destroy action for such wrongly added machines does nothing.

Error: ServerError: 503 Service Unavailable (No rack controllers can access the BMC of node node01)
│ 
│   with maas_machine.node["node01"],
│   on main.tf line 1, in resource "maas_machine" "node":1: resource "maas_machine" "node" {

However, when the correct details are passed and the resource is reapplied, errors are thrown because the wrongly added machines haven't yet been deleted.

 Error: ServerError: 400 Bad Request ({"mac_addresses": ["MAC address b8:ae:ed:73:38:40 already in use on node01."], "power_type": ["Can't set power type to amt without network interfaces"], "hostname": ["Node with this Hostname already exists."]})
│ 
│   with maas_machine.node["node01"],
│   on main.tf line 1, in resource "maas_machine" "node":1: resource "maas_machine" "node" {

The resource should clean up any failed nodes that weren't added to ensure resource idempotency. Currently, I have to manually remove them MAAS before reattempting a terraform apply.

Tested with the following maas_machine resource on the TF MAAS provider version 2.0:

resource "maas_machine" "node" {
  for_each   = var.machines
  power_type = each.value.power_type
  power_parameters = jsonencode({
    power_address = each.value.bmc_address
    power_pass    = each.value.bmc_password
  })
  pxe_mac_address = each.value.mac_address
  hostname        = each.value.name
  zone            = each.value.zone
}
@jurekh jurekh added the triaged Triaged to be addressed in a given cycle label Feb 22, 2024
@spdfnet
Copy link

spdfnet commented Jul 2, 2024

So you have a variable defined from where you can remove the faulty one, apply, then add it again.

Feels to me like usual OpenTofu behavior mixed with a lack of state flow support in the provider.
But how would you model the latter? I feel the MAAS API is not ready for it either.

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

No branches or pull requests

3 participants