vmware / terraform-provider-vra

Terraform Provider for VMware Aria Automation
https://registry.terraform.io/providers/vmware/vra/
Mozilla Public License 2.0
101 stars 89 forks source link

`r/vra_image_profile` creation fails with more 4 image mappings #528

Open PaulAngus opened 2 months ago

PaulAngus commented 2 months ago

Code of Conduct

This project has a Code of Conduct that all participants are expected to understand and follow:

vRA Version

8.16.1

Terraform Version

1.6.6

vRA Terraform Provider Version

0.9.0

Affected Resource(s)

vra_image_profile

Terraform Configuration Files

Note: This is a truncated version of the code for demo purposes.

data "vra_region" "region_SW19-1" {
  filter = "name eq SW19-1-DC"
}

data "vra_region" "region_SW19-2" {
  filter = "name eq SW19-2-DC"
}

data "vra_cloud_account_vsphere" "SW19-1" {
  name = "VCS - SW19-1"
}

data "vra_cloud_account_vsphere" "SW19-2" {
  name = "VCS - SW19-2"
}

data "vra_image" "Micro-Linux-SW19-1" {
  filter = "name eq 'AlpineLinux-Template' and cloudAccountId eq '${data.vra_cloud_account_vsphere.SW19-1.id}'"
}

data "vra_image" "Micro-Linux-SW19-2" {
  filter = "name eq 'AlpineLinux-Template' and cloudAccountId eq '${data.vra_cloud_account_vsphere.SW19-2.id}'"
}

data "vra_image" "Ubuntu22-04-SW19-1" {
  filter = "name eq 'ubuntu-jammy-22.04-cloudimg' and cloudAccountId eq '${data.vra_cloud_account_vsphere.SW19-1.id}'"
}

data "vra_image" "Ubuntu22-04-SW19-2" {
  filter = "name eq 'ubuntu-jammy-22.04-cloudimg' and cloudAccountId eq '${data.vra_cloud_account_vsphere.SW19-2.id}'"
}

data "vra_image" "Oracle-8-SW19-1" {
  filter = "name eq 'Oracle8.9-Template' and cloudAccountId eq '${data.vra_cloud_account_vsphere.SW19-1.id}'"
}

data "vra_image" "Oracle-8-SW19-2" {
  filter = "name eq 'Oracle8.9-Template' and cloudAccountId eq '${data.vra_cloud_account_vsphere.SW19-2.id}'"
}

############ Resources ###########

resource "vra_image_profile" "mlin1" {
  name        = "test-image-profile"
  description = "test image profile"
  region_id   = data.vra_region.region_SW19-1.id

  image_mapping {
    name     = "Micro-Linux"
    image_id = data.vra_image.Micro-Linux-SW19-1.id
  }
}

resource "vra_image_profile" "mlin2" {
  name        = "test-image-profile"
  description = "test image profile"
  region_id   = data.vra_region.region_SW19-2.id

  image_mapping {
    name     = "Micro-Linux"
    image_id = data.vra_image.Micro-Linux-SW19-2.id
  }
}

resource "vra_image_profile" "mlin3" {
  name        = "test-image-profile"
  description = "test image profile"
  region_id   = data.vra_region.region_SW19-1.id

  image_mapping {
    name     = "Ubuntu22.04"
    image_id = data.vra_image.Ubuntu22-04-SW19-1.id
  }
}

resource "vra_image_profile" "mlin4" {
  name        = "test-image-profile"
  description = "test image profile"
  region_id   = data.vra_region.region_SW19-2.id

  image_mapping {
    name     = "Ubuntu22.04"
    image_id = data.vra_image.Ubuntu22-04-SW19-2.id
  }
}

resource "vra_image_profile" "mlin5" {
  name        = "test-image-profile"
  description = "test image profile"
  region_id   = data.vra_region.region_SW19-1.id

  image_mapping {
    name     = "Oracle-8"
    image_id = data.vra_image.Oracle-8-SW19-1.id
  }
}

resource "vra_image_profile" "mlin6" {
  name        = "test-image-profile"
  description = "test image profile"
  region_id   = data.vra_region.region_SW19-2.id

  image_mapping {
    name     = "Oracle-8"
    image_id = data.vra_image.Oracle-8-SW19-2.id
  }
}

Expected Behavior

All Image Mappings are created in Aria Automation Assembler.

Actual Behavior

When there are over roughly four Image Mappings (each with 2 images), errors start occuring and not all Mappings are created.

Steps to Reproduce

Using above code as an example, create (roughly) more than four Image Mappings (each with 2 images) and attempt to 'apply' the Terraform.

Screenshots

Debug Output

│ Error: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 200): {}
│ 
│   with vra_image_profile.mlin5,
│   on AriaAutoImages.tf line 61, in resource "vra_image_profile" "mlin5":
│   61: resource "vra_image_profile" "mlin5" {
│ 
╵
╷
│ Error: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 200): {}
│ 
│   with vra_image_profile.mlin6,
│   on AriaAutoImages.tf line 74, in resource "vra_image_profile" "mlin6":
│   74: resource "vra_image_profile" "mlin6" {

Panic Output

Important Factoids

When adding Mappings one by one in Terraform, the number of mappings at which errors start occuring is not consistent. Sometimes, if all state and provider data is removed and Terraform init is re-run. An 'apply' which previously failed will run successfully.

References

Community Note