Missing xml namespace in UpdateNetworkConnectionSection payload
Describe the bug
When provisioning a VM with terraform the UpdateNetworkConnectionSection call is executed/scheduled but fails with HTTP 400 Bad Request
- cvc-elt.1.a: Cannot find the declaration of element 'NetworkConnectionSection'
Analysing the logs we've discovered that the namespace "http://www.vmware.com/vcloud/v1.5" is missing from the call payload.
This happens to us when using terraform provider v3.5.1 (most recent) and not v3.4.0.
Reproduction steps
Like I said we're experiencing this when using the library via terraform vcd provider. The relevant resource:
resource "vcd_vm" "template_vm" {
name = "template_vm"
catalog_name = var.source_catalog
template_name = var.source_template
cpus = 1
memory = 1024
cpu_hot_add_enabled = true
memory_hot_add_enabled = true
network_dhcp_wait_seconds = 300
network {
name = "template-network"
type = "org"
ip_allocation_mode = "DHCP"
}
}
The relevant call's log:
2022/01/27 08:09:49 --------------------------------------------------------------------------------
2022/01/27 08:09:49 Request caller: govcd.(*VM).UpdateNetworkConnectionSection-->govcd.(*VM).UpdateNetworkConnectionSection-->govcd.executeRequestWithApiVersion-->govcd.(*Client).executeTaskRequest-->govcd.executeRequestCustomErr-->govcd.executeRequestCustomErr-->govcd.(*Client).newRequest
2022/01/27 08:09:49 PUT https://XXXXXX/api/vApp/vm-39a29fbe-85ce-4bf0-baaa-857415482966/networkConnectionSection/
2022/01/27 08:09:49 --------------------------------------------------------------------------------
2022/01/27 08:09:49 Req header:
2022/01/27 08:09:49 X-Vmware-Vcloud-Access-Token: [********]
2022/01/27 08:09:49 Accept: [application/*+xml;version=33.0]
2022/01/27 08:09:49 X-Vmware-Vcloud-Token-Type: [Bearer]
2022/01/27 08:09:49 Authorization: [********]
2022/01/27 08:09:49 User-Agent: [terraform-provider-vcd/v3.5.1 (windows/amd64; isProvider:false)]
2022/01/27 08:09:49 Request data: [873]
<?xml version="1.0" encoding="UTF-8"?>
<NetworkConnectionSection xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" href="https://XXXXXX/api/vApp/vm-39a29fbe-85ce-4bf0-baaa-857415482966/networkConnectionSection/" type="application/vnd.vmware.vcloud.networkConnectionSection+xml">
<ovf:Info></ovf:Info>
<PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
<NetworkConnection network="TemplateNetwork">
<NetworkConnectionIndex>0</NetworkConnectionIndex>
<IsConnected>true</IsConnected>
<IpAddressAllocationMode>DHCP</IpAddressAllocationMode>
</NetworkConnection>
<Link href="https://XXXXXX/api/vApp/vm-39a29fbe-85ce-4bf0-baaa-857415482966/networkConnectionSection/" type="application/vnd.vmware.vcloud.networkConnectionSection+json" rel="edit"></Link>
</NetworkConnectionSection>
2022/01/27 08:09:49 ################################################################################
2022/01/27 08:09:49 Response caller govcd.(*VM).UpdateNetworkConnectionSection-->govcd.(*VM).UpdateNetworkConnectionSection-->govcd.executeRequestWithApiVersion-->govcd.(*Client).executeTaskRequest-->govcd.executeRequestCustomErr-->govcd.checkRespWithErrType-->govcd.ParseErr-->govcd.decodeBody
2022/01/27 08:09:49 Response status 400 Bad Request
2022/01/27 08:09:49 ################################################################################
2022/01/27 08:09:49 Response header:
2022/01/27 08:09:49 Strict-Transport-Security: [max-age=15768000]
2022/01/27 08:09:49 Server: [cloudflare]
2022/01/27 08:09:49 Cf-Ray: [6d40285eea274c2b-AMS]
2022/01/27 08:09:49 Connection: [keep-alive]
2022/01/27 08:09:49 X-Vmware-Vcloud-Request-Id: [92d706c8-d736-4ac3-8ec1-1a2814914a8f]
2022/01/27 08:09:49 X-Vmware-Vcloud-Request-Execution-Time: [21]
2022/01/27 08:09:49 Cf-Cache-Status: [DYNAMIC]
2022/01/27 08:09:49 Cache-Control: [no-store, must-revalidate]
2022/01/27 08:09:49 Content-Type: [application/vnd.vmware.vcloud.error+xml;version=33.0]
2022/01/27 08:09:49 Expect-Ct: [max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"]
2022/01/27 08:09:49 Date: [Thu, 27 Jan 2022 07:09:49 GMT]
2022/01/27 08:09:49 X-Vmware-Vcloud-Ceip-Id: [b77e552b-7dad-443c-84ef-be4abd75e936]
2022/01/27 08:09:49 Response text: [833]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:Error xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:ns2="http://www.vmware.com/vcloud/v1.5" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:ovfenv="http://schemas.dmtf.org/ovf/environment/1" xmlns:ns9="http://www.vmware.com/vcloud/versions" message="[ 92d706c8-d736-4ac3-8ec1-1a2814914a8f ] HTTP 400 Bad Request - cvc-elt.1.a: Cannot find the declaration of element 'NetworkConnectionSection'." majorErrorCode="400" minorErrorCode="BAD_REQUEST"/>
Note how xmlns with a value of "http://www.vmware.com/vcloud/v1.5" is missing from the payload.
Expected behavior
For comparison, the terraform provider 3.4.0 succeeds, the relevant part of the log:
2022/01/26 16:58:22 --------------------------------------------------------------------------------
2022/01/26 16:58:22 Request caller: govcd.(*VM).UpdateNetworkConnectionSection-->govcd.(*VM).UpdateNetworkConnectionSection-->govcd.executeRequestWithApiVersion-->govcd.(*Client).executeTaskRequest-->govcd.executeRequestCustomErr-->govcd.executeRequestCustomErr-->govcd.(*Client).newRequest
2022/01/26 16:58:22 PUT https://XXXXXX/api/vApp/vm-b3ff0546-c8dc-4595-bf72-0335ce2b2635/networkConnectionSection/
2022/01/26 16:58:22 --------------------------------------------------------------------------------
2022/01/26 16:58:22 Req header:
2022/01/26 16:58:22 X-Vmware-Vcloud-Token-Type: [Bearer]
2022/01/26 16:58:22 Authorization: [********]
2022/01/26 16:58:22 User-Agent: [terraform-provider-vcd/v3.4.0 (linux/amd64; isProvider:false)]
2022/01/26 16:58:22 X-Vmware-Vcloud-Access-Token: [********]
2022/01/26 16:58:22 Accept: [application/*+xml;version=33.0]
2022/01/26 16:58:22 Request data: [916]
<?xml version="1.0" encoding="UTF-8"?>
<NetworkConnectionSection xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" href="https://XXXXXX/api/vApp/vm-b3ff0546-c8dc-4595-bf72-0335ce2b2635/networkConnectionSection/" type="application/vnd.vmware.vcloud.networkConnectionSection+xml">
<ovf:Info></ovf:Info>
<PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
<NetworkConnection network="template-builder">
<NetworkConnectionIndex>0</NetworkConnectionIndex>
<IsConnected>true</IsConnected>
<IpAddressAllocationMode>DHCP</IpAddressAllocationMode>
</NetworkConnection>
<Link href="https://XXXXXX/api/vApp/vm-b3ff0546-c8dc-4595-bf72-0335ce2b2635/networkConnectionSection/" type="application/vnd.vmware.vcloud.networkConnectionSection+json" rel="edit"></Link>
</NetworkConnectionSection>
2022/01/26 16:58:22 ################################################################################
2022/01/26 16:58:22 Response caller schema.(*Resource).create-->vcd.resourceVcdStandaloneVmCreate-->vcd.genericResourceVmCreate-->vcd.resourceVcdVAppVmUpdateExecute-->govcd.(*VM).UpdateNetworkConnectionSection-->govcd.(*VM).UpdateNetworkConnectionSection-->govcd.(*Client).executeTaskRequest-->govcd.decodeBody
2022/01/26 16:58:22 Response status 202 Accepted
2022/01/26 16:58:22 ################################################################################
2022/01/26 16:58:22 Response header:
2022/01/26 16:58:22 Server: [cloudflare]
2022/01/26 16:58:22 Location: [https://XXXXXX/api/task/60e3246b-d415-4566-b17b-2b46b62c99a6]
2022/01/26 16:58:22 Date: [Wed, 26 Jan 2022 15:58:18 GMT]
2022/01/26 16:58:22 Connection: [keep-alive]
2022/01/26 16:58:22 Strict-Transport-Security: [max-age=15768000]
2022/01/26 16:58:22 Content-Type: [application/vnd.vmware.vcloud.task+xml;version=33.0]
2022/01/26 16:58:22 X-Vmware-Vcloud-Request-Id: [57a2c435-a5dd-4535-96d2-21447e367f34]
2022/01/26 16:58:22 X-Vmware-Vcloud-Ceip-Id: [b77e552b-7dad-443c-84ef-be4abd75e936]
2022/01/26 16:58:22 Expect-Ct: [max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"]
2022/01/26 16:58:22 X-Vmware-Vcloud-Request-Execution-Time: [349]
2022/01/26 16:58:22 Cf-Cache-Status: [DYNAMIC]
2022/01/26 16:58:22 Cache-Control: [no-store, must-revalidate]
2022/01/26 16:58:22 Cf-Ray: [6d3af1202ba200cd-AMS]
2022/01/26 16:58:22 Vary: [Accept-Encoding, User-Agent]
2022/01/26 16:58:22 Response text: [1771]
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Task xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:ovfenv="http://schemas.dmtf.org/ovf/environment/1" xmlns:ns9="http://www.vmware.com/vcloud/versions" status="queued" operation="Updating Virtual Machine centos7-template-1(b3ff0546-c8dc-4595-bf72-0335ce2b2635)" operationName="vappUpdateVm" serviceNamespace="com.vmware.vcloud" startTime="2022-01-26T15:58:17.101Z" expiryTime="2022-04-26T15:58:17.101Z" cancelRequested="false" name="task" id="urn:vcloud:task:60e3246b-d415-4566-b17b-2b46b62c99a6" href="https://XXXXXX/api/task/60e3246b-d415-4566-b17b-2b46b62c99a6" type="application/vnd.vmware.vcloud.task+xml">
<Owner href="https://XXXXXX/api/vApp/vm-b3ff0546-c8dc-4595-bf72-0335ce2b2635" id="urn:vcloud:vm:b3ff0546-c8dc-4595-bf72-0335ce2b2635" type="application/vnd.vmware.vcloud.vm+xml" name="centos7-template-1"/>
<User href="https://XXXXXX/api/admin/user/493d712a-8f87-4e14-8049-8f7f582e5255" id="urn:vcloud:user:493d712a-8f87-4e14-8049-8f7f582e5255" type="application/vnd.vmware.admin.user+xml" name="d145perfarba"/>
<Organization href="https://XXXXXX/api/org/f1d23f76-7631-4dd3-a979-967a2c89b207" id="urn:vcloud:org:f1d23f76-7631-4dd3-a979-967a2c89b207" type="application/vnd.vmware.vcloud.org+xml" name="ORG-C10446"/>
<Details></Details>
</Task>
Notice xmlns="http://www.vmware.com/vcloud/v1.5" in the call payload
Additional context
No response
Hello and thanks for the issue - a quick question - which VCD version are you running? Also - are you under some specific load balancer/waf? (I expect cloudflare)
VCD 10.3.1, yes, it's behind cloudflare.