vmware / terraform-provider-vcf

Terraform Provider for VMware Cloud Foundation
https://registry.terraform.io/providers/vmware/vcf/
Mozilla Public License 2.0
22 stars 9 forks source link

Workload Domain create with geneve_vlan=0 does not work #128

Closed pradeep17j closed 7 months ago

pradeep17j commented 7 months ago

Code of Conduct

Terraform

1.7.3

Terraform Provider

1.7.3

VMware Cloud Foundation

0.8.1

Description

geneve_vlan_id is a required arg for workload domain creation.

For use with Nimbus, we need to pass geneve_vlan_id = "0" When "0" is passed, the workload domain spec validation fails because the nextClusterSpec is empty as below

,"nsxClusterSpec":{"nsxTClusterSpec":{}}},

But when the geneve_vlan_id is set to 200, all goes well. It generates proper spec and workload domain creation succeeds

"nsxClusterSpec":{"nsxTClusterSpec":{"geneveVlanId":200}}}

Affected Resources or Data Sources

workload domain create

Terraform Configuration

-----------------------------------------------

SDDC Workload Domain Deployment Module

[] Assumes 'Host Commisioning' is completed

[] Assumes pre-existing Network Pool(s) for vSAN and vMotion

[] Creates Workload Domain, vCenter and NSX instance, Datacenter and Cluster

[] Configures hosts into newly defined cluster and prepares with NSX VIBs

-----------------------------------------------

-----------------------------------------------

VCF Configuration - Workload Domain

-----------------------------------------------

resource "vcf_domain" "workload_domain" { name = "sfo-w01-vc01"

vCenter Settings

vcenter_configuration { name = var.vcenter_configuration["name"] fqdn = var.vcenter_configuration["fqdn"] vm_size = var.vcenter_configuration["vm_size"] storage_size = var.vcenter_configuration["storage_size"] ip_address = var.vcenter_configuration["ip"] subnet_mask = var.vcenter_configuration["subnet_mask"] gateway = var.vcenter_configuration["gateway"] datacenter_name = "${var.workload_domain_name}-dc" root_password = var.wld_passwords["vcenter"] }

NSX Settings

nsx_configuration { form_factor = var.nsx_settings["size"] vip = var.nsx_settings["vip"] vip_fqdn = var.nsx_settings["vip_fqdn"] license_key = var.license_keys["nsx"] nsx_manager_admin_password = var.wld_passwords["nsx_admin"] nsx_manager_audit_password = var.wld_passwords["nsx_audit"]

nsx_manager_node {
  name        = var.nsx_settings["appliance1_name"]
  fqdn        = "${var.nsx_settings["appliance1_name"]}.${var.domain_suffix}"
  ip_address  = var.nsx_settings["appliance1_ip"]
  subnet_mask = var.nsx_settings["subnet_mask"]
  gateway     = var.nsx_settings["gateway"]
}
nsx_manager_node {
  name        = var.nsx_settings["appliance2_name"]
  fqdn        = "${var.nsx_settings["appliance2_name"]}.${var.domain_suffix}"
  ip_address  = var.nsx_settings["appliance2_ip"]
  subnet_mask = var.nsx_settings["subnet_mask"]
  gateway     = var.nsx_settings["gateway"]
}
nsx_manager_node {
  name        = var.nsx_settings["appliance3_name"]
  fqdn        = "${var.nsx_settings["appliance3_name"]}.${var.domain_suffix}"
  ip_address  = var.nsx_settings["appliance3_ip"]
  subnet_mask = var.nsx_settings["subnet_mask"]
  gateway     = var.nsx_settings["gateway"]
}

} cluster { name = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}"

vds {
  name           = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-vds"
  is_used_by_nsx = true
  portgroup {
    name           = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-mgmt"
    transport_type = "MANAGEMENT"
  }
  portgroup {
    name           = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-vmotion"
    transport_type = "VMOTION"
  }
  portgroup {
    name           = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-vsan"
    transport_type = "VSAN"
  }
}

dynamic "host" {
  for_each = var.wld_hosts
  content {
    id          = host.value[0] // update
    license_key = var.license_keys["esxi"]
    vmnic {
      id       = host.value[2] // update
      vds_name = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-vds"
    }
    vmnic {
      id       = host.value[3] // update
      vds_name = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-vds"
    }
  }
}

vsan_datastore {
  datastore_name       = "${var.workload_domain_name}-${var.wld_cluster_settings["name"]}-vsan-ds"
  failures_to_tolerate = var.wld_cluster_settings["vsan_ftt"]
  license_key          = var.license_keys["vsan"]
}

#geneve_vlan_id = var.wld_cluster_settings["tep_vlan"]
geneve_vlan_id = "200"

} }

Debug Output

The error will be seen in domainmanager.log

2024-02-22T19:43:25.273+0000 INFO [vcf_dm,65d7a3dc956e4b5bc075a0f229f76e7d,05a6] [c.vmware.vcf.vimanager.utils.DnsUtil,http-nio-127.0.0.1-7200-exec-1] DNS name resolves to IP(s) [wld1-nsxt-vip.vrack.vsphere] 2024-02-22T19:43:25.273+0000 ERROR [vcf_dm,65d7a3dc956e4b5bc075a0f229f76e7d,05a6] [c.v.v.v.c.v1.DomainController,http-nio-127.0.0.1-7200-exec-1] Failed to validate DomainCreationSpec java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "com.vmware.evo.sddc.clustermanager.is.rest.model.spec.NsxTClusterSpec.getGeneveVlanId()" is null at com.vmware.vcf.clustermanager.controller.ClusterAssembler.getGeneveVlanId(ClusterAssembler.java:1167) at com.vmware.vcf.clustermanager.controller.ClusterAssembler.toNsxTClusterSpec(ClusterAssembler.java:1131) at com.vmware.vcf.clustermanager.controller.ClusterAssembler.toClusterSpecBase(ClusterAssembler.java:769) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)

Panic Output

No response

Expected Behavior

WLD create should succeed

Actual Behavior

WLD create fails

Steps to Reproduce

create wld with terraform apply

Environment Details

No response

Screenshots

No response

References

No response

spacegospod commented 7 months ago

@pradeep17j is this the value you used when the provider failed?

geneve_vlan_id = var.wld_cluster_settings["tep_vlan"]

Can you confirm that "var.wld_cluster_settings["tep_vlan"]" was set? The only way for this bug to occur is for you to have provided an empty string to the geneve_vlan_id input.

Please upload the exact configuration you used to reproduce, variable values inlcuded and then re-open the ticket

pradeep17j commented 7 months ago

@stoyanzhelyazkov ,

To avoid introducing errors in variable referencing ,  I directly hard coded the value in main.tf as below
geneve_vlan_id = "0"

only change between failure case and working case is the hard coded value that geneve_vlan_id is assigned to as below.

FAILURE CASE :  geneve_vlan_id = "0"

SUCCESS_CASE : geneve_vlan_id = "200"
spacegospod commented 7 months ago

Got it Pradeep, thanks. I am re-openning the issue

spacegospod commented 7 months ago

@pradeep17j I identified the bug. The problem is caused by incorrect serialization into JSON. I will have to make the fix in the SDK project https://github.com/vmware/vcf-sdk-go/tree/main

github-actions[bot] commented 6 months ago

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.