Skip to content

Conversation

@ustcweizhou
Copy link
Contributor

@ustcweizhou ustcweizhou commented Jan 20, 2021

Description

This PR fixes an issue when move a vm from an account to another account.

Steps to reproduce the issue
(1) create a vm with multiple shared networks (in advanced zone, or advanced zone with security groups)
(2) create another account (in same domain who can also access the shared networks)
(3) move vm to new account, with a list of networkid

expected result: the vm has nics on the networks in same order as specified in API request, and nics have the same ips as before
actual result: network order is not same as specified, ips are changed.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

new code looks good, moveVMToUser is 500 lines in a single method. this deserves refactoring and the logic remains hardly verifyable by code review. testing required ;)

@shwstppr
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✖centos8 ✔debian. JID-2586

@shwstppr
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@shwstppr a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

Trillian test result (tid-3411)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 29260 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4602-t3411-kvm-centos7.zip
Smoke tests completed. 83 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@shwstppr
Copy link
Contributor

@ustcweizhou maybe it due to Simulator env but while assigning a new user, VM lost one NIC while IP for default network remained the same. Is this expected behaviour?

> list virtualmachine id=aa71e2fb-7339-485f-877a-3ac61e4b81de 
{
  "virtualmachine": {
    "account": "admin",
    "affinitygroup": [],
    "cpunumber": 1,
    "cpuspeed": 500,
    "created": "2021-01-26T11:24:28+0530",
    "details": {
      "Message.ReservedCapacityFreed.Flag": "false"
    },
    "displayname": "t2",
    "displayvm": true,
    "domain": "ROOT",
    "domainid": "284bc227-5f98-11eb-b2a8-a0afbd4a2d60",
    "guestosid": "283ee5bb-5f98-11eb-b2a8-a0afbd4a2d60",
    "haenable": false,
    "hypervisor": "Simulator",
    "id": "aa71e2fb-7339-485f-877a-3ac61e4b81de",
    "instancename": "i-2-6-QA",
    "isdynamicallyscalable": false,
    "jobid": "32b17768-41c6-485e-b4b8-23cb1c6cf862",
    "jobstatus": 0,
    "memory": 512,
    "name": "t2",
    "nic": [
      {
        "broadcasturi": "vlan://4321",
        "extradhcpoption": [],
        "gateway": "10.9.8.1",
        "id": "22c803ef-e260-496e-901d-af853d51079e",
        "ipaddress": "10.9.8.19",
        "isdefault": true,
        "isolationuri": "vlan://4321",
        "macaddress": "1e:00:da:00:01:ab",
        "netmask": "255.255.255.0",
        "networkid": "62694527-4073-4e8e-840f-1688a4652cd0",
        "networkname": "net-b",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      },
      {
        "broadcasturi": "vlan://1234",
        "extradhcpoption": [],
        "gateway": "10.9.9.1",
        "id": "55cb9940-14c7-46df-a83b-72419bb52ce4",
        "ipaddress": "10.9.9.24",
        "isdefault": false,
        "isolationuri": "vlan://1234",
        "macaddress": "1e:00:0d:00:01:9c",
        "netmask": "255.255.255.0",
        "networkid": "7e686848-e92a-449a-b1e3-cb0e5116ea7f",
        "networkname": "net-a",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      }
    ],
    "osdisplayname": "CentOS 5.6 (64-bit)",
    "ostypeid": "283ee5bb-5f98-11eb-b2a8-a0afbd4a2d60",
    "passwordenabled": false,
    "rootdeviceid": 0,
    "rootdevicetype": "ROOT",
    "securitygroup": [],
    "serviceofferingid": "a0194498-2a06-4110-9db1-99020ba9a326",
    "serviceofferingname": "Small Instance",
    "state": "Stopped",
    "tags": [],
    "templatedisplaytext": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "templateid": "68a1f0ce-5f98-11eb-b2a8-a0afbd4a2d60",
    "templatename": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "userid": "284f2b10-5f98-11eb-b2a8-a0afbd4a2d60",
    "username": "admin",
    "zoneid": "390f525e-6c46-432d-8552-6519980f34c3",
    "zonename": "Sandbox-simulator"
  }
}

