Resizing Pinned Instances to Unpinned

Image by mikael_k / Unsplash

OpenStack Nova provides support for resize operations, or the changing of the flavor associated with instance. This allows you to add or remove resources from the instance, in addition to modifying other configuration associated with the flavor.

There were reports that resizing an instance from a pinned flavor to a unpinned one did not result in the pinning being removed. The opposite was also reportedly true. I investigated this to see if this was the case.

Steps

Create the required flavors

The first step we’ll do is create two new flavors - test.unpinned and test.pinned. Begin by creating these:

$ openstack flavor create test.unpinned \
  --id 100 --ram 2048 --disk 0 --vcpus 2
$ openstack flavor create test.pinned \
  --id 101 --ram 2048 --disk 0 --vcpus 2
$ openstack flavor set test.pinned --property "hw:cpu_policy=dedicated"

$ openstack flavor list
+-----+---------------+-------+------+-----------+-------+-----------+
| ID  | Name          |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+-----+---------------+-------+------+-----------+-------+-----------+
| 1   | m1.tiny       |   512 |    1 |         0 |     1 | True      |
| 101 | test.unpinned |  2048 |    0 |         0 |     2 | True      |
| 101 | test.pinned   |  2048 |    0 |         0 |     2 | True      |
| 2   | m1.small      |  2048 |   20 |         0 |     1 | True      |
| 3   | m1.medium     |  4096 |   40 |         0 |     2 | True      |
| 4   | m1.large      |  8192 |   80 |         0 |     4 | True      |
| 42  | m1.nano       |    64 |    0 |         0 |     1 | True      |
| 5   | m1.xlarge     | 16384 |  160 |         0 |     8 | True      |
| 84  | m1.micro      |   128 |    0 |         0 |     1 | True      |
+-----+---------------+-------+------+-----------+-------+-----------+

Create a new instance

Now create the new instance, based on the test.pinned flavor:

$ openstack image list
+--------------------------------------+---------------------------------+--------+
| ID                                   | Name                            | Status |
+--------------------------------------+---------------------------------+--------+
| c44bba29-653e-4ddf-963d-442af4c33a13 | cirros-0.3.4-x86_64-uec         | active |
| 8b0284ee-ae6c-4e80-b5ee-26895d574717 | cirros-0.3.4-x86_64-uec-ramdisk | active |
| 855c2971-aedc-4d5f-a366-73bb14707965 | cirros-0.3.4-x86_64-uec-kernel  | active |
+--------------------------------------+---------------------------------+--------+

$ openstack server create --flavor=test.pinned \
  --image=cirros-0.3.4-x86_64-uec --wait test1

Validate that the instance is pinned

Ensure the instance is actually pinned in the first place before we resize anything:

$ openstack server list
+--------------------------------------+-------+--------+--------------------------------------------------------+
| ID                                   | Name  | Status | Networks                                               |
+--------------------------------------+-------+--------+--------------------------------------------------------+
| 857597cb-266b-4032-8030-e3cc76ebf0e7 | test1 | ACTIVE | private=10.0.0.3, fd2a:ec16:99e1:0:f816:3eff:fe99:df9f |
+--------------------------------------+-------+--------+--------------------------------------------------------+

$ sudo virsh list
 Id    Name                           State
----------------------------------------------------
 1     instance-00000001              running

$ sudo virsh dumpxml instance-00000001
<domain type='kvm' id='1'>
  <name>instance-00000001</name>
  ...
  <vcpu placement='static'>2</vcpu>
  <cputune>
    <shares>2048</shares>
    <vcpupin vcpu='0' cpuset='1'/>
    <vcpupin vcpu='1' cpuset='21'/>
    <emulatorpin cpuset='1,21'/>
  </cputune>
  <numatune>
    <memory mode='strict' nodeset='0'/>
    <memnode cellid='0' mode='strict' nodeset='0'/>
  </numatune>
  ...
  <cpu>
    <topology sockets='1' cores='1' threads='2'/>
    <numa>
      <cell id='0' cpus='0-1' memory='2097152' unit='KiB'/>
    </numa>
  </cpu>
  ...
