diff --git a/config.yaml b/config.yaml index 5911673e..519d3f0a 100644 --- a/config.yaml +++ b/config.yaml @@ -244,6 +244,11 @@ options: default: 512 description: | Amount of memory in MB to reserve for the host. Defaults to 512MB. + reserved-host-disk: + type: int + default: 0 + description: | + Amount of disk resource in MB to reserve for the host. Defaults to 0MB. vcpu-pin-set: type: string default: diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 31d89906..360106b5 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -302,6 +302,7 @@ class NovaComputeLibvirtContext(context.OSContextGenerator): ctxt['num_pcie_ports'] = config('num-pcie-ports') ctxt['reserved_host_memory'] = config('reserved-host-memory') + ctxt['reserved_host_disk'] = config('reserved-host-disk') db = kv() if db.get('host_uuid'): diff --git a/templates/kilo/nova.conf b/templates/kilo/nova.conf index 30691a89..a3781adb 100644 --- a/templates/kilo/nova.conf +++ b/templates/kilo/nova.conf @@ -117,6 +117,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if pci_passthrough_whitelist -%} pci_passthrough_whitelist = {{ pci_passthrough_whitelist }} diff --git a/templates/liberty/nova.conf b/templates/liberty/nova.conf index 65278a7d..869d1b24 100644 --- a/templates/liberty/nova.conf +++ b/templates/liberty/nova.conf @@ -117,6 +117,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if pci_passthrough_whitelist -%} pci_passthrough_whitelist = {{ pci_passthrough_whitelist }} diff --git a/templates/mitaka/nova.conf b/templates/mitaka/nova.conf index b5882395..1491b1f9 100644 --- a/templates/mitaka/nova.conf +++ b/templates/mitaka/nova.conf @@ -104,6 +104,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if pci_passthrough_whitelist -%} pci_passthrough_whitelist = {{ pci_passthrough_whitelist }} diff --git a/templates/newton/nova.conf b/templates/newton/nova.conf index cd2ff138..848cefa2 100644 --- a/templates/newton/nova.conf +++ b/templates/newton/nova.conf @@ -103,6 +103,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/templates/ocata/nova.conf b/templates/ocata/nova.conf index 25468138..f1eeabae 100644 --- a/templates/ocata/nova.conf +++ b/templates/ocata/nova.conf @@ -106,6 +106,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/templates/pike/nova.conf b/templates/pike/nova.conf index 87c086a0..679a9430 100644 --- a/templates/pike/nova.conf +++ b/templates/pike/nova.conf @@ -97,6 +97,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/templates/queens/nova.conf b/templates/queens/nova.conf index f85da07d..bef0f21d 100644 --- a/templates/queens/nova.conf +++ b/templates/queens/nova.conf @@ -103,6 +103,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index ad0abea2..f179367d 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -103,6 +103,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/templates/stein/nova.conf b/templates/stein/nova.conf index 44330199..c95875fd 100644 --- a/templates/stein/nova.conf +++ b/templates/stein/nova.conf @@ -107,6 +107,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/templates/train/nova.conf b/templates/train/nova.conf index dc9507e2..dbb51354 100644 --- a/templates/train/nova.conf +++ b/templates/train/nova.conf @@ -135,6 +135,7 @@ instances_path = {{ instances_path }} vcpu_pin_set = {{ vcpu_pin_set }} {% endif -%} reserved_host_memory_mb = {{ reserved_host_memory }} +reserved_host_disk_mb = {{ reserved_host_disk }} {% if reserved_huge_pages -%} {% for value in reserved_huge_pages -%} diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 530845be..2b18f203 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -377,6 +377,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_context_inject_password(self): @@ -398,6 +399,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': True, 'inject_partition': -1, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_context_libvirtd_reserved_huge_pages_1(self): @@ -419,6 +421,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512, 'reserved_huge_pages': ['node:0,size:2048,count:6']}, libvirt()) @@ -443,6 +446,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512, 'reserved_huge_pages': ['node:0,size:2048,count:6', 'node:1,size:1G,count:32']}, libvirt()) @@ -465,6 +469,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_bin_context_migration_tcp_listen(self): @@ -492,6 +497,7 @@ class NovaComputeContextTests(CharmTestCase): 'force_raw_images': True, 'inject_password': False, 'inject_partition': -2, + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_context_without_migration_network(self): @@ -554,6 +560,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_bin_context_migration_tcp_listen_with_post_copy(self): @@ -582,6 +589,7 @@ class NovaComputeContextTests(CharmTestCase): 'force_raw_images': True, 'inject_password': False, 'inject_partition': -2, + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_disk_cachemodes(self): @@ -603,6 +611,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_hugepages(self): @@ -625,6 +634,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_context_libvirtd_force_raw_images(self): @@ -646,6 +656,7 @@ class NovaComputeContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt()) def test_lxd_live_migration_opts_xenial(self): @@ -734,6 +745,7 @@ class NovaComputeContextTests(CharmTestCase): self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'} self.test_config.set('hugepages', '22') self.test_config.set('reserved-host-memory', 1024) + self.test_config.set('reserved-host-disk', 65536) self.test_config.set('vcpu-pin-set', '^0^2') self.test_config.set('pci-passthrough-whitelist', 'mypcidevices') self.test_config.set('virtio-net-tx-queue-size', 512) @@ -753,6 +765,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'reserved_host_memory': 1024, + 'reserved_host_disk': 65536, 'force_raw_images': True, 'inject_password': False, 'inject_partition': -2, @@ -778,6 +791,7 @@ class NovaComputeContextTests(CharmTestCase): 'kvm_hugepages': 0, 'listen_tls': 0, 'host_uuid': self.host_uuid, + 'reserved_host_disk': 0, 'reserved_host_memory': 512, 'vcpu_pin_set': '^0^2', 'force_raw_images': True, @@ -799,6 +813,7 @@ class NovaComputeContextTests(CharmTestCase): 'kvm_hugepages': 0, 'listen_tls': 0, 'host_uuid': self.host_uuid, + 'reserved_host_disk': 0, 'reserved_host_memory': 512, 'cpu_shared_set': '4-15', 'cpu_dedicated_set': '16-31', @@ -1092,6 +1107,7 @@ class SerialConsoleContextTests(CharmTestCase): 'inject_password': False, 'inject_partition': -2, 'default_ephemeral_format': 'ext4', + 'reserved_host_disk': 0, 'reserved_host_memory': 512}, libvirt())