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

Allows to remove network interface from VM with hot update #568

Merged
merged 27 commits into from
Oct 13, 2020

Conversation

vbauzys
Copy link
Contributor

@vbauzys vbauzys commented Oct 6, 2020

Ref: #388

This change allows to make hot VM network interface removal.
Limitations of network interface removal is on only in 10.1 version due the bug.

Tested on 9.7 and 10.0

Merge branch 'master' of github.com:vmware/terraform-provider-vcd
Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

Looks suspicious:

=== RUN   TestAccVcdVAppVmMultiNIC
    testing.go:654: Step 0 error: Check failed: 1 error occurred:
                * Check 37/75 error: vcd_vapp_vm.TestAccVcdVAppVmMultiNICVM: Attribute 'network.3.mac' expected "00:00:00:11:11:11", got "00:50:56:1c:17:61"


--- FAIL: TestAccVcdVAppVmMultiNIC (362.22s)

vcd/resource_vcd_vapp_vm.go Outdated Show resolved Hide resolved
Merge branch 'master' of github.com:vmware/terraform-provider-vcd
Merge branch 'master' of github.com:vmware/terraform-provider-vcd
# Conflicts:
#	scripts/skip-upgrade-tests.txt
#	vcd/resource_vcd_vapp_vm.go
@vbauzys
Copy link
Contributor Author

vbauzys commented Oct 8, 2020

Looks suspicious:

=== RUN   TestAccVcdVAppVmMultiNIC
    testing.go:654: Step 0 error: Check failed: 1 error occurred:
                * Check 37/75 error: vcd_vapp_vm.TestAccVcdVAppVmMultiNICVM: Attribute 'network.3.mac' expected "00:00:00:11:11:11", got "00:50:56:1c:17:61"


--- FAIL: TestAccVcdVAppVmMultiNIC (362.22s)

After merge can't reproduce. Looks ok.

}

