Jump to content

Portal:Cloud VPS/Admin/Resizing instances

From Wikitech

Resizing an OpenStack instance is a variation on the process of migrating an instance from one cloudvirt to another. In addition to the normal things that happen during a migration, the resize also changes the flavor of the newly migrated instance.

Resize process

1. List all available flavors and decide which one you will want to resize the instance to:

user@cloudcontrol1003:~$ sudo wmcs-openstack flavor list
+--------------------------------------+---------------------------+-------+------+-----------+-------+-----------+
| ID                                   | Name                      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+---------------------------+-------+------+-----------+-------+-----------+
| 06c3e0a1-f684-4a0c-8f00-551b59a518c8 | g2.cores4.ram8.disk80     |  8192 |   80 |         0 |     4 | True      |
| 135fdbe2-86d7-4472-a0fe-01ae72ddbfb2 | g2.cores8.ram16.disk160   | 16384 |  160 |         0 |     8 | True      |
| 2a6fca3c-9acd-42c0-8284-929e5345b607 | g2.cores2.ram4.disk40     |  4096 |   40 |         0 |     2 | True      |
| 4                                    | m1.large                  |  8192 |   80 |         0 |     4 | True      |
| c39bc0a6-71a2-4512-926e-43cccf5f8b4c | mediumdb                  | 65536 | 1638 |         0 |    16 | False     |
| e7261773-a931-4a72-b725-3ccf71580b18 | largedb                   | 65536 | 3481 |         0 |    16 | False     |
| ea5a9202-c567-4e58-8cae-86ad3defa730 | g2.cores8.ram36.disk80    | 36864 |   80 |         0 |     8 | True      |
| f5b0c7bc-b09a-41af-8812-b50ed99dbec8 | g2.cores1.ram2.disk20     |  2048 |   20 |         0 |     1 | True      |
| f8435c5e-1fbc-4edf-89ac-00bd4015f3d0 | g2.cores16.ram16.disk80   | 16384 |   80 |         0 |    16 | True      |
| f8f25f58-2021-49bb-95d7-9d0d49a08b9c | g2.cores16.ram64.disk1638 | 65536 | 1638 |         0 |    16 | False     |
+--------------------------------------+---------------------------+-------+------+-----------+-------+-----------+

2. Verify the current status of the instance:

user@cloudcontrol1003:~$ OS_PROJECT_ID=PROJECT-ID sudo wmcs-openstack server show SERVER-ID
+-------------------------------------+-----------------------------------------------------------------------------------+
| Field                               | Value                                                                             |
+-------------------------------------+-----------------------------------------------------------------------------------+
| OS-DCF:diskConfig                   | AUTO                                                                              |
| OS-EXT-AZ:availability_zone         | nova                                                                              |
| OS-EXT-SRV-ATTR:host                | cloudvirt1036                                                                     |
| OS-EXT-SRV-ATTR:hypervisor_hostname | cloudvirt1036.eqiad.wmnet                                                         |
| OS-EXT-SRV-ATTR:instance_name       | i-00011964                                                                        |
| OS-EXT-STS:power_state              | Running                                                                           |
| OS-EXT-STS:task_state               | None                                                                              |
| OS-EXT-STS:vm_state                 | active                                                                            |
| OS-SRV-USG:launched_at              | 2020-10-02T16:42:18.000000                                                        |
| OS-SRV-USG:terminated_at            | None                                                                              |
| accessIPv4                          |                                                                                   |
| accessIPv6                          |                                                                                   |
| addresses                           | lan-flat-cloudinstances2b=172.16.0.149                                            |
| config_drive                        |                                                                                   |
| created                             | 2020-01-21T22:40:39Z                                                              |
| flavor                              | g2.cores1.ram2.disk20 (f5b0c7bc-b09a-41af-8812-b50ed99dbec8)                      |
| hostId                              | 80a2e6e408a35547b147fe59d43c54b1f6981b47178247d3554c8ef2                          |
| id                                  | 05f311e9-1ef4-4acd-b467-adb59f6c2f93                                              |
| image                               | debian-10.0-buster (deprecated 2020-10-16) (031d2d76-8368-4066-a502-d28107d0195e) |
| key_name                            | None                                                                              |
| name                                | deployment-puppetdb03                                                             |
| progress                            | 0                                                                                 |
| project_id                          | deployment-prep                                                                   |
| properties                          |                                                                                   |
| security_groups                     | name='default'                                                                    |
| status                              | ACTIVE                                                                            |
| updated                             | 2020-10-02T16:42:22Z                                                              |
| user_id                             | krenair                                                                           |
| volumes_attached                    |                                                                                   |
+-------------------------------------+-----------------------------------------------------------------------------------+

