Skip to content

Commit 0737f4d

Browse files
authored
Merge pull request #892 from stackhpc/upstream/2026.1-2026-06-29
Synchronise 2026.1 with upstream
2 parents ac5bca7 + 6303668 commit 0737f4d

9 files changed

Lines changed: 141 additions & 4 deletions

File tree

ansible/library/kolla_toolbox.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,10 @@ def main(self) -> None:
382382
try:
383383
self._push_private_data_dir(kolla_toolbox, pdd, user)
384384

385+
exec_user = user or 'ansible'
385386
runner_env = {}
387+
if exec_user == 'ansible':
388+
runner_env['HOME'] = _PDD_BASEDIR
386389
if self.module._diff:
387390
runner_env['ANSIBLE_DIFF_MODE'] = '1'
388391

@@ -391,7 +394,7 @@ def main(self) -> None:
391394
['/opt/ansible/bin/ansible-runner', 'run', pdd,
392395
'--playbook', 'main.json',
393396
'--rotate-artifacts', '1'],
394-
user=user,
397+
user=exec_user,
395398
environment=runner_env
396399
)
397400
# exit 2 = task failed/unreachable; handled via event below.

ansible/roles/barbican/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ barbican_api_healthcheck_test:
109109
- >-
110110
healthcheck_curl {{
111111
'https' if barbican_enable_tls_backend | bool else 'http' }}://{{
112-
api_interface_address | put_address_in_context('url') }}:{{ barbican_api_listen_port }}/healthcheck"
112+
api_interface_address | put_address_in_context('url') }}:{{ barbican_api_listen_port }}/healthcheck
113113
barbican_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}"
114114
barbican_api_healthcheck:
115115
interval: "{{ barbican_api_healthcheck_interval }}"

ansible/roles/nova-cell/tasks/version-check.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,47 @@
7575
success_msg: >
7676
Libvirt version check successful: target {{ new_version }} >= current {{ current_version }}.
7777
when: libvirt_version_current_results is not skipped
78+
79+
- name: Check nova_libvirt image provides the libvirt start script
80+
when: enable_nova_libvirt_container | bool and (groups[service.group] | length) > 0
81+
vars:
82+
service_name: "nova-libvirt"
83+
service: "{{ nova_cell_services[service_name] }}"
84+
tags: nova-libvirt-script-check
85+
block:
86+
- name: Look for kolla_nova_libvirt_start in the nova_libvirt image
87+
become: true
88+
kolla_container:
89+
action: "start_container"
90+
command: "ls /usr/local/bin/kolla_nova_libvirt_start"
91+
common_options: "{{ docker_common_options }}"
92+
container_engine: "{{ kolla_container_engine }}"
93+
detach: false
94+
environment:
95+
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
96+
image: "{{ service.image }}"
97+
name: "nova_libvirt_script_check"
98+
restart_policy: oneshot
99+
remove_on_exit: true
100+
register: nova_libvirt_script_check
101+
failed_when: false
102+
check_mode: false
103+
run_once: true
104+
delegate_to: "{{ groups[service.group] | first }}"
105+
106+
- name: Assert the nova_libvirt image is recent enough
107+
run_once: true
108+
delegate_to: "{{ groups[service.group] | first }}"
109+
ansible.builtin.assert:
110+
that:
111+
- "'/usr/local/bin/kolla_nova_libvirt_start' in (nova_libvirt_script_check.stdout | default(''))"
112+
fail_msg: >
113+
The nova_libvirt image '{{ service.image }}' does not contain
114+
/usr/local/bin/kolla_nova_libvirt_start, which this version of
115+
Kolla-Ansible needs to launch libvirtd alongside virtlogd. This
116+
almost always means the container image has not been updated to
117+
match the upgraded Kolla-Ansible code. Pull or build a current
118+
nova-libvirt image before deploying. If you intend to keep using
119+
an older image, skip the tag 'nova-libvirt-script-check'.
120+
success_msg: >
121+
nova_libvirt image provides kolla_nova_libvirt_start.