After assigning new user,

> assign virtualmachine virtualmachineid=aa71e2fb-7339-485f-877a-3ac61e4b81de account=admin1 domainid=284bc227-5f98-11eb-b2a8-a0afbd4a2d60 
{
  "virtualmachine": {
    "account": "admin1",
    "affinitygroup": [],
    "cpunumber": 1,
    "cpuspeed": 500,
    "created": "2021-01-26T11:24:28+0530",
    "details": {
      "Message.ReservedCapacityFreed.Flag": "false"
    },
    "displayname": "t2",
    "displayvm": true,
    "domain": "ROOT",
    "domainid": "284bc227-5f98-11eb-b2a8-a0afbd4a2d60",
    "guestosid": "283ee5bb-5f98-11eb-b2a8-a0afbd4a2d60",
    "haenable": false,
    "hypervisor": "Simulator",
    "id": "aa71e2fb-7339-485f-877a-3ac61e4b81de",
    "instancename": "i-2-6-QA",
    "isdynamicallyscalable": false,
    "memory": 512,
    "name": "t2",
    "nic": [
      {
        "broadcasturi": "vlan://4321",
        "extradhcpoption": [],
        "gateway": "10.9.8.1",
        "id": "4c1ae559-b16d-4535-a2aa-95095a6904aa",
        "ipaddress": "10.9.8.19",
        "isdefault": true,
        "isolationuri": "vlan://4321",
        "macaddress": "1e:00:ea:00:01:ab",
        "netmask": "255.255.255.0",
        "networkid": "62694527-4073-4e8e-840f-1688a4652cd0",
        "networkname": "net-b",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      }
    ],
    "osdisplayname": "CentOS 5.6 (64-bit)",
    "ostypeid": "283ee5bb-5f98-11eb-b2a8-a0afbd4a2d60",
    "passwordenabled": false,
    "rootdeviceid": 0,
    "rootdevicetype": "ROOT",
    "securitygroup": [],
    "serviceofferingid": "a0194498-2a06-4110-9db1-99020ba9a326",
    "serviceofferingname": "Small Instance",
    "state": "Stopped",
    "tags": [],
    "templatedisplaytext": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "templateid": "68a1f0ce-5f98-11eb-b2a8-a0afbd4a2d60",
    "templatename": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "userid": "284f2b10-5f98-11eb-b2a8-a0afbd4a2d60",
    "username": "admin",
    "zoneid": "390f525e-6c46-432d-8552-6519980f34c3",
    "zonename": "Sandbox-simulator"
  }
}

@weizhouapache
Copy link
Member

false,
"isolationuri": "vlan://1234",
"macaddress": "1e:00:0d:00:01:9c",
"netmask": "255.255.255.0",
"networkid": "7e686848-e92a-449a-b1e3-cb0e5116ea7f",
"networkname": "net-a",
"secondaryip": [],

@shwstppr I will look into it.
what type of zone in simulator env ? advanced zone with isolated networks or security groups ?

@rohityadavcloud
Copy link
Member

@weizhouapache that's the adv zone created by https://github.com/apache/cloudstack/blob/master/setup/dev/advanced.cfg but it would be a good idea to test SG envs as well

@weizhouapache
Copy link
Member

@weizhouapache that's the adv zone created by https://github.com/apache/cloudstack/blob/master/setup/dev/advanced.cfg but it would be a good idea to test SG envs as well

@rhtyd thanks. I will investigate it.

@weizhouapache
Copy link
Member

@weizhouapache that's the adv zone created by https://github.com/apache/cloudstack/blob/master/setup/dev/advanced.cfg but it would be a good idea to test SG envs as well

@rhtyd thanks. I will investigate it.

@shwstppr
I check the source code, the logic is

(1) if there is no network in api request,
(1.1) if the first nic of old vm is Shared and can be used by new user, then use it as default.
(1.2) if first nic is not Shared or cannot be used by new user, then create a new isolated network (advanced zone) or throw exception (advanced zone with security groups).

(2) if there is a list of networks in api request,
(2.1) check if new user can use the networks.
(2.2) if not, throw an exception.

