diff --git a/deployment/logging/files/nova-libvirt.yaml b/deployment/logging/files/nova-libvirt.yaml new file mode 100644 index 0000000000..48110a744b --- /dev/null +++ b/deployment/logging/files/nova-libvirt.yaml @@ -0,0 +1,48 @@ +heat_template_version: rocky + +description: > + OpenStack containerized Nova libvirt service + +parameters: + LibvirtLogLevel: + default: 3 + description: Defines log level in libvirt to filter log output. + See https://libvirt.org/logging.html to find its detail. + type: number + constraints: + - range: { min: 1, max: 4 } + +outputs: + config_settings: + description: Extra hieradata needed to log to files in the host. + value: + nova::compute::libvirt::log_outputs: + str_replace: + template: + 'LEVEL:file:/var/log/libvirt/libvirtd.log' + params: + LEVEL: {get_param: LibvirtLogLevel} + volumes: + description: The volumes needed to log to files in the host. + value: + - /var/log/containers/libvirt:/var/log/libvirt:z + docker_config: + description: Extra containers needed for logging to file in the host. + value: null + host_prep_tasks: + description: Extra ansible tasks needed for logging to files in the host. + value: + - name: create persistent directories + file: + path: "{{ item.path }}" + setype: "{{ item.setype }}" + state: directory + with_items: + - { 'path': /var/log/containers/libvirt, 'setype': svirt_sandbox_file_t } + - name: libvirt logs readme + copy: + dest: /var/log/libvirt/readme.txt + content: | + Log files from libvirt containers can be found under + /var/log/containers/libvirt. + ignore_errors: true diff --git a/deployment/logging/stdout/nova-libvirt.yaml b/deployment/logging/stdout/nova-libvirt.yaml index 227e94e1e2..7353a6e927 100644 --- a/deployment/logging/stdout/nova-libvirt.yaml +++ b/deployment/logging/stdout/nova-libvirt.yaml @@ -3,11 +3,25 @@ heat_template_version: rocky description: > OpenStack containerized Nova libvirt service +parameters: + LibvirtLogLevel: + default: 3 + description: Defines log level in libvirt to filter log output. + See https://libvirt.org/logging.html to find its detail. + type: number + constraints: + - range: { min: 1, max: 4 } + outputs: config_settings: description: Extra hieradata needed to log to stdout. value: - nova::compute::libvirt::log_outputs: '3:stderr' + nova::compute::libvirt::log_outputs: + str_replace: + template: + 'LEVEL:stderr' + params: + LEVEL: {get_param: LibvirtLogLevel} docker_config: description: Extra containers needed for logging to stdout or a sidecar container. value: null @@ -15,5 +29,5 @@ outputs: description: The volumes needed to log to stdout or a sidecar container. value: null host_prep_tasks: - description: Extra ansible tasks needed for logging to files in the host. + description: Extra ansible tasks needed for logging to stdout or a sidecar container. value: null diff --git a/deployment/nova/nova-libvirt-container-puppet.yaml b/deployment/nova/nova-libvirt-container-puppet.yaml index c5965bf15f..8c93688caa 100644 --- a/deployment/nova/nova-libvirt-container-puppet.yaml +++ b/deployment/nova/nova-libvirt-container-puppet.yaml @@ -212,11 +212,6 @@ parameters: type: boolean tags: - role_specific - LibvirtLogOutputs: - description: Defines how log outputs are sent, as described in - https://libvirt.org/logging.html . - type: string - default: '3:file:/var/log/libvirt/libvirtd.log' LibvirtLogFilters: description: Defines a filter to select a different logging level for a given category log outputs, as specified in @@ -398,7 +393,6 @@ outputs: "%{hiera('$NETWORK')}" params: $NETWORK: {get_param: [ServiceNetMap, NovaLibvirtNetwork]} - nova::compute::libvirt::log_outputs: {get_param: LibvirtLogOutputs} nova::compute::libvirt::log_filters: {get_param: LibvirtLogFilters} rbd_persistent_storage: {get_param: CinderEnableRbdBackend} tripleo::nova_libvirt::firewall_rules: @@ -690,6 +684,7 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NovaLibvirtLogging, volumes]} - - /var/lib/kolla/config_files/nova_libvirt.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/nova_libvirt/:/var/lib/kolla/config_files/src:ro @@ -701,7 +696,6 @@ outputs: - /etc/libvirt:/etc/libvirt - /var/run/libvirt:/var/run/libvirt:shared,z - /var/lib/libvirt:/var/lib/libvirt:shared,z - - /var/log/containers/libvirt:/var/log/libvirt:z - /var/log/libvirt/qemu:/var/log/libvirt/qemu:ro - /var/lib/vhost_sockets:/var/lib/vhost_sockets:z # podman fails to relable if nova_nfs_enabled where we have @@ -823,72 +817,73 @@ outputs: msg: nova-libvirt isn't working (healtcheck failed) when: nova_libvirt_healthcheck_state.status.ExecMainStatus != '0' host_prep_tasks: - - name: create libvirt persistent data directories - file: - path: "{{ item.path }}" - state: directory - setype: "{{ item.setype }}" - with_items: - - { 'path': /etc/libvirt, 'setype': svirt_sandbox_file_t } - - { 'path': /etc/libvirt/secrets, 'setype': svirt_sandbox_file_t } - - { 'path': /etc/libvirt/qemu, 'setype': svirt_sandbox_file_t } - - { 'path': /var/lib/libvirt, 'setype': svirt_sandbox_file_t } - - { 'path': /var/lib/nova, 'setype': svirt_sandbox_file_t } - - { 'path': /var/log/containers/libvirt, 'setype': svirt_sandbox_file_t } - - { 'path': /var/run/libvirt, 'setype': virt_var_run_t } - - { 'path': /var/log/libvirt, 'setype': svirt_sandbox_file_t } - - { 'path': /var/log/libvirt/qemu, 'setype': svirt_sandbox_file_t } - # qemu user on host will be cretaed by libvirt package install, ensure - # the qemu user created with same uid/gid as like libvirt package. - # These specific values are required since ovs is running on host. - # Once ovs with DPDK is containerized, we could modify this uid/gid - # to match with kolla config values. - - name: ensure qemu group is present on the host - group: - name: qemu - gid: 107 - state: present - - name: ensure qemu user is present on the host - user: - name: qemu - uid: 107 - group: qemu - state: present - shell: /sbin/nologin - comment: qemu user - - name: create directory for vhost-user sockets with qemu ownership - file: - path: /var/lib/vhost_sockets - state: directory - owner: qemu - group: {get_attr: [RoleParametersValue, value, vhostuser_socket_group]} - setype: virt_cache_t - seuser: system_u - - name: ensure ceph configurations exist - file: - path: /etc/ceph - state: directory - - name: check if libvirt is installed - command: /usr/bin/rpm -q libvirt-daemon - failed_when: false - register: libvirt_installed - check_mode: no - - name: make sure libvirt services are disabled and masked - service: - name: "{{ item }}" - state: stopped - enabled: no - masked: yes - daemon_reload: yes - with_items: - - libvirtd.service - - virtlogd.socket - when: libvirt_installed.rc == 0 - - name: ensure /var/run/libvirt is present upon reboot - copy: - dest: /etc/tmpfiles.d/var-run-libvirt.conf - content: | - d /var/run/libvirt 0755 root root - - + list_concat: + - {get_attr: [NovaLibvirtLogging, host_prep_tasks]} + - - name: create libvirt persistent data directories + file: + path: "{{ item.path }}" + state: directory + setype: "{{ item.setype }}" + with_items: + - { 'path': /etc/libvirt, 'setype': svirt_sandbox_file_t } + - { 'path': /etc/libvirt/secrets, 'setype': svirt_sandbox_file_t } + - { 'path': /etc/libvirt/qemu, 'setype': svirt_sandbox_file_t } + - { 'path': /var/lib/libvirt, 'setype': svirt_sandbox_file_t } + - { 'path': /var/lib/nova, 'setype': svirt_sandbox_file_t } + - { 'path': /var/run/libvirt, 'setype': virt_var_run_t } + - { 'path': /var/log/libvirt, 'setype': svirt_sandbox_file_t } + - { 'path': /var/log/libvirt/qemu, 'setype': svirt_sandbox_file_t } + # qemu user on host will be cretaed by libvirt package install, ensure + # the qemu user created with same uid/gid as like libvirt package. + # These specific values are required since ovs is running on host. + # Once ovs with DPDK is containerized, we could modify this uid/gid + # to match with kolla config values. + - name: ensure qemu group is present on the host + group: + name: qemu + gid: 107 + state: present + - name: ensure qemu user is present on the host + user: + name: qemu + uid: 107 + group: qemu + state: present + shell: /sbin/nologin + comment: qemu user + - name: create directory for vhost-user sockets with qemu ownership + file: + path: /var/lib/vhost_sockets + state: directory + owner: qemu + group: {get_attr: [RoleParametersValue, value, vhostuser_socket_group]} + setype: virt_cache_t + seuser: system_u + - name: ensure ceph configurations exist + file: + path: /etc/ceph + state: directory + - name: check if libvirt is installed + command: /usr/bin/rpm -q libvirt-daemon + failed_when: false + register: libvirt_installed + check_mode: no + - name: make sure libvirt services are disabled and masked + service: + name: "{{ item }}" + state: stopped + enabled: no + masked: yes + daemon_reload: yes + with_items: + - libvirtd.service + - virtlogd.socket + when: libvirt_installed.rc == 0 + - name: ensure /var/run/libvirt is present upon reboot + copy: + dest: /etc/tmpfiles.d/var-run-libvirt.conf + content: | + d /var/run/libvirt 0755 root root - - metadata_settings: list_concat: - if: diff --git a/overcloud-resource-registry-puppet.j2.yaml b/overcloud-resource-registry-puppet.j2.yaml index 311cf727ca..eff86ea4a2 100644 --- a/overcloud-resource-registry-puppet.j2.yaml +++ b/overcloud-resource-registry-puppet.j2.yaml @@ -348,7 +348,7 @@ resource_registry: OS::TripleO::Services::Logging::NovaApi: deployment/logging/files/nova-api.yaml OS::TripleO::Services::Logging::NovaMetadata: deployment/logging/files/nova-metadata.yaml OS::TripleO::Services::Logging::NovaCommon: deployment/logging/files/nova-common.yaml - OS::TripleO::Services::Logging::NovaLibvirt: OS::Heat::None + OS::TripleO::Services::Logging::NovaLibvirt: deployment/logging/files/nova-libvirt.yaml OS::TripleO::Services::Logging::OpenDaylightApi: deployment/deprecated/opendaylight/opendaylight-api-container-puppet.yaml OS::TripleO::Services::Logging::PlacementApi: deployment/logging/files/placement-api.yaml diff --git a/releasenotes/notes/nova_libvirtd_log_level-b1393b582360ad4f.yaml b/releasenotes/notes/nova_libvirtd_log_level-b1393b582360ad4f.yaml new file mode 100644 index 0000000000..eec15988f6 --- /dev/null +++ b/releasenotes/notes/nova_libvirtd_log_level-b1393b582360ad4f.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + LibvirtLogLevel is added to configure libvirt log level. This option + also works if environments/stdout-logging.yaml used to enable stdout + logging +deprecations: + - | + LibvirtLogOutputs option was removed and now has no effect. Use + LivirtLogLevel to change log level in libvirt.