vmware / terraform-provider-nsxt

Terraform VMware NSX-T provider
https://www.terraform.io/docs/providers/nsxt/
Other
123 stars 80 forks source link

nsx_edge_transport_node deploy failure (root object absent) #1204

Closed martinrohrbach closed 2 months ago

martinrohrbach commented 2 months ago

Describe the bug

Followup on #1186 since the second part of the issue hasn't been fixed yet.

We still have problems creating new edges with our desired configuration. Given the following resource:

resource "nsxt_edge_transport_node" "edge" {
  description  = var.edge.display_name
  display_name = var.edge.display_name

  standard_host_switch {
    host_switch_name = "Overlay"
    ip_assignment {
      static_ip_pool = nsxt_policy_ip_pool.ip_pool_edge.realized_id
    }
    transport_zone_endpoint {
      transport_zone = data.nsxt_policy_transport_zone.policy_overlay_transport_zone.id
    }
    host_switch_profile = [data.nsxt_policy_uplink_host_switch_profile.uplink_host_switch_profile.id]
    pnic {
      device_name = "fp-eth0"
      uplink_name = "uplink"
    }
  }

  standard_host_switch {
    host_switch_name = "VLAN"
    ip_assignment {
      assigned_by_dhcp = true
    }
    transport_zone_endpoint {
      transport_zone = data.nsxt_policy_transport_zone.policy_vlan_transport_zone.id
    }

    host_switch_profile = [data.nsxt_policy_uplink_host_switch_profile.uplink_host_switch_profile.id]
    pnic {
      device_name = "fp-eth1"
      uplink_name = "uplink"
    }
  }

  deployment_config {
    form_factor = var.edge.form_factor
    node_user_settings {
      cli_password  = var.edge.deploy_creds
      root_password = var.edge.deploy_creds
    }
    vm_deployment_config {
      management_network_id = data.vsphere_network.edge_mgmt_network.id
      data_network_ids = [
        data.vsphere_network.edge_geneve_network.id,
        data.vsphere_network.edge_uplink_network.id
      ]
      compute_id = data.vsphere_compute_cluster.edge_compute_cluster.id
      storage_id = data.vsphere_datastore.datastore_edges.id
      vc_id      = data.nsxt_compute_manager.compute_mgr.id
      host_id    = data.vsphere_host.edge_deployment_target_host.id
      management_port_subnet {
        ip_addresses  = [var.edge.mgmt_ip]
        prefix_length = 24
      }
      default_gateway_address = [var.edge.mgmt_default_gateway]
    }
  }

  node_settings {
    hostname             = var.edge.host_name
    allow_ssh_root_login = true
    enable_ssh           = false
    dns_servers          = var.edge.dns_servers
    ntp_servers          = var.edge.ntp_servers
    search_domains       = var.edge.search_domains
    syslog_server {
      name      = var.edge.syslog_server
      log_level = "INFO"
      protocol  = "TCP"
      server    = var.edge.syslog_server
      port      = 514
    }
  }

  depends_on = [
    nsxt_policy_ip_pool_static_subnet.static_subnet_edge,
  ]
}

The edge is deployed, but terraform throws an error at the end and the edge is not persisted in the state:

Error: Provider produced inconsistent result after apply
When applying changes to nsxt_edge_transport_node.edge,
provider "provider[\"registry.terraform.io/vmware/nsxt\"]" produced an
unexpected new value: Root object was present, but now absent.
This is a bug in the provider, which should be reported in the provider's
own issue tracker.

Reproduction steps

  1. Deploy nsx_edge_transport_node with the above config
  2. Observe error(s)

Expected behavior

No errors on deploy.

Additional context

We're testing against NSX-T 4.1.2.3 with the newest provider 3.6.1.

annakhm commented 2 months ago

Hi @martinrohrbach, does this happen with clean state, or is this a result of apply on state that resulted from previous error (after upgrading the provider)? Thank you

martinrohrbach commented 2 months ago

@annakhm The repo had a clean apply before without any nsxt_edge_transport_node in the state. I then updated from provider 3.6.0 to to provider 3.6.1, added the nsxt_edge_transport_node and applied it which resulted in the error above. Does that answer the question? Or did I get the question wrong?

If you think this has to do with the previous state, I could test this again with a completely empty state, I'll see if I find some time for this on monday.

martinrohrbach commented 2 months ago

@annakhm Update: I just tested this with a blank terraform state, creation of the edge resource only.

Same result, edge is being created just fine, terraform (1.8.2) errors out with the error above, state is empty afterwards.

annakhm commented 2 months ago

Thank you, this helps!

martinrohrbach commented 1 week ago

@annakhm I don't think this fix has made to a released version yet, any chance to get an update on when the next release is due?

annakhm commented 1 week ago

Hi @martinrohrbach, we expect next release to be before end of July