3. Resize the instance to the flavor ID of your choosing:

user@cloudcontrol1003:~$ OS_PROJECT_ID=PROJECT-ID sudo wmcs-openstack server resize --flavor FLAVOR-ID SERVER-ID

4. The instance will be in an intermediate state (VERIFY_RESIZE). Verify that that's the case:

user@cloudcontrol1003:~$ OS_PROJECT_ID=PROJECT-ID sudo wmcs-openstack server show SERVER-ID
+-------------------------------------+-----------------------------------------------------------------------------------+
| Field                               | Value                                                                             |
+-------------------------------------+-----------------------------------------------------------------------------------+
| OS-DCF:diskConfig                   | AUTO                                                                              |
| OS-EXT-AZ:availability_zone         | nova                                                                              |
| OS-EXT-SRV-ATTR:host                | cloudvirt1023                                                                     |
| OS-EXT-SRV-ATTR:hypervisor_hostname | cloudvirt1023.eqiad.wmnet                                                         |
| OS-EXT-SRV-ATTR:instance_name       | i-00011964                                                                        |
| OS-EXT-STS:power_state              | Running                                                                           |
| OS-EXT-STS:task_state               | None                                                                              |
| OS-EXT-STS:vm_state                 | resized                                                                           |
| OS-SRV-USG:launched_at              | 2020-12-23T18:47:49.000000                                                        |
| OS-SRV-USG:terminated_at            | None                                                                              |
| accessIPv4                          |                                                                                   |
| accessIPv6                          |                                                                                   |
| addresses                           | lan-flat-cloudinstances2b=172.16.0.149                                            |
| config_drive                        |                                                                                   |
| created                             | 2020-01-21T22:40:39Z                                                              |
| flavor                              | g2.cores2.ram4.disk40 (2a6fca3c-9acd-42c0-8284-929e5345b607)                      |
| hostId                              | 1d17668b9d52959efb4c0fb06e0ff7bf101a2557e213dbd8f1e63bd6                          |
| id                                  | 05f311e9-1ef4-4acd-b467-adb59f6c2f93                                              |
| image                               | debian-10.0-buster (deprecated 2020-10-16) (031d2d76-8368-4066-a502-d28107d0195e) |
| key_name                            | None                                                                              |
| name                                | deployment-puppetdb03                                                             |
| progress                            | 0                                                                                 |
| project_id                          | deployment-prep                                                                   |
| properties                          |                                                                                   |
| security_groups                     | name='default'                                                                    |
| status                              | VERIFY_RESIZE                                                                     |
| updated                             | 2020-12-23T18:47:49Z                                                              |
| user_id                             | krenair                                                                           |
| volumes_attached                    |                                                                                   |
+-------------------------------------+-----------------------------------------------------------------------------------+

5. Confirm that the VM has the characteristics of the new flavor:

username@servername:~$ free -m
              total        used        free      shared  buff/cache   available
Mem:           3955         278        3305           7         370        3439
Swap:           510           0         510

username@servername:~$ cat /proc/cpuinfo  | grep ^processor
processor	: 0
processor	: 1

6. Now confirm the resize as successful in OpenStack to complete the process:

user@cloudcontrol1003:~$ OS_PROJECT_ID=PROJECT-ID sudo wmcs-openstack server resize --confirm SERVER-ID