From ac7c1e96e3709785395db275feb83419c13e1c13 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Mon, 11 Mar 2024 16:48:48 +0000 Subject: [PATCH] Support custom Nova Compute Ironic host names This fixes an issue where it is not possible to customise the `host` config option in the Nova Compute Ironic config file without breaking detection of the service. This is a backwards compatible fix, which allows a user to set the `host` config option using Ansible host or group vars. Other reasons for not using the default host setting of `{{ ansible_hostname }}-ironic` are covered in [1]. [1] https://specs.openstack.org/openstack/nova-specs/specs/2024.1/approved/ironic-shards.html#migrate-from-peer-list-to-shard-key. Closes-Bug: #2056571 Change-Id: I9b562f6a5722f21b7dbec2a4d53a46a57c829155 --- .../tasks/wait_discover_computes.yml | 2 +- .../roles/nova-cell/templates/nova.conf.j2 | 2 +- .../reference/bare-metal/ironic-guide.rst | 43 +++++++++++++++++++ ...e-ironic-host-option-a7a3f6ae095f5201.yaml | 6 +++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-setting-nova-compute-ironic-host-option-a7a3f6ae095f5201.yaml diff --git a/ansible/roles/nova-cell/tasks/wait_discover_computes.yml b/ansible/roles/nova-cell/tasks/wait_discover_computes.yml index 1a7a99a527..1603af5dea 100644 --- a/ansible/roles/nova-cell/tasks/wait_discover_computes.yml +++ b/ansible/roles/nova-cell/tasks/wait_discover_computes.yml @@ -79,7 +79,7 @@ # configure for [DEFAULT] host in nova.conf. ironic_compute_service_hosts: >- {{ ironic_computes_in_batch | - map('extract', hostvars, ['ansible_facts', 'hostname']) | + map('extract', hostvars) | json_query('[].nova_compute_ironic_custom_host || [].ansible_facts.hostname') | map('regex_replace', '^(.*)$', '\1-ironic') | list }} expected_compute_service_hosts: "{{ virt_compute_service_hosts + ironic_compute_service_hosts }}" diff --git a/ansible/roles/nova-cell/templates/nova.conf.j2 b/ansible/roles/nova-cell/templates/nova.conf.j2 index 5d01a73f77..47f3d1e21e 100644 --- a/ansible/roles/nova-cell/templates/nova.conf.j2 +++ b/ansible/roles/nova-cell/templates/nova.conf.j2 @@ -9,7 +9,7 @@ state_path = /var/lib/nova allow_resize_to_same_host = true {% if service_name == "nova-compute-ironic" %} -host={{ ansible_facts.hostname }}-ironic +host={{ nova_compute_ironic_custom_host | default(ansible_facts.hostname) }}-ironic log_file = /var/log/kolla/nova/nova-compute-ironic.log compute_driver = ironic.IronicDriver ram_allocation_ratio = 1.0 diff --git a/doc/source/reference/bare-metal/ironic-guide.rst b/doc/source/reference/bare-metal/ironic-guide.rst index b58d1e843a..bf57a8f146 100644 --- a/doc/source/reference/bare-metal/ironic-guide.rst +++ b/doc/source/reference/bare-metal/ironic-guide.rst @@ -148,6 +148,49 @@ variable ``ironic_enable_keystone_integration`` to ``"yes"`` ironic_enable_keystone_integration: "yes" +Avoiding problems with high availability +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. note:: + + This section assumes that you have not yet deployed the Nova Compute + Ironic service. If you have already deployed multiple instances of the + service and have one or more baremetal nodes registered, the following + operations are non-trivial. You will likely have to use the `nova-manage` + command (or pre-Caracal edit the DB) to ensure that all Ironic nodes + are registered with a single Nova Compute Ironic instance. This is + an advanced subject and is not covered here. Stop now if you don't + know what you are doing. + +Nova Compute Ironic HA is known to be unstable. Pending a better solution, +a workaround is to avoid the feature by running a single Nova Compute Ironic +instance. For example: + +.. code-block:: diff + + - [nova-compute-ironic:children] + - nova + + [nova-compute-ironic] + + controller1 + +If you choose to do this, it is helpful to pin the service host name +to a 'synthetic' constant. This means that if you need to re-deploy the +service to another host, the Ironic nodes will automatically use the new +service instance. Otherwise you will need to manually move active Ironic nodes +to the new service, with either the `nova-manage` CLI, or pre-Caracal, by +editing the Nova database. + +The config option to pin the host name is `nova_compute_ironic_custom_host` +and must be set as a group or host var. Note that, unless you know what you +are doing, you must not change or set this option if you have already deployed +Ironic nodes. + +This config option is also useful for Ironic Shards. Whilst these are not +explicitly supported by Kolla Ansible, some further information can be found +`here `__. + +Note that Ironic HA is not affected, and continues to work as normal. + Deployment ~~~~~~~~~~ Run the deploy as usual: diff --git a/releasenotes/notes/fix-setting-nova-compute-ironic-host-option-a7a3f6ae095f5201.yaml b/releasenotes/notes/fix-setting-nova-compute-ironic-host-option-a7a3f6ae095f5201.yaml new file mode 100644 index 0000000000..1a444f6356 --- /dev/null +++ b/releasenotes/notes/fix-setting-nova-compute-ironic-host-option-a7a3f6ae095f5201.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes the detection of the Nova Compute Ironic service when a custom `host` + option is set in the service config file. + See `LP#2056571 `__