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

Patch XML namespace problem for vm. UpdateNetworkConnectionSection #677

Merged
merged 2 commits into from
May 13, 2024

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented May 13, 2024

Closes #429

Problem

In some cases, vm.UpdateNetworkConnectionSection fails with error similar toHTTP 400 Bad Request - cvc-elt.1.a: Cannot find the declaration of element 'NetworkConnectionSection'

The cause

The vm.UpdateNetworkConnectionSection at first retrieves existing network configuration (vm.GetNetworkConnectionSection) and the modifies it.

In some environments, there is a problem that in some cases VCD randomly (not always) puts the payload for GET query into ns2 namespace.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:NetworkConnectionSection 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=......

For reference, the regular normal payload that this call returns (not wrapped into ns2 namespace)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<NetworkConnectionSection 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/](http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData).....

Because Go XML library has issues with namespace handling (golang/go#9519), the Xmlns attribute value http://www.vmware.com/vcloud/v1.5 gets lost in translation and this causes the described error when update occurs.

The fix

The fix is to set hardcoded setting for Xmlns to http://www.vmware.com/vcloud/v1.5 for every update call. This will prevent malformed XML document query.

Testing

I have triggered tests that include call to the methodvm.UpdateNetworkConnectionSection and none of them failed:

  • Test_AddNewEmptyVMMultiNIC
  • Test_GetNetworkConnectionSection
  • Test_VMGetDhcpAddress
  • Test_NsxtSecurityGroupGetAssociatedVms

Signed-off-by: Dainius Serplis <dserplis@vmware.com>
@Didainius Didainius changed the title Patch XML namespace problem Patch XML namespace problem for vm. UpdateNetworkConnectionSection May 13, 2024
@Didainius Didainius marked this pull request as ready for review May 13, 2024 07:45
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
@Didainius Didainius merged commit 2aed4dc into vmware:main May 13, 2024
@Didainius Didainius deleted the patch-network-latest branch May 13, 2024 09:31
@dataclouder dataclouder mentioned this pull request Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing xml namespace in UpdateNetworkConnectionSection payload
5 participants