From 0eebcadb8fecbed31d370776d8717cc29029e256 Mon Sep 17 00:00:00 2001 From: Hemanth Nakkina Date: Thu, 8 Oct 2026 12:02:43 +0530 Subject: [PATCH] feat: expose nova block_device_allocate_retries snap config keys Nova aborts VM builds when a volume on a slow cinder backend does not finish creating within block_device_allocate_retries * block_device_allocate_retries_interval (defaults: 60 * 3s). Expose both knobs as compute.block-device-allocate-retries and compute.block-device-allocate-retries-interval snap config keys, unset by default so nova's upstream defaults apply unless overridden. Fixes: https://bugs.launchpad.net/snap-openstack-hypervisor/+bug/2169142 --- README.md | 12 ++++++++++++ openstack_hypervisor/hooks.py | 2 ++ templates/nova.conf.j2 | 9 +++++++++ tests/unit/test_templates.py | 19 +++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/README.md b/README.md index 129ae4d..712eeac 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,18 @@ IP address to use for configuration of SPICE consoles in instances. Whether to resume instances on boot or not. +* `compute.block-device-allocate-retries` Number of attempts when waiting +for a volume to be created + +Unset by default (nova's own default applies, currently 60 attempts). +Increase for slow volume backends that abort VM builds with +"Volume ... did not finish being created even after we waited ...". + +* `compute.block-device-allocate-retries-interval` Interval in seconds +between volume creation attempts + +Unset by default (nova's own default applies, currently 3 seconds). + * `compute.flavors` Flavor of the compute host Comma separated string of Flavors like SEV, SRIOV, DPDK. diff --git a/openstack_hypervisor/hooks.py b/openstack_hypervisor/hooks.py index 56e436a..02c9193 100644 --- a/openstack_hypervisor/hooks.py +++ b/openstack_hypervisor/hooks.py @@ -523,6 +523,8 @@ def _get_local_ip_by_default_route() -> str: "compute.key": UNSET, "compute.migration-address": UNSET, "compute.resume-on-boot": True, + "compute.block-device-allocate-retries": UNSET, + "compute.block-device-allocate-retries-interval": UNSET, "compute.cpu-pinning-profile": UNSET, "compute.flavors": UNSET, "compute.pci-device-specs": [], diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index f0acc9a..7094a7d 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -27,6 +27,15 @@ metadata_workers = 4 resume_guests_state_on_host_boot = {{ compute.resume_on_boot }} +{% if compute.block_device_allocate_retries -%} +# Number of times to retry waiting for a volume to be created +block_device_allocate_retries = {{ compute.block_device_allocate_retries }} +{% endif -%} +{% if compute.block_device_allocate_retries_interval -%} +# Interval in seconds between volume creation retries +block_device_allocate_retries_interval = {{ compute.block_device_allocate_retries_interval }} +{% endif -%} + # To collect compute node related metrics compute_monitors = cpu.virt_driver diff --git a/tests/unit/test_templates.py b/tests/unit/test_templates.py index f79bf78..69278a9 100644 --- a/tests/unit/test_templates.py +++ b/tests/unit/test_templates.py @@ -30,6 +30,8 @@ }, "compute": { "resume_on_boot": False, + "block_device_allocate_retries": "", + "block_device_allocate_retries_interval": "", "multipath_enabled": False, "virt_type": "kvm", "cpu_mode": "host-passthrough", @@ -96,6 +98,23 @@ def test_nova_clients_use_internal_interface(): ) == 1 +def test_nova_block_device_allocate_retries_only_render_when_set(): + output = _render("nova.conf.j2") + + assert "block_device_allocate_retries" not in output + assert "block_device_allocate_retries_interval" not in output + + compute = { + **BASE_CONTEXT["compute"], + "block_device_allocate_retries": "120", + "block_device_allocate_retries_interval": "3", + } + output = _render("nova.conf.j2", compute=compute) + + assert "block_device_allocate_retries = 120" in output + assert "block_device_allocate_retries_interval = 3" in output + + def test_neutron_clients_use_internal_interface(): output = _render("neutron.conf.j2")