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

vcd_vapp_vm: network: Update of is_primary from false to true does not work for first interface #549

Closed
jpbuecken opened this issue Aug 26, 2020 · 7 comments

Comments

@jpbuecken
Copy link

jpbuecken commented Aug 26, 2020

Version

Used a self compiled version based on #543.
It includes the changes from #388

Tested with 2.9 release on VCD 10.1 as well. Same behaviour

Affected Resource(s)

Please list the resources as a list, for example:

  • vcd_vapp_vm

Terraform Configuration Files

resource "vcd_vapp_vm" "instance" {
[...]
  network {
    type               = "org"
    name               = vcd_vapp_org_network.vappnetattach.org_network_name
    adapter_type       = var.nic_controller
    ip_allocation_mode = var.private_ip == null ? "POOL" : "MANUAL"
    ip                 = var.private_ip
    is_primary         = true
  }

  network {
    type               = "org"
    name               = vcd_vapp_org_network.vappnetattach.org_network_name
    adapter_type       = var.nic_controller
    ip_allocation_mode = "POOL"
    is_primary         = false
  }

Expected Behavior

In the above HCL, switch roles of is_primary.
terraform plan should show that is_primary will be switched.
If you apply, then the roles should have been switched. This means: First interface will be false, second interface will be primary.

NOW: If you switch back again the roles should switch again.

Actual Behavior

The plan only shows change for the interface that switches from false -> true:

        network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.70.21.72"
            ip_allocation_mode = "POOL"
            is_primary         = true
            mac                = "00:50:56:01:00:d3"
            name               = "10.70.21.64-26_R"
            type               = "org"
        }
      ~ network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.70.21.80"
            ip_allocation_mode = "POOL"
          ~ is_primary         = false -> true
            mac                = "00:50:56:01:00:d4"
            name               = "10.70.21.64-26_R"
            type               = "org"
        }

Apply this anyway.

NOW: Switch back:

      ~ network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.70.21.72"
            ip_allocation_mode = "POOL"
          ~ is_primary         = false -> true
            mac                = "00:50:56:01:00:d3"
            name               = "10.70.21.64-26_R"
            type               = "org"
        }
        network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.70.21.80"
            ip_allocation_mode = "POOL"
            is_primary         = true
            mac                = "00:50:56:01:00:d4"
            name               = "10.70.21.64-26_R"
            type               = "org"
        }

Apply this

Now, run terraform plan again: It did not work to set the first interface as primary again. It still shows the diff.

@Didainius
Copy link
Collaborator

Thanks for it. Just double checking - did the release version also gave you this problem or we broke something that is untested yet?

@jpbuecken
Copy link
Author

only tested on VCD 10.1,
not tested with 2.9 release yet

@jpbuecken jpbuecken changed the title vcd_vapp_vm: network: change of is_primary does not work vcd_vapp_vm: network: change of is_primary from false to true does not work for first interface Aug 27, 2020
@jpbuecken jpbuecken changed the title vcd_vapp_vm: network: change of is_primary from false to true does not work for first interface vcd_vapp_vm: network: Update of is_primary from false to true does not work for first interface Aug 27, 2020
@jpbuecken
Copy link
Author

Tested with 2.9 release on VCD 10.1: Does not work as well, same behaviour

@vbauzys
Copy link
Contributor

vbauzys commented Oct 5, 2020

Hi @jpbuecken, could test #556 PR? - we improved is_primary handling. Would like to have external confirmation :)

@jpbuecken
Copy link
Author

Accidentally I could rollout is_primary = true for two interfaces:

The behavior is: After every apply the roles of "is_primary" switches. Funny.

Not sure if this should be taken care of by the provider.

  network {
    type               = "org"
    name               = vcd_vapp_org_network.vappnetattach.org_network_name
    adapter_type       = var.nic_controller
    ip_allocation_mode = var.private_ip == null ? "POOL" : "MANUAL"
    ip                 = var.private_ip
    is_primary         = true
  }
  network {
    type               = "org"
    name               = vcd_vapp_org_network.vappnetattach.org_network_name
    adapter_type       = var.nic_controller
    ip_allocation_mode = "POOL"
    connected          = true
    is_primary         = true
  }

@jpbuecken
Copy link
Author

jpbuecken commented Oct 8, 2020

The situation is better now.

The plan still does not show that is_primary = true will be set to false .


        network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.161.207.132"
            ip_allocation_mode = "POOL"
            is_primary         = true
            mac                = "00:50:56:01:06:c7"
            name               = "10.161.207.128-27_R"
            type               = "org"
        }
        network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.75.220.207"
            ip_allocation_mode = "POOL"
            is_primary         = false
            mac                = "00:50:56:01:06:c8"
            name               = "EXT_BACKUP01"
            type               = "org"
        }
      ~ network {
            adapter_type       = "VMXNET3"
            connected          = true
            ip                 = "10.161.207.133"
            ip_allocation_mode = "POOL"
          ~ is_primary         = false -> true
            mac                = "00:50:56:01:06:c9"
            name               = "10.161.207.128-27_R"
            type               = "org"
        }

But the more important part of this bug seems to be fixed. After i applied the above, I switched back roles again (first interface to primary). No I can apply and it is applied afterwards. (Start point of this bug was that after you can apply multiple times and it was still not changed at this point)

-> OK

EDIT: Check was done with PR #568 including merge of " Merge branch 'master' into vm-hot-netw-removal a3e37cf" ~3 hours ago

@vbauzys
Copy link
Contributor

vbauzys commented Oct 16, 2020

Accidentally I could rollout is_primary = true for two interfaces:

The behavior is: After every apply the roles of "is_primary" switches. Funny.

Not sure if this should be taken care of by the provider.

  network {
    type               = "org"
    name               = vcd_vapp_org_network.vappnetattach.org_network_name
    adapter_type       = var.nic_controller
    ip_allocation_mode = var.private_ip == null ? "POOL" : "MANUAL"
    ip                 = var.private_ip
    is_primary         = true
  }
  network {
    type               = "org"
    name               = vcd_vapp_org_network.vappnetattach.org_network_name
    adapter_type       = var.nic_controller
    ip_allocation_mode = "POOL"
    connected          = true
    is_primary         = true
  }

Yep, HCL doesn't allow to configure such validation. If were will be complains from users who expect different behaviour we will think about internal(apply phase) validation.

@vbauzys vbauzys closed this as completed Oct 16, 2020
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

No branches or pull requests

3 participants