How easy is it to resize / grow OpenStack Instance or Virtual Machine?. OpenStack Compute is the central component that provides virtual machines on demand. It enables Sysadmins to create instances with specific hardware specifications – Ram, CPU and Disk space.

In OpenStack, each created instance is given a flavor (resource template), which determines the instance’s size and capacity. Flavors can also specify secondary ephemeral storage, swap disk, metadata to restrict usage, or special project access. These extra attributes have to be defined to store desired values.

You can check available flavors from the command line using the command:

$ openstack flavor list
+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 0  | m1.tiny   |  1024 |   10 |         0 |     1 | True      |
| 1  | m1.small  |  2048 |   20 |         0 |     1 | True      |
| 2  | m1.medium |  4096 |   20 |         0 |     2 | True      |
| 3  | m1.large  |  8192 |   40 |         0 |     4 | True      |
| 4  | m1.xlarge | 16384 |   40 |         0 |     4 | True      |
+----+-----------+-------+------+-----------+-------+-----------+

As an OpenStack Administrator, you’ll most likely encounter scenarios where you have to upgrade or downgrade a server based on emerging compute needs. As an example, you deploy a server with 2GB of Ram and would like to upgrade it to 4GB of Ram.

I have a Debian 10 server running on OpenStack Stein platform with below hardware specifications.

$ openstack server show deb10
+-------------------------------------+----------------------------------------------------------+
| Field                               | Value                                                    |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                   |
| OS-EXT-AZ:availability_zone         | nova                                                     |
| OS-EXT-SRV-ATTR:host                | server1.computingforgeeks.com                            |
| OS-EXT-SRV-ATTR:hypervisor_hostname | server1.computingforgeeks.com                            |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000024                                        |
| OS-EXT-STS:power_state              | Running                                                  |
| OS-EXT-STS:task_state               | None                                                     |
| OS-EXT-STS:vm_state                 | active                                                   |
| OS-SRV-USG:launched_at              | 2019-09-17T16:34:03.000000                               |
| OS-SRV-USG:terminated_at            | None                                                     |
| accessIPv4                          |                                                          |
| accessIPv6                          |                                                          |
| addresses                           | private=10.10.1.104                                      |
| config_drive                        |                                                          |
| created                             | 2019-09-17T16:33:58Z                                     |
| flavor                              | m1.small (1)                                             |
| hostId                              | da0a05ef20a03e97f301563551bab9b669ef04adbce232d941519946 |
| id                                  | 04ed473d-c889-40c2-9204-3a4544e419dc                     |
| image                               | Debian-10 (f0ac705b-ee73-4de8-95f7-4e06569f0f5c)         |
| key_name                            | mykey1                                                   |
| name                                | deb10                                                    |
| progress                            | 0                                                        |
| project_id                          | 06bcc3c56ab1489282b65681e782d7f6                         |
| properties                          |                                                          |
| security_groups                     | name='default'                                           |
| status                              | ACTIVE                                                   |
| updated                             | 2019-09-17T16:34:57Z                                     |
| user_id                             | 336acbb7421f47f8be4891eabf0c9cc8                         |
| volumes_attached                    |                                                          |
+-------------------------------------+----------------------------------------------------------+

This server has 2GB of RAM and 20GB of root disk. The flavor defining this resources is m1.small. Let’s upgrade it with a flavor for 4GB RAM and 40GB disk space.

For this task, we use openstack server resize command. This scales a server to a new flavor. This is achieved by creating a new server and copying the contents of the original disk into a new one.

$ openstack server resize --flavor m1.medium deb10
No valid host was found. No valid host found for resize (HTTP 400) (Request-ID: req-b1c22b58-cb3b-4869-80dd-29b300459f5b)

How to Solve No valid host was found. No valid host found for resize

On first resize trial I got an error message “No valid host was found. No valid host found for resize“. This is because in my setup I have one compute host. To solve this, set allow_resize_to_same_host parameter to true in nova configuration file.

$ sudo vi /etc/nova/nova.conf

Add the line to [DEFAULT] section.

