From 37ff6ded8bdbbe480baa4db4627d6cc889d2e3ef Mon Sep 17 00:00:00 2001 From: Andre Ruiz Date: Mon, 18 Feb 2019 12:56:04 -0300 Subject: [PATCH] Implement new option: default_ephemeral_format This change implements a new option in config.yaml that sets the default format for new ephemeral volumes attached to instances. Closes-Bug: #1693943 Change-Id: Iff9254039fa6f1cef9d80c0d59de8e37b39e30f0 --- config.yaml | 6 ++++++ hooks/nova_compute_context.py | 4 ++++ templates/icehouse/nova.conf | 3 +++ templates/juno/nova.conf | 3 +++ templates/kilo/nova.conf | 3 +++ templates/liberty/nova.conf | 3 +++ templates/mitaka/nova.conf | 3 +++ templates/newton/nova.conf | 3 +++ templates/ocata/nova.conf | 3 +++ templates/pike/nova.conf | 3 +++ templates/rocky/nova.conf | 3 +++ unit_tests/test_nova_compute_contexts.py | 12 ++++++++++++ 12 files changed, 49 insertions(+) diff --git a/config.yaml b/config.yaml index 8e151b68..4ba87e1c 100644 --- a/config.yaml +++ b/config.yaml @@ -482,6 +482,12 @@ options: Block devices to use for storage of ephermeral disks to support nova instances; generally used in-conjunction with 'encrypt' to support data-at-rest encryption of instance direct attached storage volumes. + default-ephemeral-format: + type: string + default: ext4 + description: | + The default format an ephemeral volume will be formatted with on creation. + Possible values: ext2 ext3 ext4 xfs ntfs (only for Windows guests) encrypt: default: False type: boolean diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index fa334462..4386f0a1 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -213,6 +213,10 @@ class NovaComputeLibvirtContext(context.OSContextGenerator): if config('use-multipath'): ctxt['use_multipath'] = config('use-multipath') + if config('default-ephemeral-format'): + ctxt['default_ephemeral_format'] = \ + config('default-ephemeral-format') + if config('cpu-mode'): ctxt['cpu_mode'] = config('cpu-mode') elif ctxt['arch'] in ('ppc64el', 'ppc64le', 'aarch64'): diff --git a/templates/icehouse/nova.conf b/templates/icehouse/nova.conf index cde954bd..006c30de 100644 --- a/templates/icehouse/nova.conf +++ b/templates/icehouse/nova.conf @@ -176,5 +176,8 @@ disk_cachemodes = {{ disk_cachemodes }} {% if use_multipath -%} iscsi_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} {% include "parts/section-ephemeral" %} diff --git a/templates/juno/nova.conf b/templates/juno/nova.conf index c04af571..35143891 100644 --- a/templates/juno/nova.conf +++ b/templates/juno/nova.conf @@ -171,6 +171,9 @@ disk_cachemodes = {{ disk_cachemodes }} {% if use_multipath -%} iscsi_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} {% include "parts/section-cinder" %} diff --git a/templates/kilo/nova.conf b/templates/kilo/nova.conf index 53591fe4..a0003626 100644 --- a/templates/kilo/nova.conf +++ b/templates/kilo/nova.conf @@ -192,6 +192,9 @@ disk_cachemodes = {{ disk_cachemodes }} {% if use_multipath -%} iscsi_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} {% include "parts/section-database" %} diff --git a/templates/liberty/nova.conf b/templates/liberty/nova.conf index b527be23..35f89889 100644 --- a/templates/liberty/nova.conf +++ b/templates/liberty/nova.conf @@ -196,6 +196,9 @@ disk_cachemodes = {{ disk_cachemodes }} {% if use_multipath -%} iscsi_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} {% include "parts/section-database" %} diff --git a/templates/mitaka/nova.conf b/templates/mitaka/nova.conf index caeaed34..332132ac 100644 --- a/templates/mitaka/nova.conf +++ b/templates/mitaka/nova.conf @@ -208,6 +208,9 @@ live_migration_tunnelled = False {% if use_multipath -%} iscsi_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} hw_disk_discard = unmap {% if virt_type == 'lxd' -%} diff --git a/templates/newton/nova.conf b/templates/newton/nova.conf index 19a6afa1..2a82f4df 100644 --- a/templates/newton/nova.conf +++ b/templates/newton/nova.conf @@ -220,6 +220,9 @@ live_migration_tunnelled = False {% if use_multipath -%} volume_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} hw_disk_discard = unmap {% if virt_type == 'lxd' -%} diff --git a/templates/ocata/nova.conf b/templates/ocata/nova.conf index b2afb639..2b27c100 100644 --- a/templates/ocata/nova.conf +++ b/templates/ocata/nova.conf @@ -224,6 +224,9 @@ live_migration_tunnelled = False {% if use_multipath -%} volume_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} hw_disk_discard = unmap {% if virt_type == 'lxd' -%} diff --git a/templates/pike/nova.conf b/templates/pike/nova.conf index 0db89c1e..acc77c14 100644 --- a/templates/pike/nova.conf +++ b/templates/pike/nova.conf @@ -232,6 +232,9 @@ live_migration_tunnelled = False {% if use_multipath -%} volume_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} hw_disk_discard = unmap {% if virt_type == 'lxd' -%} diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index 8aaf719f..8bfe4d67 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -220,6 +220,9 @@ live_migration_tunnelled = False {% if use_multipath -%} volume_use_multipath = {{ use_multipath }} {% endif %} +{% if default_ephemeral_format -%} +default_ephemeral_format = {{ default_ephemeral_format }} +{% endif %} hw_disk_discard = unmap {% if virtio_net_tx_queue_size -%} tx_queue_size = {{ virtio_net_tx_queue_size }} diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index bc31f898..d430dcbd 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -216,6 +216,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt()) def test_libvirt_context_libvirtd_reserved_huge_pages_1(self): @@ -234,6 +235,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512, 'reserved_huge_pages': ['node:0,size:2048,count:6']}, libvirt()) @@ -255,6 +257,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512, 'reserved_huge_pages': ['node:0,size:2048,count:6', 'node:1,size:1G,count:32']}, libvirt()) @@ -274,6 +277,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt()) def test_libvirt_bin_context_migration_tcp_listen(self): @@ -293,6 +297,7 @@ class NovaComputeContextTests(CharmTestCase): 'live_migration_uri': 'qemu+ssh://%s/system', 'live_migration_permit_auto_converge': False, 'live_migration_permit_post_copy': False, + 'default_ephemeral_format': 'ext4', 'force_raw_images': True, 'reserved_host_memory': 512}, libvirt()) @@ -315,6 +320,7 @@ class NovaComputeContextTests(CharmTestCase): 'live_migration_permit_auto_converge': True, 'live_migration_permit_post_copy': False, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt()) def test_libvirt_bin_context_migration_tcp_listen_with_post_copy(self): @@ -335,6 +341,7 @@ class NovaComputeContextTests(CharmTestCase): 'live_migration_uri': 'qemu+ssh://%s/system', 'live_migration_permit_auto_converge': False, 'live_migration_permit_post_copy': True, + 'default_ephemeral_format': 'ext4', 'force_raw_images': True, 'reserved_host_memory': 512}, libvirt()) @@ -354,6 +361,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt()) def test_libvirt_hugepages(self): @@ -373,6 +381,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt()) def test_libvirt_context_libvirtd_force_raw_images(self): @@ -391,6 +400,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': False, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt()) def test_lxd_live_migration_opts_xenial(self): @@ -501,6 +511,7 @@ class NovaComputeContextTests(CharmTestCase): 'pci_passthrough_whitelist': 'mypcidevices', 'virtio_net_tx_queue_size': 512, 'virtio_net_rx_queue_size': 1024, + 'default_ephemeral_format': 'ext4', 'cpu_shared_set': "4-12,^8,15"}, libvirt()) def test_ksm_configs(self): @@ -653,6 +664,7 @@ class SerialConsoleContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'force_raw_images': True, + 'default_ephemeral_format': 'ext4', 'reserved_host_memory': 512}, libvirt())