</domain>

Resize the instance to the unpinned flavor

Seeing as pinning was in effect, we can now resize to the test.unpinned flavor:

$ openstack server resize test1 --flavor test.unpinned --wait
complete

$ openstack server list
+--------------------------------------+-------+---------------+--------------------------------------------------------+
| ID                                   | Name  | Status        | Networks                                               |
+--------------------------------------+-------+---------------+--------------------------------------------------------+
| 857597cb-266b-4032-8030-e3cc76ebf0e7 | test1 | VERIFY_RESIZE | private=10.0.0.3, fd2a:ec16:99e1:0:f816:3eff:fe99:df9f |
+--------------------------------------+-------+---------------+--------------------------------------------------------+

$ openstack server resize test1 --confirm

Validate that the instance is no longer pinned

Once resized, check to see if the instance has been unpinned:

$ openstack server list
+--------------------------------------+-------+--------+--------------------------------------------------------+
| ID                                   | Name  | Status | Networks                                               |
+--------------------------------------+-------+--------+--------------------------------------------------------+
| 857597cb-266b-4032-8030-e3cc76ebf0e7 | test1 | ACTIVE | private=10.0.0.3, fd2a:ec16:99e1:0:f816:3eff:fe99:df9f |
+--------------------------------------+-------+--------+--------------------------------------------------------+

$ sudo virsh list
 Id    Name                           State
----------------------------------------------------
 2     instance-00000001              running

$ sudo virsh dumpxml instance-00000001
<domain type='kvm' id='2'>
  <name>instance-00000002</name>
  ...
  <vcpu placement='static'>2</vcpu>
  <cputune>
    <shares>2048</shares>
  </cputune>
  ...
</domain>

Resize the instance back to the pinned flavor

Let’s go back the other way, and resize back to the test.pinned flavor:

$ openstack server resize test1 --flavor test.pinned --wait
complete

$ openstack server list
+--------------------------------------+-------+---------------+--------------------------------------------------------+
| ID                                   | Name  | Status        | Networks                                               |
+--------------------------------------+-------+---------------+--------------------------------------------------------+
| 857597cb-266b-4032-8030-e3cc76ebf0e7 | test1 | VERIFY_RESIZE | private=10.0.0.3, fd2a:ec16:99e1:0:f816:3eff:fe99:df9f |
+--------------------------------------+-------+---------------+--------------------------------------------------------+

$ openstack server resize test1 --confirm

Validate that the instance is pinned once more

Finally, ensure the instance is once again pinned:

$ openstack server list
+--------------------------------------+-------+--------+--------------------------------------------------------+
| ID                                   | Name  | Status | Networks                                               |
+--------------------------------------+-------+--------+--------------------------------------------------------+
| 857597cb-266b-4032-8030-e3cc76ebf0e7 | test1 | ACTIVE | private=10.0.0.3, fd2a:ec16:99e1:0:f816:3eff:fe99:df9f |
+--------------------------------------+-------+--------+--------------------------------------------------------+

$ sudo virsh list
 Id    Name                           State
----------------------------------------------------
 3     instance-00000001              running

$ sudo virsh dumpxml instance-00000001
<domain type='kvm' id='3'>
  <name>instance-00000001</name>
  ...
  <vcpu placement='static'>2</vcpu>
  <cputune>
    <shares>2048</shares>
    <vcpupin vcpu='0' cpuset='1'/>
    <vcpupin vcpu='1' cpuset='21'/>
    <emulatorpin cpuset='1,21'/>
  </cputune>
  <numatune>
    <memory mode='strict' nodeset='0'/>
    <memnode cellid='0' mode='strict' nodeset='0'/>
  </numatune>
  ...
  <cpu>
    <topology sockets='1' cores='1' threads='2'/>
    <numa>
      <cell id='0' cpus='0-1' memory='2097152' unit='KiB'/>
    </numa>
  </cpu>
  ...
</domain>

Result

It is possible to resize from pinned to unpinned, and from unpinned to pinned. No issues here.

References

comments powered by Disqus