Portal:Cloud VPS/Admin/Resizing instances

From Wikitech
Jump to navigation Jump to search

Make backups

Before attempting to resize an instance, make backups of the contents in `/var/log/nova/instances/$INSTANCE_UUID` with the instance stopped.

Resizing

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

root@cloudcontrol1003:~# openstack flavor list
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
| ID                                   | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
| 2                                    | m1.small  |  2048 |   20 |         0 |     1 | True      |
| 21e9047d-a60f-499d-b7f5-51f83ddf3611 | bigdisk2  | 24576 |  300 |         0 |     4 | True      |
| 3                                    | m1.medium |  4096 |   40 |         0 |     2 | True      |
| 3fbb962d-86c1-40a6-a712-e744d4622635 | bigdisk   | 24576 |  300 |         0 |     4 | False     |
| 4                                    | m1.large  |  8192 |   80 |         0 |     4 | True      |
| 5                                    | m1.xlarge | 16384 |  160 |         0 |     8 | True      |
| c39bc0a6-71a2-4512-926e-43cccf5f8b4c | mediumdb  | 65536 | 1638 |         0 |    16 | False     |
| e48a8d9d-e735-4742-981f-b55f293d4115 | bigram    | 36864 |   80 |         0 |     8 | True      |
| e7261773-a931-4a72-b725-3ccf71580b18 | largedb   | 65536 | 3481 |         0 |    16 | False     |
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+

2. Verify the current status of the instance:

root@cloudcontrol1003:~# OS_PROJECT_ID=project openstack server show servername
+--------------------------------------+-----------------------------------------------------------------------------------+
| Field                                | Value                                                                             |
+--------------------------------------+-----------------------------------------------------------------------------------+
| flavor                               | m1.small (2)                                                                      |
| id                                   | c7bed3eb-decf-4a95-8ed5-a13703f02fff                                              |
| image                                | debian-9.5-stretch (deprecated 2018-11-22) (c6273cce-9b8b-4364-9f1f-7bf58436994f) |
| name                                 | servername                                                                        |
| project_id                           | project                                                                           |
| status                               | ACTIVE                                                                            |
| updated                              | 2019-02-22T14:16:25Z                                                              |
| user_id                              | username                                                                          |
+--------------------------------------+-----------------------------------------------------------------------------------+

3. Re-activate the base image that the instance is based on (otherwise the resize will fail with a message "Not authorized for image"):

root@cloudcontrol1003:~# openstack image set --activate c6273cce-9b8b-4364-9f1f-7bf58436994f

If the instance is based on a base image that is not deactivated, this step can be skipped (but that's very unlikely).

4. Resize the instance to the flavor ID of your choosing (m1.small -> m1.medium in this example):

root@cloudcontrol1003:~# OS_PROJECT_ID=project nova resize servername 3 --poll
Server resizing... 100% complete
Finished

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

root@cloudcontrol1003:~# OS_PROJECT_ID=testlabs openstack server show servername
+--------------------------------------+-----------------------------------------------------------------------------------+
| Field                                | Value                                                                             |
+--------------------------------------+-----------------------------------------------------------------------------------+
| OS-EXT-STS:vm_state                  | resized                                                                           |
| flavor                               | m1.medium (3)                                                                     |
| id                                   | c7bed3eb-decf-4a95-8ed5-a13703f0284d                                              |
| image                                | debian-9.5-stretch (deprecated 2018-11-22) (c6273cce-9b8b-4364-9f1f-7bf58436994f) |
| name                                 | servername                                                                        |
| os-extended-volumes:volumes_attached | []                                                                                |
| progress                             | 0                                                                                 |
| project_id                           | project                                                                           |
| status                               | VERIFY_RESIZE                                                                     |
| updated                              | 2019-02-22T14:16:25Z                                                              |
| user_id                              | username                                                                          |
+--------------------------------------+-----------------------------------------------------------------------------------+

6. Confirm that the VM has the characteristics of the flavor you chose:


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

7. Now confirm the resize as successful in OpenStack:

root@cloudcontrol1003:~# OS_PROJECT_ID=project openstack server resize --confirm servername

8. If you re-activated a previously deactivated image, remember to deactivate it again:

root@cloudcontrol1003:~# openstack image set --deactivate c6273cce-9b8b-4364-9f1f-7bf58436994f

Troubleshooting

If you forget to re-activate a deactivated image prior to starting this process, the resize will fail

root@cloudcontrol1003:~# OS_PROJECT_ID=project nova resize servername 3 --poll
Server resizing... 0% complete
Error resizing server
ERROR (ResourceInErrorState):

And the instance will be in an ERROR state:

root@cloudcontrol1003:~# OS_PROJECT_ID=project nova show servername
+--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
| Property                             | Value                                                                                                                         |
+--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+
| OS-EXT-STS:vm_state                  | error                                                                                                                         |
| fault                                | {"message": "Not authorized for image c6273cce-9b8b-4364-9f1f-7bf58436994f.", "code": 500, "created": "2019-02-22T14:02:19Z"} |
| flavor                               | m1.small (2)                                                                                                                  |
| hostId                               | 945a478d7702b081701f7ece90da4d8f0fcd39155134a6afb89a2fcx                                                                      |
| host_status                          | UP                                                                                                                            |
| id                                   | c7bed3eb-decf-4a95-8ed5-a13703f0284d                                                                                          |
| image                                | debian-9.5-stretch (deprecated 2018-11-22) (c6273cce-9b8b-4364-9f1f-7bf58436994f)                                             |
| name                                 | servername                                                                                                                      |
| os-extended-volumes:volumes_attached | []                                                                                                                            |
| security_groups                      | default                                                                                                                       |
| status                               | ERROR                                                                                                                         |
| tenant_id                            | project                                                                                                                     |
| updated                              | 2019-02-22T14:11:09Z                                                                                                          |
| user_id                              | username                                                                                                                        |
+--------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+

In that case, hard reboot it:

OS_PROJECT_ID=project nova reboot--hard servername