network {
type = "org"
name = vcd_vapp_org_network.vappNetwork1.org_network_name
ip_allocation_mode = "DHCP"
is_primary = true
is_primary = "true"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why quoting here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Merge branch 'master' of github.com:vmware/terraform-provider-vcd
@@ -46,6 +46,12 @@ The following fields were removed from resources in *v3.0*:
* `resource/vcd_vm_affinity_rule.virtual_machine_ids` renamed to `vm_ids`


## Removed resources and fields
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Is there a change log entry somewhere else?

  2. I can't make it work. I'm removing NIC, it's an update as expected, but getting this error:

vcd_vapp_vm.demo_vm_wordpress: Still modifying... [id=urn:vcloud:vm:7417411f-14d7-4b02-8e19-228b7d3a1b10, 30s elapsed]

Error: unable to update network configuration: error updating network connection: API Error: 400: NICs with indices '0' cannot be removed while VM is powered on.

  on radio2020.tf line 318, in resource "vcd_vapp_vm" "demo_vm_wordpress":
 318: resource "vcd_vapp_vm" "demo_vm_wordpress" {

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. I just tried with two NICs and to remove the 2nd one. Same error:
  # vcd_vapp_vm.demo_vm_wordpress will be updated in-place
  ~ resource "vcd_vapp_vm" "demo_vm_wordpress" {
        accept_all_eulas               = true
        catalog_name                   = "shared-catalog"
        computer_name                  = "bitnami-wordpress-532-2-r01-linux-centos-7-x8664-001"
        cpu_cores                      = 1
        cpu_hot_add_enabled            = false
        cpus                           = 1
        expose_hardware_virtualization = false
        guest_properties               = {
            "demo.setting" = "Guest property set by Terraform vCD Provider"
        }
        hardware_version               = "vmx-08"
        href                           = "https://bos1-vcloud-static-171-124.eng.vmware.com/api/vApp/vm-7417411f-14d7-4b02-8e19-228b7d3a1b10"
        id                             = "urn:vcloud:vm:7417411f-14d7-4b02-8e19-228b7d3a1b10"
        internal_disk                  = [
            {
                bus_number       = 0
                bus_type         = "parallel"
                disk_id          = "2000"
                iops             = 0
                size_in_mb       = 10240
                storage_profile  = "*"
                thin_provisioned = true
                unit_number      = 0
            },
        ]
        memory                         = 512
        memory_hot_add_enabled         = false
        metadata                       = {
            "demo_data" = "Terraform vCD Provider"
        }
        name                           = "demo-vm-wordpress"
        os_type                        = "otherLinux64Guest"
        power_on                       = true
        prevent_update_power_off       = false
        sizing_policy_id               = "urn:vcloud:vdcComputePolicy:1489d852-56d3-4931-b2d3-6d77a7c8f1c7"
        storage_profile                = "*"
        template_name                  = "bitnami-wordpress-5.3.2-2-r01-linux-centos-7-x86_64"
        vapp_name                      = "demo-web"

        customization {
            admin_password                      = (sensitive value)
            allow_local_admin_password          = true
            auto_generate_password              = true
            change_sid                          = false
            enabled                             = true
            force                               = false
            join_domain                         = false
            join_org_domain                     = false
            must_change_password_on_first_login = false
            number_of_auto_logons               = 0
        }

        network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "192.168.0.2"
            ip_allocation_mode = "POOL"
            is_primary         = true
            mac                = "00:50:56:29:00:0a"
            name               = "demo-net-web"
            type               = "org"
        }
      - network {
          - adapter_type       = "E1000" -> null
          - connected          = true -> null
          - ip                 = "192.168.0.6" -> null
          - ip_allocation_mode = "POOL" -> null
          - is_primary         = false -> null
          - mac                = "00:50:56:29:00:0f" -> null
          - name               = "demo-net-web" -> null
          - type               = "org" -> null
        }
    }

Plan: 0 to add, 2 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

vcd_vapp_vm.demo_vm_wordpress: Modifying... [id=urn:vcloud:vm:7417411f-14d7-4b02-8e19-228b7d3a1b10]
vcd_vapp_vm.demo_vm_wordpress: Still modifying... [id=urn:vcloud:vm:7417411f-14d7-4b02-8e19-228b7d3a1b10, 10s elapsed]
vcd_vapp_vm.demo_vm_wordpress: Still modifying... [id=urn:vcloud:vm:7417411f-14d7-4b02-8e19-228b7d3a1b10, 20s elapsed]

Error: unable to update network configuration: error updating network connection: API Error: 400: NICs with indices '1' cannot be removed while VM is powered on.

  on radio2020.tf line 318, in resource "vcd_vapp_vm" "demo_vm_wordpress":
 318: resource "vcd_vapp_vm" "demo_vm_wordpress" {

Copy link

@jpbuecken jpbuecken Oct 8, 2020

Choose a reason for hiding this comment

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

That is strange, I tested with VCD 10.0 and I could remove all interfaces, even that one that is_primary and has index 0

Did you test with VCD 10.1? I had that message there in the UI (did not test this PR with VCD 10.1 yet). Maybe the exception to cold plug for VCD 10.1 does not work?

By the way, will prevent_update_power_off = true work for VCD 10.1 (warn user) but let it go on VCD 10.0 since it is a online change?

Copy link

@jpbuecken jpbuecken Oct 8, 2020

Choose a reason for hiding this comment

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

Just tested VCD10.1. prevent_update_power_off and the code worked as expected (hot add, cold remove with warning)

I tested with SLES12 and SLES15 Guest OS (64bit)

@lvirbalas What guest os does you VM have? Maybe, just for testing, you change the "Operating System" value in VCD to "SUSE Linux Enterprise 15 (64bit)" (it does not really matter what os is really installed for this test.)

EDIT: I just changed my "Operating System" value to Windows 2016 and newer. It worked with my linux os inside on VCD10.0 as well...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Need @Didainius @dataclouder help to try this scenario too.

Situation for now:

  • Above issue on 10.2
  • For @vbauzysvmware works on 10.1

Copy link
Collaborator

Choose a reason for hiding this comment

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

What guest os does you VM have?

bitnami-wordpress-5.3.2-2-r01-linux-centos-7-x86_64

Maybe, just for testing, you change the "Operating System" value in VCD to "SUSE Linux Enterprise 15 (64bit)" (it does not really matter what os is really installed for this test.)

It was "Other Linux", changed to "CentOS 4/5/6 (64-bit)" and then to "SUSE Linux Enterprise 10 (64-bit)", but same error.

@Didainius found references:

https://kb.vmware.com/s/article/2081503

https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.networking.doc/GUID-1A9F0D79-7A78-44D2-8401-33A004C384FB.html

Copy link
Collaborator

Choose a reason for hiding this comment

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

p.s. Tried adding vmx.hotRemoveWait = 120 to VM configuration through vSphere, but same error (and in same time).

VMware Tools: Running, version:10336 (Guest Managed)

Choose a reason for hiding this comment

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

Maybe it is not fixed in your beta of VCD 10.2 yet. VMware only promised us they will fix it for the release.
Anyway, for centos7 the "CentOS 7 (64bit)" Operating System value is the correct one

image

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.

Though hot removal is not possible in all cases, the new "Hot and Cold update" doc section helps to understand the details. LGTM now!

Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

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

Thanks for all the troubles and solutions.
I have had acceptance, binary and upgrade tests passing on various instances. In some cases last (primary) interface is not allowed to be hot-removed, but that is probably not too often that all adapters are removed and there is a way to go around it by first powering of the VM (power_on=false).

@vbauzys vbauzys changed the title Allows to remove network interfance from VM with hot update Allows to remove network interface from VM with hot update Oct 13, 2020
@vbauzys vbauzys merged commit bfeecd8 into vmware:master Oct 13, 2020
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.

6 participants