this pr fixes

  1. vm nics after moving are not in same order as networks in the list in api request.
  2. vm nics ip on same Shared network are changed after moving.

hence I think your testing result is same as expected.
you can try to add a list of networks in the cloudmonkey command.

I will add a commit to take L2 network into consideration.

@shwstppr
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✖centos8 ✔debian. JID-2595

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@ustcweizhou ustcweizhou reopened this Jan 27, 2021
@blueorangutan
Copy link

Trillian test result (tid-3439)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 31415 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4602-t3439-kvm-centos7.zip
Smoke tests completed. 83 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

LGTM, Tested on local simulator env,

> list virtualmachines id=8fbb3706-c542-4224-a274-6f40c490804a 
{
  "count": 1,
  "virtualmachine": [
    {
      "account": "admin",
      "affinitygroup": [],
      "bootmode": "legacy",
      "boottype": "Bios",
      "cpunumber": 1,
      "cpuspeed": 500,
      "created": "2021-01-29T12:13:29+0530",
      "details": {},
      "displayname": "t5",
      "displayvm": true,
      "domain": "ROOT",
      "domainid": "b4924318-6146-11eb-9c0f-a0afbd4a2d60",
      "guestosid": "b48662d8-6146-11eb-9c0f-a0afbd4a2d60",
      "haenable": false,
      "hostid": "e4090dc6-ba83-4a6a-ad43-09a0c8879b1d",
      "hostname": "SimulatedAgent.2466f4c8-49df-47b7-804d-b5306163368b",
      "hypervisor": "Simulator",
      "id": "8fbb3706-c542-4224-a274-6f40c490804a",
      "instancename": "i-2-10-QA",
      "isdynamicallyscalable": false,
      "memory": 512,
      "name": "t5",
      "nic": [
        {
          "broadcasturi": "vlan://4321",
          "extradhcpoption": [],
          "gateway": "10.9.9.1",
          "id": "c534fbc5-d5f8-40b8-876b-affb4ad6ce98",
          "ipaddress": "10.9.9.23",
          "isdefault": true,
          "isolationuri": "vlan://4321",
          "macaddress": "1e:00:9a:00:01:af",
          "netmask": "255.255.255.0",
          "networkid": "8f3b4910-008a-49e5-a305-74a5edff3254",
          "networkname": "sh2",
          "secondaryip": [],
          "traffictype": "Guest",
          "type": "Shared"
        },
        {
          "broadcasturi": "vlan://1234",
          "extradhcpoption": [],
          "gateway": "10.9.8.1",
          "id": "37ea01ba-7fc7-4506-806c-4464b5b745a7",
          "ipaddress": "10.9.8.12",
          "isdefault": false,
          "isolationuri": "vlan://1234",
          "macaddress": "1e:00:7f:00:01:90",
          "netmask": "255.255.255.0",
          "networkid": "12cf0569-f05d-44a2-88cf-d9b5b04eefe9",
          "networkname": "sh1",
          "secondaryip": [],
          "traffictype": "Guest",
          "type": "Shared"
        }
      ],
      "osdisplayname": "CentOS 5.6 (64-bit)",
      "ostypeid": "b48662d8-6146-11eb-9c0f-a0afbd4a2d60",
      "passwordenabled": false,
      "rootdeviceid": 0,
      "rootdevicetype": "ROOT",
      "securitygroup": [],
      "serviceofferingid": "6338335e-5ee7-4fcc-a0cb-4746ff0d35e3",
      "serviceofferingname": "Small Instance",
      "state": "Running",
      "tags": [],
      "templatedisplaytext": "CentOS 5.6 (64-bit) no GUI (Simulator)",
      "templateid": "4a0360b8-6147-11eb-9c0f-a0afbd4a2d60",
      "templatename": "CentOS 5.6 (64-bit) no GUI (Simulator)",
      "userid": "b494f70a-6146-11eb-9c0f-a0afbd4a2d60",
      "username": "admin",
      "zoneid": "25849759-355c-49be-b004-664f34d77a65",
      "zonename": "Sandbox-simulator"
    }
  ]
}
(localcloud) 🐱 > stop virtualmachine id=8fbb3706-c542-4224-a274-6f40c490804a 
{
  "virtualmachine": {
    "account": "admin",
    "affinitygroup": [],
    "cpunumber": 1,
    "cpuspeed": 500,
    "cpuused": "10%",
    "created": "2021-01-29T12:13:29+0530",
    "details": {
      "Message.ReservedCapacityFreed.Flag": "false"
    },
    "diskioread": 0,
    "diskiowrite": 0,
    "diskkbsread": 0,
    "diskkbswrite": 0,
    "displayname": "t5",
    "displayvm": true,
    "domain": "ROOT",
    "domainid": "b4924318-6146-11eb-9c0f-a0afbd4a2d60",
    "guestosid": "b48662d8-6146-11eb-9c0f-a0afbd4a2d60",
    "haenable": false,
    "hypervisor": "Simulator",
    "id": "8fbb3706-c542-4224-a274-6f40c490804a",
    "instancename": "i-2-10-QA",
    "isdynamicallyscalable": false,
    "jobid": "99369c1f-a616-4ecf-b74a-2e46ecb40714",
    "jobstatus": 0,
    "memory": 512,
    "memoryintfreekbs": 0,
    "memorykbs": 0,
    "memorytargetkbs": 0,
    "name": "t5",
    "networkkbsread": 32768,
    "networkkbswrite": 16384,
    "nic": [
      {
        "broadcasturi": "vlan://4321",
        "extradhcpoption": [],
        "gateway": "10.9.9.1",
        "id": "c534fbc5-d5f8-40b8-876b-affb4ad6ce98",
        "ipaddress": "10.9.9.23",
        "isdefault": true,
        "isolationuri": "vlan://4321",
        "macaddress": "1e:00:9a:00:01:af",
        "netmask": "255.255.255.0",
        "networkid": "8f3b4910-008a-49e5-a305-74a5edff3254",
        "networkname": "sh2",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      },
      {
        "broadcasturi": "vlan://1234",
        "extradhcpoption": [],
        "gateway": "10.9.8.1",
        "id": "37ea01ba-7fc7-4506-806c-4464b5b745a7",
        "ipaddress": "10.9.8.12",
        "isdefault": false,
        "isolationuri": "vlan://1234",
        "macaddress": "1e:00:7f:00:01:90",
        "netmask": "255.255.255.0",
        "networkid": "12cf0569-f05d-44a2-88cf-d9b5b04eefe9",
        "networkname": "sh1",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      }
    ],
    "osdisplayname": "CentOS 5.6 (64-bit)",
    "ostypeid": "b48662d8-6146-11eb-9c0f-a0afbd4a2d60",
    "passwordenabled": false,
    "rootdeviceid": 0,
    "rootdevicetype": "ROOT",
    "securitygroup": [],
    "serviceofferingid": "6338335e-5ee7-4fcc-a0cb-4746ff0d35e3",
    "serviceofferingname": "Small Instance",
    "state": "Stopped",
    "tags": [],
    "templatedisplaytext": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "templateid": "4a0360b8-6147-11eb-9c0f-a0afbd4a2d60",
    "templatename": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "userid": "b494f70a-6146-11eb-9c0f-a0afbd4a2d60",
    "username": "admin",
    "zoneid": "25849759-355c-49be-b004-664f34d77a65",
    "zonename": "Sandbox-simulator"
  }
}
(localcloud) 🐱 > assign virtualmachine virtualmachineid=8fbb3706-c542-4224-a274-6f40c490804a account=admin1 domainid=b4924318-6146-11eb-9c0f-a0afbd4a2d60 networkids=8f3b4910-008a-49e5-a305-74a5edff3254,12cf0569-f05d-44a2-88cf-d9b5b04eefe9
{
  "virtualmachine": {
    "account": "admin1",
    "affinitygroup": [],
    "cpunumber": 1,
    "cpuspeed": 500,
    "cpuused": "10%",
    "created": "2021-01-29T12:13:29+0530",
    "details": {
      "Message.ReservedCapacityFreed.Flag": "false"
    },
    "diskioread": 0,
    "diskiowrite": 0,
    "diskkbsread": 0,
    "diskkbswrite": 0,
    "displayname": "t5",
    "displayvm": true,
    "domain": "ROOT",
    "domainid": "b4924318-6146-11eb-9c0f-a0afbd4a2d60",
    "guestosid": "b48662d8-6146-11eb-9c0f-a0afbd4a2d60",
    "haenable": false,
    "hypervisor": "Simulator",
    "id": "8fbb3706-c542-4224-a274-6f40c490804a",
    "instancename": "i-2-10-QA",
    "isdynamicallyscalable": false,
    "memory": 512,
    "memoryintfreekbs": 0,
    "memorykbs": 0,
    "memorytargetkbs": 0,
    "name": "t5",
    "networkkbsread": 32768,
    "networkkbswrite": 16384,
    "nic": [
      {
        "broadcasturi": "vlan://4321",
        "extradhcpoption": [],
        "gateway": "10.9.9.1",
        "id": "c8604d05-6fff-47c1-baa1-4f50ab5d6bd5",
        "ipaddress": "10.9.9.23",
        "isdefault": true,
        "isolationuri": "vlan://4321",
        "macaddress": "1e:00:44:00:01:af",
        "netmask": "255.255.255.0",
        "networkid": "8f3b4910-008a-49e5-a305-74a5edff3254",
        "networkname": "sh2",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      },
      {
        "broadcasturi": "vlan://1234",
        "extradhcpoption": [],
        "gateway": "10.9.8.1",
        "id": "57dbdd3c-96de-4e1e-be8d-745ccf75e932",
        "ipaddress": "10.9.8.12",
        "isdefault": false,
        "isolationuri": "vlan://1234",
        "macaddress": "1e:00:d0:00:01:90",
        "netmask": "255.255.255.0",
        "networkid": "12cf0569-f05d-44a2-88cf-d9b5b04eefe9",
        "networkname": "sh1",
        "secondaryip": [],
        "traffictype": "Guest",
        "type": "Shared"
      }
    ],
    "osdisplayname": "CentOS 5.6 (64-bit)",
    "ostypeid": "b48662d8-6146-11eb-9c0f-a0afbd4a2d60",
    "passwordenabled": false,
    "rootdeviceid": 0,
    "rootdevicetype": "ROOT",
    "securitygroup": [],
    "serviceofferingid": "6338335e-5ee7-4fcc-a0cb-4746ff0d35e3",
    "serviceofferingname": "Small Instance",
    "state": "Stopped",
    "tags": [],
    "templatedisplaytext": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "templateid": "4a0360b8-6147-11eb-9c0f-a0afbd4a2d60",
    "templatename": "CentOS 5.6 (64-bit) no GUI (Simulator)",
    "userid": "b494f70a-6146-11eb-9c0f-a0afbd4a2d60",
    "username": "admin",
    "zoneid": "25849759-355c-49be-b004-664f34d77a65",
    "zonename": "Sandbox-simulator"
  }
}

@rohityadavcloud rohityadavcloud merged commit 1913c68 into apache:4.14 Feb 1, 2021
DaanHoogland pushed a commit that referenced this pull request Feb 1, 2021
* 4.14:
  server: select root disk based on user input during vm import (#4591)
  kvm: Use Q35 chipset for UEFI x86_64 (#4576)
  server: fix wrong error message when create isolated network without SourceNat (#4624)
  server: add possibility to scale vm to current customer offerings (#4622)
  server: keep networks order and ips while move a vm with multiple networks (#4602)
  server: throw exception when update vm nic on L2 network (#4625)
  doc: fix typo in install notes (#4633)
DaanHoogland pushed a commit that referenced this pull request Feb 1, 2021
* 4.15:
  server: select root disk based on user input during vm import (#4591)
  kvm: Use Q35 chipset for UEFI x86_64 (#4576)
  server: fix wrong error message when create isolated network without SourceNat (#4624)
  server: add possibility to scale vm to current customer offerings (#4622)
  server: keep networks order and ips while move a vm with multiple networks (#4602)
  server: throw exception when update vm nic on L2 network (#4625)
  doc: fix typo in install notes (#4633)
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