Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updating vcd_external_network_v2 with edge gateway having dedicate_external_network=true #1301

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented Aug 6, 2024

Closes #1183

About the problem

There is a bug in runtime validation that is triggered when all of the following conditions are met:

Fix

The fix is to ignore validation !usingIpSpace && d.Get("dedicated_org_id").(string) != "" during update because d.Get("dedicated_org_id") might return the value of computed field which automatically gets populated when edge gateway consumes this network (has dedicate_external_network = true).

Sample hcl

resource "vcd_external_network_v2" "ext-net-nsxt" {
  name        = "XXX"
  description = "Test External Network"

  nsxt_network {
    nsxt_manager_id      = data.vcd_nsxt_manager.main.id
    nsxt_tier0_router_id = data.vcd_nsxt_tier0_router.router.id
  }

  use_ip_spaces = false

  ip_scope {
    enabled       = true
    gateway       = "192.168.30.49"
    prefix_length = "24"

    static_ip_pool {
      start_address = "192.168.30.51"
      end_address   = "192.168.30.66" # Increment the end address for update to see the issue
    }
  }

}


resource "vcd_nsxt_edgegateway" "nsxt-edge" {
  # org         = "my-org"
  owner_id    = data.vcd_org_vdc.vdc1.id
  name        = "nsxt-edge"
  description = "Description"

  external_network_id       = vcd_external_network_v2.ext-net-nsxt.id
  dedicate_external_network = true

  subnet {
    gateway       = "192.168.30.49"
    prefix_length = "24"
    primary_ip = "192.168.30.51"
    allocated_ips {
      start_address = "192.168.30.51"
      end_address   = "192.168.30.60"
    }
  }
}

Replicating

commit da78097 has a test that hits the issue

Signed-off-by: Dainius Serplis <[email protected]>
Signed-off-by: Dainius Serplis <[email protected]>
Signed-off-by: Dainius Serplis <[email protected]>
@Didainius Didainius marked this pull request as ready for review August 7, 2024 04:04
Copy link
Collaborator

@adambarreiro adambarreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky computed attributes 🙂
LGTM, test passed

@lvirbalas lvirbalas changed the title Fix bug when updating vcd_external_network_v2 and edge gateway has dedicate_external_network=true Fix updating vcd_external_network_v2 with edge gateway having dedicate_external_network=true Aug 16, 2024
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Didainius Didainius merged commit e9c95cf into vmware:main Aug 19, 2024
2 checks passed
@Didainius Didainius deleted the issue-1183 branch August 19, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: could not get network data: 'dedicated_org_id' modifying "vcd_external_network_v2" resource
3 participants