In OpenStack you can resize the VM instance size by changing its flavor. This process will involve rebuilding of the instance and the instance restart after successful rebuild.
To perform a VM instance resize in OpenStack you will run the openstack server resize
command:
openstack server resize --flavor <FLAVOR> <SERVER>
To list available flavors in OpenStack you will run:
# openstack flavor list
+----+------------------------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+------------------------+-------+------+-----------+-------+-----------+
| 10 |basic-vps | 2048 | 20 | 0 | 1 | True |
| 11 |standard-vps | 4096 | 40 | 0 | 2 | True |
| 12 |advanced-vps | 8192 | 80 | 0 | 2 | True |
| 13 |business-vps | 16384 | 160 | 0 | 4 | True |
| 14 |enterprise-vps | 32768 | 240 | 0 | 8 | True |
+----+------------------------+-------+------+-----------+-------+-----------+
Suppose we have an instance with name 31666d86db93e83 , and we want to do a resize from basic-vps to standard-vps, we will run:
openstack server resize --flavor standard-vps 31666d86db93e83
After you resize your OpenStack instance, it will go into the Status of “VERIFY_RESIZE“.
[root@osp# openstack server show 31666d86db93e83
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-SRV-ATTR:host | osp.example.com |
| OS-EXT-SRV-ATTR:hostname | 31666d86db93e83 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | osp1.example.com |
| OS-EXT-SRV-ATTR:instance_name | instance-00000002 |
| OS-EXT-SRV-ATTR:kernel_id | |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | |
| OS-EXT-SRV-ATTR:reservation_id | r-th200i68 |
| OS-EXT-SRV-ATTR:root_device_name | /dev/vda |
| OS-EXT-SRV-ATTR:user_data | None |
| OS-EXT-STS:power_state | Running |
| OS-EXT-STS:task_state | None |
| OS-EXT-STS:vm_state | resized |
| OS-SRV-USG:launched_at | 2024-06-15T13:10:15.000000 |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | public=192.168.2.4 |
| config_drive | |
| created | 2024-06-15T12:20:15Z |
| description | 31666d86db93e83 |
| flavor | description=, disk='40', ephemeral='0', , id='linux-standard-vps', is_disabled=, is_public='True', location=, name='linux-standard-vps', |
| | original_name='linux-standard-vps', ram='4096', rxtx_factor=, swap='0', vcpus='2' |
| hostId | 7f9765d5e2e63614bad156c183b0abcde123cbc3eabd730b992eb99e |
| host_status | UP |
| id | e61991b8-fea6-4cc4-9c70-9661c8aa05df |
| image | Rocky-Linux-9 (6774019b-df26-4841-8842-689e31aff1d7) |
| key_name | Key31Hash8d0a63da9d8949900d1283215d9fa137 |
| locked | False |
| locked_reason | None |
| name | 31666d86db93e83 |
| progress | 0 |
| project_id | 3dfc8a0aec3d409696daa2c825b85a3f |
| properties | |
| security_groups | name='e61991b8-fea6-4cc4-9c70-9661c8aa05df1718454311' |
| | name='allow_all' |
| server_groups | [] |
| status | VERIFY_RESIZE
From the output we can confirm the instance status is VERIFY_RESIZE. We can manually confirm the resize to change the status to ACTIVE:
openstack server resize --revert 31666d86db93e83
The procedure of manual approval works fine for small use case such as home lab environment. If you have tens to hundreds of instances, manual approval is not efficient.
To automate this approval step, we enable automatic “Confirm Action” once an instance resize request is received. Open the OpenStack Nova Compute default configuration file.
sudo vim /etc/nova/nova.conf
Locate the resize_confirm_window
line and set automatic time in seconds to automatically confirm resizes.
#
# Automatically confirm resizes after N seconds. For more information, refer to
# the documentation. (integer value)
# Minimum value: 0
resize_confirm_window=60
In our setting we have configured automatically resize after 60 seconds. This doesn’t require a system administrator to perform any action.
Restart openstack-nova-compute
service for the change to be effected.
sudo systemctl restart openstack-nova-compute.service
After 60 seconds all the pending confirmations will be approved by the system. Instance status will the change to ACTIVE.
| status | ACTIVE