Skip to content

Commit e488bd9

Browse files
committed
reduce libvirtd log levels
This change reduces the libvirtd log levels by default from info to warning level. It also makes both the log_output and log_filter configurable with support for partial overrides using the combine filter pattern. Changes included: - Add configurable logging parameters to role defaults - Support partial log filter overrides without redefining all values - Fix template variable references in virtproxyd.conf and virtnodedevd.conf - Add comprehensive parameter documentation in argument_specs.yml - Add molecule test helper for verifying log filter configurations - Update all libvirt service templates to use new logging variables Assisted-By: Claude <[email protected]> Signed-off-by: Sean Mooney <[email protected]>
1 parent 6ae9fe2 commit e488bd9

File tree

12 files changed

+88
-12
lines changed

12 files changed

+88
-12
lines changed

roles/edpm_libvirt/defaults/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,20 @@ edpm_libvirt_password_path: /var/lib/openstack/configs/{{ edpm_libvirt_service_n
7272
# certs
7373
edpm_libvirt_tls_certs_enabled: "{{ edpm_tls_certs_enabled | default(False) }}"
7474
edpm_libvirt_tls_cert_src_dir: /var/lib/openstack/certs/{{ edpm_libvirt_service_name }}/default
75+
# logging
76+
# levels 1: debug, 2: info, 3:warning, 4:error
77+
# by default we send warning and error log to the journal
78+
# and do not output debug or info logs to any location
79+
# this is a space separated list of output <level>:<output method>
80+
# https://libvirt.org/logging.html
81+
edpm_libvirt_log_outputs: "3:journald"
82+
edpm_libvirt_default_log_filters: "3:qemu 3:libvirt 4:object 4:json 4:event 3:util"
83+
edpm_libvirt_log_filters_defaults:
84+
virtqemud: "{{ edpm_libvirt_default_log_filters }}"
85+
virtlogd: "{{ edpm_libvirt_default_log_filters }}"
86+
virtproxyd: "{{ edpm_libvirt_default_log_filters }}"
87+
virtsecretd: "{{ edpm_libvirt_default_log_filters }}"
88+
virtnodedevd: "{{ edpm_libvirt_default_log_filters }}"
89+
90+
# Merge user overrides with defaults
91+
edpm_libvirt_log_filters: "{{ edpm_libvirt_log_filters_defaults | combine(edpm_libvirt_log_filters_override | default({})) }}"

roles/edpm_libvirt/meta/argument_specs.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,28 @@ argument_specs:
6464
type: str
6565
description: The vhost user socket directory group name.
6666
default: ''
67+
edpm_libvirt_log_outputs:
68+
type: str
69+
description: Libvirt log output configuration (level:destination format).
70+
default: "3:journald"
71+
edpm_libvirt_default_log_filters:
72+
type: str
73+
description: Default log filter configuration for all libvirt services.
74+
default: "3:qemu 3:libvirt 4:object 4:json 4:event 3:util"
75+
edpm_libvirt_log_filters_defaults:
76+
type: dict
77+
description: Dictionary of default log filters for each libvirt service.
78+
default:
79+
virtqemud: "{{ edpm_libvirt_default_log_filters }}"
80+
virtlogd: "{{ edpm_libvirt_default_log_filters }}"
81+
virtproxyd: "{{ edpm_libvirt_default_log_filters }}"
82+
virtsecretd: "{{ edpm_libvirt_default_log_filters }}"
83+
virtnodedevd: "{{ edpm_libvirt_default_log_filters }}"
84+
edpm_libvirt_log_filters_override:
85+
type: dict
86+
description: Dictionary of log filter overrides for specific libvirt services.
87+
default: {}
88+
edpm_libvirt_log_filters:
89+
type: dict
90+
description: Combined log filters (defaults merged with overrides) for each libvirt service.
91+
default: "{{ edpm_libvirt_log_filters_defaults | combine(edpm_libvirt_log_filters_override | default({})) }}"

roles/edpm_libvirt/molecule/default/converge.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@
1919
edpm_libvirt_tls_cert_src_dir: /tmp/pki
2020
edpm_libvirt_tls_certs_enabled: true
2121
edpm_libvirt_password_path: /tmp/libvirtpw
22+
edpm_libvirt_log_filters_override:
23+
virtqemud: "1:qemu 2:libvirt 3:object 4:json"

roles/edpm_libvirt/molecule/default/prepare.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@
6767
ansible.builtin.import_role:
6868
name: osp.edpm.edpm_timezone
6969

70+
- name: remove vagrant image packages
71+
become: true
72+
ansible.builtin.dnf:
73+
name: "{{ item }}"
74+
state: absent
75+
loop:
76+
# NOTE(sean-k-mooney): without this network connectivity will be lost
77+
# when the nft rules are applied as firewalld conflicts with the rules
78+
# we set.
79+
- firewalld
80+
7081
- name: Create firewall directory
7182
become: true
7283
ansible.builtin.file:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
- name: Verify libvirt logging
2+
vars:
3+
expected: "{{item.expected | default('3:qemu 3:libvirt 4:object 4:json 4:event 3:util')}}"
4+
block:
5+
- name: Detect if libvirt log filters exists {{item.dest}} {{expected}}
6+
become: true
7+
ansible.builtin.command: grep -q 'log_filters="{{expected}}"' {{item.dest}}
8+
register: libvirt_filter_exists
9+
- name: Assert log filter exists in {{item.dest}}
10+
ansible.builtin.assert:
11+
that:
12+
- libvirt_filter_exists.rc == 0
13+
fail_msg: "libvirt log_filters are incorrect in {{item.dest}} {{expected}}"

roles/edpm_libvirt/molecule/default/verify.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
vars:
88
test_helper_dir: "../../../../molecule/test-helpers"
99
tasks:
10+
- name: ensure libvirt socket activation drop-in directories exist
11+
ansible.builtin.include_tasks: "test-helpers/verify_logging.yaml"
12+
loop:
13+
- {"dest": "/etc/libvirt/virtlogd.conf"}
14+
- {"dest": "/etc/libvirt/virtnodedevd.conf"}
15+
- {"dest": "/etc/libvirt/virtproxyd.conf"}
16+
- {"dest": "/etc/libvirt/virtsecretd.conf"}
17+
- {"dest": "/etc/libvirt/virtqemud.conf", "expected": "1:qemu 2:libvirt 3:object 4:json"}
1018
- name: ensure expected directories exist
1119
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
1220
loop:

roles/edpm_libvirt/molecule/vagrant/molecule.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ driver:
77
name: libvirt
88
provision: no
99
parallel: true
10-
default_box: 'generic/rocky9'
11-
# default_box: 'generic/centos9s'
10+
# default_box: 'generic/rocky9'
11+
default_box: 'generic/centos9s'
1212
platforms:
1313
- name: compute-1
1414
memory: 8192
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
log_filters="1:logging 4:object 4:json 4:event 1:util"
2-
log_outputs="2:journald"
1+
log_filters="{{edpm_libvirt_log_filters['virtlogd']}}"
2+
log_outputs="{{edpm_libvirt_log_outputs}}"

roles/edpm_libvirt/templates/virtnodedevd.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ unix_sock_ro_perms="0444"
22
unix_sock_rw_perms="0770"
33
auth_unix_ro="none"
44
auth_unix_rw="none"
5-
log_filters="1:qemu 1:libvirt 4:object 4:json 4:event 1:util"
6-
log_outputs="2:journald"
5+
log_filters="{{edpm_libvirt_log_filters['virtnodedevd']}}"
6+
log_outputs="{{edpm_libvirt_log_outputs}}"

roles/edpm_libvirt/templates/virtproxyd.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ unix_sock_rw_perms="0770"
33
auth_unix_ro="none"
44
auth_unix_rw="none"
55
auth_tls="sasl"
6-
log_filters="1:qemu 1:libvirt 4:object 4:json 4:event 1:util"
7-
log_outputs="2:journald"
6+
log_filters="{{edpm_libvirt_log_filters['virtproxyd']}}"
7+
log_outputs="{{edpm_libvirt_log_outputs}}"

0 commit comments

Comments
 (0)