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

Fixes for release 3.5.0 #761

Merged
merged 4 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changes/v3.5.0/761-bug-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Skip tests for resources not available in 10.1 [GH-761]
* Fix wrong references in `TestAccVcdVAppVmMultiNIC` [GH-761]
2 changes: 2 additions & 0 deletions vcd/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func testSpecificDataSourceNotFound(t *testing.T, dataSourceName string, vcdClie
t.Skip(`Works only with system admin privileges`)
case dataSourceName == "vcd_external_network_v2" && vcdClient.Client.APIVCDMaxVersionIs("< 33"):
t.Skip("External network V2 requires at least API version 33 (VCD 10.0+)")
case (dataSourceName == "vcd_library_certificate" || dataSourceName == "vcd_vdc_group") && vcdClient.Client.APIVCDMaxVersionIs("< 35"):
t.Skipf("%s requires at least API version 34 (VCD 10.2+)", dataSourceName)
case (dataSourceName == "vcd_nsxt_edgegateway" || dataSourceName == "vcd_nsxt_edge_cluster" ||
dataSourceName == "vcd_nsxt_security_group" || dataSourceName == "vcd_nsxt_nat_rule" ||
dataSourceName == "vcd_nsxt_app_port_profile" || dataSourceName == "vcd_nsxt_ip_set") &&
Expand Down
7 changes: 6 additions & 1 deletion vcd/datasource_vcd_resource_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestAccVcdDatasourceResourceList(t *testing.T) {
{"global_role", "vcd_global_role", "", "vApp Author"},
{"rights_bundle", "vcd_rights_bundle", "", "Default Rights Bundle"},
{"right", "vcd_right", "", "Catalog: Change Owner"},
{"library_certificate", "vcd_library_certificate", "", ""},

// entities belonging to an Org don't require an explicit parent, as it is given from the Org passed in the provider
// For each resource, we test with and without and explicit parent
Expand Down Expand Up @@ -77,6 +76,12 @@ func TestAccVcdDatasourceResourceList(t *testing.T) {
{"lb_app_profile", "vcd_lb_app_profile", testConfig.Networking.EdgeGateway, ""},
{"lb_app_rule", "vcd_lb_app_rule", testConfig.Networking.EdgeGateway, ""},
}
vcdClient := createTemporaryVCDConnection(true)
if vcdClient != nil && vcdClient.Client.APIVCDMaxVersionIs(">= 35") {
lists = append(lists,
listDef{"library_certificate", "vcd_library_certificate", "", ""},
)
}
for _, def := range lists {
t.Run(def.name+"-"+def.resourceType, func(t *testing.T) { runResourceInfoTest(def, t) })
}
Expand Down
8 changes: 4 additions & 4 deletions vcd/resource_vcd_vapp_vm_customization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,11 @@ resource "vcd_vapp_vm" "test-vm-step2" {
cpu_cores = 1

customization {
enabled = false
admin_password = "some password"
enabled = false
admin_password = "some password"
auto_generate_password = false
join_domain = true
join_org_domain = true
join_domain = true
join_org_domain = true
}
}
`
Expand Down
22 changes: 11 additions & 11 deletions vcd/resource_vcd_vapp_vm_multinetwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ resource "vcd_vapp" "{{.VAppName}}" {
vdc = "{{.Vdc}}"

name = "{{.VAppName}}"
depends_on = ["vcd_network_routed.net", "vcd_network_routed.net2"]
depends_on = [vcd_network_routed.net, vcd_network_routed.net2]
}

resource "vcd_vapp_network" "vappIsolatedNet" {
Expand Down Expand Up @@ -362,22 +362,22 @@ resource "vcd_vapp_vm" "{{.VMName}}" {

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
ip_allocation_mode = "POOL"
is_primary = false
adapter_type = "PCNet32"
}

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
ip_allocation_mode = "DHCP"
is_primary = true
}

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
ip = "11.10.0.170"
ip_allocation_mode = "MANUAL"
is_primary = false
Expand All @@ -387,7 +387,7 @@ resource "vcd_vapp_vm" "{{.VMName}}" {

network {
type = "org"
name = vcd_network_routed.net2.name
name = vcd_vapp_org_network.vappAttachedRoutedNet2.org_network_name
ip_allocation_mode = "POOL"
is_primary = false
adapter_type = "e1000e"
Expand Down Expand Up @@ -430,7 +430,7 @@ resource "vcd_vapp_vm" "{{.VMName}}" {

network {
type = "org"
name = vcd_vapp_org_network.vappAttachedRoutedNet2.org_network_name
name = vcd_vapp_org_network.vappAttachedRoutedNet2.org_network_name
ip_allocation_mode = "POOL"
}
}
Expand All @@ -452,21 +452,21 @@ resource "vcd_vapp_vm" "{{.VMName}}" {

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
ip_allocation_mode = "POOL"
is_primary = true
}

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
ip_allocation_mode = "DHCP"
is_primary = false
}

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
ip = "11.10.0.170"
ip_allocation_mode = "MANUAL"
is_primary = false
Expand All @@ -475,7 +475,7 @@ resource "vcd_vapp_vm" "{{.VMName}}" {

network {
type = "org"
name = vcd_network_routed.net2.name
name = vcd_vapp_org_network.vappAttachedRoutedNet2.org_network_name
ip_allocation_mode = "POOL"
is_primary = false
mac = "00:00:00:11:11:11"
Expand Down Expand Up @@ -547,7 +547,7 @@ resource "vcd_vapp_vm" "{{.VMName}}" {

network {
type = "org"
name = vcd_network_routed.net.name
name = vcd_vapp_org_network.vappAttachedNet.org_network_name
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason behind all these changes from Routed to vApp Org network?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for the failures was that we had the wrong reference for the network name.
Both references in the end result to the same name, but, when we refer to the vapp network, Terraform will wait for the VM to be destroyed before destroying the vapp network.
When we instead refer to the Org network, Terraform will try destruction in parallel. Sometimes the operation succeeds, and sometimes it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also explained in the commit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To add - this actually dates back to when we introduced vcd_vapp_org_network resource instead of doing "attachment magic" inside vcd_vapp_vm. Back then we tuned our examples and code in many places, however it looks there are still places left.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you, this, indeed, reminds me of very similar issues with dependencies I had long time ago.

ip_allocation_mode = "POOL"
adapter_type = "vmxnet2"
}
Expand Down