diff --git a/README.md b/README.md index 899041a..9c5a4e5 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,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 9653476..a4b5226 100644 --- a/openstack_hypervisor/hooks.py +++ b/openstack_hypervisor/hooks.py @@ -556,6 +556,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 85015b1..6d44ee4 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 ff8807a..e0eca3f 100644 --- a/tests/unit/test_templates.py +++ b/tests/unit/test_templates.py @@ -19,6 +19,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", @@ -82,6 +84,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")