vmware / terraform-provider-nsxt

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

nsx_edge_transport_node deploy failures (crash on syslog port + root object absent) #1186

Closed martinrohrbach closed 4 months ago

martinrohrbach commented 4 months ago

Describe the bug

Since #1146 and #1153 have now been fixed (thanks!) and the new provider has been released, we have resumed testing.

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,
  ]
}

We have two problems.

1) When se use the node_settings / syslog_server / port property, it immediately throws a provider error. It does not matter if we set the port as an integer or as a string which is both accepted but fails all the same:

Stack trace from the terraform-provider-nsxt_v3.6.0 plugin:
panic: interface conversion: interface {} is int, not string
goroutine 11858 [running]:
github.com/vmware/terraform-provider-nsxt/nsxt.validateSinglePort.func1({0x19278a0?, 0xc000a3cc40?}, {0xc00015b350?, 0x2?})
github.com/vmware/terraform-provider-nsxt/nsxt/validators.go:54 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Schema).validateFunc(0x202?, {0x19278a0?, 0xc000a3cc40?}, {0xc00015b350?, 0xc0006d0a50?}, {0xc000435400?, 0x5, 0x8})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:594 +0x8b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validatePrimitive(0x15?, {0xc00015b350, 0x24}, {0x19278a0, 0xc000a3ca78?}, 0xc000303680, 0xc0000fe000?, {0xc000435400, 0x5, 0x8})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2314 +0xa28
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateType(0xc0008fddd8?, {0xc00015b350?, 0xc0009470e0?}, {0x19278a0?, 0xc000a3ca78?}, 0xc000303680, 0x7b39b18fb8a8?, {0xc000435400, 0x5, 0x8})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2341 +0x14a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validate(0x19c81a0?, {0xc00015b350, 0x24}, 0xc000303680, 0x2?, {0xc000435400, 0x5, 0x8})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:1751 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateObject(0x1a74460?, {0xc000cf5c20, 0x1f}, 0x2?, 0x2?, {0xc00071d400?, 0x4, 0x4})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2187 +0x592
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateList(0x0?, {0xc000cf5c00, 0x1d}, {0x1914aa0?, 0xc000822528?}, 0xc000303a40, 0x1975580?, {0xc00071d400, 0x3, 0x4})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:1976 +0xca5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateType(0xc0008fe6b8?, {0xc000cf5c00?, 0xc00034fb20?}, {0x1914aa0?, 0xc000822528?}, 0xc000303a40, 0x7b39b18fb8a8?, {0xc00071d400, 0x3, 0x4})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2327 +0x1a5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validate(0x19c81a0?, {0xc000cf5c00, 0x1d}, 0xc000303a40, 0x2?, {0xc00071d400, 0x3, 0x4})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:1751 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateObject(0x19c81a0?, {0xc000a3cc00, 0xf}, 0x2?, 0x2?, {0xc0007121e0?, 0x2, 0x2})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2187 +0x592
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateList(0x0?, {0x1b60ce0, 0xd}, {0x1914aa0?, 0xc000822540?}, 0xc000303b80, 0x1975580?, {0xc00034e320, 0x1, 0x1})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:1976 +0xca5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateType(0xc0008fefd8?, {0x1b60ce0?, 0x440571?}, {0x1914aa0?, 0xc000822540?}, 0xc000303b80, 0x94?, {0xc00034e320, 0x1, 0x1})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2327 +0x1a5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validate(0x19c81a0?, {0x1b60ce0, 0xd}, 0xc000303b80, 0x1a0?, {0xc00034e320, 0x1, 0x1})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:1751 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.validateObject(0x0?, {0x0, 0x0}, 0x2?, 0x1e2d8c0?, {0x26e6988?, 0x0, 0x0})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:2187 +0x592
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Validate(...)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/schema.go:810
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Validate(0xc000300540, 0xc00042def0?)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/resource.go:987 +0x6d
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ValidateResource(0x1e32d80?, {0xc00076b9f8, 0x18}, 0xd?)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/provider.go:258 +0xf2
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ValidateResourceTypeConfig(0xc000010018, {0x1e32d80?, 0xc000563020?}, 0xc000822060)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.29.0/helper/schema/grpc_provider.go:282 +0x1a9
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ValidateResourceTypeConfig(0xc000378460, {0x1e32d80?, 0xc0005628a0?}, 0xc0007ebec0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/tf5server/server.go:729 +0x2e3
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ValidateResourceTypeConfig_Handler({0x1adde40?, 0xc000378460}, {0x1e32d80, 0xc0005628a0}, 0xc0003715e0, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:359 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00026e1e0, {0x1e370a0, 0xc0000d01a0}, 0xc000698ea0, 0xc00035d770, 0x26a4fe8, 0x0)
google.golang.org/grpc@v1.57.1/server.go:1358 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc00026e1e0, {0x1e370a0, 0xc0000d01a0}, 0xc000698ea0, 0x0)
google.golang.org/grpc@v1.57.1/server.go:1735 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/grpc@v1.57.1/server.go:970 +0xca
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.57.1/server.go:981 +0x15c
Error: The terraform-provider-nsxt_v3.6.0 plugin crashed!
This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

2) If we remove the syslog port config (because 514 is the default anyway), 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. Observer error(s)

Expected behavior

No errors on deploy.

Additional context

No response

martinrohrbach commented 4 months ago

Ah, I always forget: we're testing against NSX-T 4.1.2.3