ansible/roles/nova-cell/templates/nova-libvirt.json.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"command": "/usr/sbin/libvirtd --listen",
2+
"command": "/usr/local/bin/kolla_nova_libvirt_start",
33
"config_files": [
44
{
55
"source": "{{ container_config_directory }}/libvirtd.conf",

ansible/roles/nova-cell/templates/qemu.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
stdio_handler = "file"
1+
stdio_handler = "logd"
22

33
user = "nova"
44
group = "nova"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a stray trailing quote in the ``barbican_api`` healthcheck
5+
command that caused containers to be falsely reported as unhealthy.
6+
`LP#2157639 <https://launchpad.net/bugs/2157639>`__
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
upgrade:
3+
- |
4+
A deploy-time check now verifies that the ``nova_libvirt`` image contains
5+
the ``/usr/local/bin/kolla_nova_libvirt_start`` helper before deploying.
6+
This helper launches ``libvirtd`` alongside ``virtlogd`` and is required
7+
by current Kolla-Ansible. If you upgrade Kolla-Ansible but continue to
8+
use an older ``nova_libvirt`` image that predates the helper, the deploy
9+
now fails fast with an explanatory message instead of leaving the
10+
container unable to start. Pull or build a matching ``nova_libvirt``
11+
image, or skip the ``nova-libvirt-script-check`` tag to bypass the check.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
features:
3+
- |
4+
The ``nova_libvirt`` container now runs ``virtlogd`` as a sidecar
5+
alongside ``libvirtd``, and ``qemu.conf`` is configured with
6+
``stdio_handler = "logd"`` so that libvirt routes instance console
7+
chardevs through ``virtlogd``. This allows guest console logs to be
8+
rotated according to ``/etc/libvirt/virtlogd.conf`` (by default 2MB
9+
per file with 3 backups), instead of growing without bound as they
10+
did when ``stdio_handler`` was set to ``"file"``.
11+
12+
Note that existing instances must be hard rebooted to pick up the
13+
new console handler, as the chardev mode is fixed at qemu launch.

tests/test_kolla_toolbox.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,66 @@ def test_fail_json_when_ansible_runner_not_found(self):
649649
self.fake_ktbw.main)
650650
self.assertIn('ansible-runner', error.result['msg'])
651651

652+
def test_runner_exec_uses_ansible_user_when_no_user_param(self):
653+
"""user=None must exec ansible-runner as 'ansible', not as root.
654+
655+
Podman serialises user=None as null in ExecCreate; some daemon
656+
versions interpret null as UID 0 (root), which breaks openstacksdk
657+
lookups because HOME becomes /root instead of /var/lib/ansible.
658+
"""
659+
self.mock_ansible_module.params['user'] = None
660+
661+
with mock.patch.object(self.fake_ktbw, '_push_private_data_dir'), \
662+
mock.patch.object(self.fake_ktbw, '_parse_runner_result',
663+
return_value={'changed': False}):
664+
self.fake_ktbw.main()
665+
666+
# call[0]=check_runner, call[1]=ansible-runner, call[2]=cleanup
667+
runner_call = self.mock_container.exec_run.call_args_list[1]
668+
self.assertEqual('ansible', runner_call.kwargs.get('user'))
669+
670+
def test_runner_exec_sets_home_to_pdd_basedir_for_ansible_user(self):
671+
"""HOME must be set to _PDD_BASEDIR to finds clouds.yaml."""
672+
self.mock_ansible_module.params['user'] = None
673+
674+
with mock.patch.object(self.fake_ktbw, '_push_private_data_dir'), \
675+
mock.patch.object(self.fake_ktbw, '_parse_runner_result',
676+
return_value={'changed': False}):
677+
self.fake_ktbw.main()
678+
679+
runner_call = self.mock_container.exec_run.call_args_list[1]
680+
env = runner_call.kwargs.get('environment', {})
681+
self.assertEqual(kolla_toolbox._PDD_BASEDIR, env.get('HOME'))
682+
683+
def test_runner_exec_uses_explicit_user_param(self):
684+
"""When user='rabbitmq', ansible-runner must exec as 'rabbitmq'."""
685+
self.mock_ansible_module.params['user'] = 'rabbitmq'
686+
687+
with mock.patch.object(self.fake_ktbw, '_push_private_data_dir'), \
688+
mock.patch.object(self.fake_ktbw, '_parse_runner_result',
689+
return_value={'changed': False}):
690+
self.fake_ktbw.main()
691+
692+
runner_call = self.mock_container.exec_run.call_args_list[1]
693+
self.assertEqual('rabbitmq', runner_call.kwargs.get('user'))
694+
695+
def test_runner_exec_no_home_override_for_non_ansible_user(self):
696+
"""HOME must not be overridden for non-ansible users.
697+
698+
Forcing HOME=/var/lib/ansible when running as rabbitmq causes
699+
PermissionError because rabbitmq cannot write to ansible's home.
700+
"""
701+
self.mock_ansible_module.params['user'] = 'rabbitmq'
702+
703+
with mock.patch.object(self.fake_ktbw, '_push_private_data_dir'), \
704+
mock.patch.object(self.fake_ktbw, '_parse_runner_result',
705+
return_value={'changed': False}):
706+
self.fake_ktbw.main()
707+
708+
runner_call = self.mock_container.exec_run.call_args_list[1]
709+
env = runner_call.kwargs.get('environment', {})
710+
self.assertNotIn('HOME', env)
711+
652712

653713
class TestModuleInteraction(TestKollaToolboxModule):
654714
"""Class focused on testing user input data from playbook."""

0 commit comments

Comments
 (0)