[DEFAULT]
allow_resize_to_same_host = True
state_path = /var/lib/nova
enabled_apis = osapi_compute,metadata
log_dir = /var/log/nova
use_neutron = True
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
vif_plugging_is_fatal = True
vif_plugging_timeout = 300
resume_guests_state_on_host_boot = True

The same setting can be added with

sudo openstack-config --set /etc/nova/nova.conf DEFAULT allow_resize_to_same_host True

Display the value set:

$ openstack-config --get /etc/nova/nova.conf DEFAULT allow_resize_to_same_host
True

Restart OpenStack Nova services.

for service in compute api scheduler; do
  sudo systemctl restart openstack-nova-${service}.service
done

Retry instance resizing.

openstack server resize --flavor m1.medium deb10

The first is to perform the resize, the second is to either confirm (verify) success and release the old server, or to declare a revert to release the new server and restart the old one.

Confirm server resize is complete:

openstack server resize --confirm  deb10

If you want to restore server state before resize, use:

openstack server resize --revert deb10

Resize OpenStack Instance from Horizon UI

For UI resizing navigate to Project > Compute > Instances >Instancename > Resize Instance.

openstack resize instance

Choose a new flavor and click on the “Resize” button.

openstack resize instance 02

Let’s confirm the change.

$ openstack server show deb10
+-------------------------------------+----------------------------------------------------------+
| Field                               | Value                                                    |
+-------------------------------------+----------------------------------------------------------+
| OS-DCF:diskConfig                   | MANUAL                                                   |
| OS-EXT-AZ:availability_zone         | nova                                                     |
| OS-EXT-SRV-ATTR:host                | server1.computingforgeeks.com                            |
| OS-EXT-SRV-ATTR:hypervisor_hostname | server1.computingforgeeks.com                            |
| OS-EXT-SRV-ATTR:instance_name       | instance-00000024                                        |
| OS-EXT-STS:power_state              | Running                                                  |
| OS-EXT-STS:task_state               | None                                                     |
| OS-EXT-STS:vm_state                 | active                                                   |
| OS-SRV-USG:launched_at              | 2019-09-17T17:24:01.000000                               |
| OS-SRV-USG:terminated_at            | None                                                     |
| accessIPv4                          |                                                          |
| accessIPv6                          |                                                          |
| addresses                           | private=10.10.1.104                                      |
| config_drive                        |                                                          |
| created                             | 2019-09-17T16:33:58Z                                     |
| flavor                              | m1.medium (2)                                            |
| hostId                              | da0a05ef20a03e97f301563551bab9b669ef04adbce232d941519946 |
| id                                  | 04ed473d-c889-40c2-9204-3a4544e419dc                     |
| image                               | Debian-10 (f0ac705b-ee73-4de8-95f7-4e06569f0f5c)         |
| key_name                            | mykey1                                                   |
| name                                | deb10                                                    |
| progress                            | 0                                                        |
| project_id                          | 06bcc3c56ab1489282b65681e782d7f6                         |
| properties                          |                                                          |
| security_groups                     | name='default'                                           |
| status                              | VERIFY_RESIZE                                            |
| updated                             | 2019-09-17T17:24:02Z                                     |
| user_id                             | 336acbb7421f47f8be4891eabf0c9cc8                         |
| volumes_attached                    |                                                          |
+-------------------------------------+----------------------------------------------------------+

We can confirm the flavor has changed to m1.medium and OS-EXT-STS:vm_state set to active. The same can be seen on the VM terminal.

[email protected]:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:          3.9Gi        50Mi       3.7Gi       6.0Mi        80Mi       3.6Gi
Swap:         4.0Gi          0B       4.0Gi
[email protected]:~$ lscpu 
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       39 bits physical, 48 bits virtual
CPU(s):              2
...

$ lsblk 
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    254:0    0  20G  0 disk 
└─vda1 254:1    0  20G  0 part /
vdb    254:16   0   4G  0 disk [SWAP]

Read more on OpenStack hacks and management:

Best books for Learning OpenStack Cloud Platform

How To Install and Configure OpenStack Client on Linux

How To Configure OpenStack Instances / VMs to Autostart after Nova compute reboot

How To Create OpenStack Cinder Volumes and Attach to a VM Instance/Server on CLI

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here