CiscoDevNet / terraform-provider-dcnm

Cisco DCNM Provider
https://registry.terraform.io/providers/CiscoDevNet/dcnm/latest/docs
Mozilla Public License 2.0
8 stars 15 forks source link

Resource `dcnm_inventory` fails in NDFC 12.1.2e #123

Closed jgomezve closed 3 months ago

jgomezve commented 1 year ago

Community Note

Terraform Version

Affected Resource(s)

Terraform Configuration Files

resource "dcnm_inventory" "fabric" {
  fabric_name   = "SIMPL-BROWNFIELD"
  username      = "admin"
  password      = "cisco.123"
  max_hops      = 0
  preserve_config = "false"
  auth_protocol = 0
  config_timeout = 15
  switch_config {
    ip   = "1.2.3.4"
    role = "spine"
  }
  switch_config {
    ip   = "5.6.7.8"
    role = "border"
  }
}

Expected Behavior

The switches listed in the resources should be added to the Fabric

Actual Behavior

Terraform deploy shows dcnm_inventory.fabric: Still creating...

Steps to Reproduce

  1. terraform apply

Important Factoids

After setting TF_LOG=DEBUG it is clear that an API Call to the URL GET /appcenter/cisco/ndfc/api/v1/lan-fabricrest/control/fabrics/SIMPL-BROWNFIELD/config-preview HTTP/1.1 failed ( 500 Config Preview is already in progress for the fabric SIMPL-BROWNFIELD. Please try Config Preview later). This produces the following cascading events:

Not sure why this did not happen in a previous version of NDFC/DCNM, since the code tries that call in parallel for all the added devices

I guess a workaround would be to retry the API call if the content message states Please try config Preview Laterat this line code https://github.com/CiscoDevNet/terraform-provider-dcnm/blob/d0ff6c3b92fbe1dfbe1e55e4928a56edf2916879/dcnm/resource_dcnm_inventory.go#L854

jgomezve commented 1 year ago

The current provider code waits for the Switch to be in Normal mode before assigning the user-defined role. Unfortunately in my current setup (NDFC 12.1.2e + HW N9K) the switches goes first Normal for 10 seconds, Migration for 2 Minutes and finally back to Normal. These state changes produce the Go code to change the device role while the device is still in Migration mode.

According to Engineering this is a exepcted behaviour. Have the current version of the TF provider been tested against the latest NDFC versions (12.x) ?

dsx1123 commented 1 year ago

I am experiencing a similar issue, the previous reply is not correct, this is not a brownfield scenario, it is greenfield, as the preserve_config is false.