Skip to content

Avoid root logger setup when SELinux helper is missing#30

Open
coiby wants to merge 1 commit into
teemtee:mainfrom
coiby:has_selinux_log
Open

Avoid root logger setup when SELinux helper is missing#30
coiby wants to merge 1 commit into
teemtee:mainfrom
coiby:has_selinux_log

Conversation

@coiby

@coiby coiby commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

When testcloud's has_selinux() runs on systems where the selinuxenabled command is not installed. The FileNotFoundError handler used module-level logging.debug(), which implicitly calls logging.basicConfig() when the root logger has no handlers.

That creates a default root StreamHandler. Libraries such as tmt use propagating DEBUG-level loggers with their own filtering, so once the root handler exists, their records also get emitted with Python's default format which clutters CI output e.g. [1],

    /plans/example
        discover
            how: shell
            summary: 1 test selected
        provision
            queued provision.provision tasks
                #1: default-0

            provision.provision task #1: default-0
            how: virtual
            ansible: {}

            image: fedora:43
            progress: downloading...
    DEBUG:tmt.run.logger0.provision.provision.queue:        Run command: qemu-img check /var/tmp/tmt/testcloud/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2
    DEBUG:tmt.run.logger0.provision.provision.queue:        environment: {}
    DEBUG:tmt.run.logger0.provision.provision.queue:        Command event: 2.674e-06 waiting for process to finish
    DEBUG:tmt.run.logger0.provision.provision.queue:        stdout: No errors were found on the image.
    DEBUG:tmt.run.logger0.provision.provision.queue:        stdout: 11441/81920 = 13.97% allocated, 91.29% fragmented, 88.97% compressed clusters
    DEBUG:tmt.run.logger0.provision.provision.queue:        stdout: Image end offset: 583335936
    DEBUG:tmt.run.logger0.provision.provision.queue:        Command event: 0.00551 waiting for process completed
    DEBUG:tmt.run.logger0.provision.provision.queue:        Command event: 0.00559 waiting for stream readers
    ....

Log through the testcloud.util module logger instead, preserving the existing library-mode NullHandler behavior and avoiding implicit root logger configuration. Add a regression test for the missing selinuxenabled path.

[1] https://github.com/coiby/kernel-auto-bisect/actions/runs/27798088731/job/82262170969?pr=5

When testcloud's has_selinux() runs on systems where the selinuxenabled
command is not installed. The FileNotFoundError handler used
module-level logging.debug(), which implicitly calls
logging.basicConfig() when the root logger has no handlers.

That creates a default root StreamHandler. Libraries such as tmt use
propagating DEBUG-level loggers with their own filtering, so once the
root handler exists, their records also get emitted with Python's
default format which clutters CI output e.g. [1],
    /plans/example
        discover
            how: shell
            summary: 1 test selected
        provision
            queued provision.provision tasks
                teemtee#1: default-0

            provision.provision task teemtee#1: default-0
            how: virtual
            ansible: {}

            image: fedora:43
            progress: downloading...
    DEBUG:tmt.run.logger0.provision.provision.queue:        Run command: qemu-img check /var/tmp/tmt/testcloud/images/Fedora-Cloud-Base-Generic-43-1.6.x86_64.qcow2
    DEBUG:tmt.run.logger0.provision.provision.queue:        environment: {}
    DEBUG:tmt.run.logger0.provision.provision.queue:        Command event: 2.674e-06 waiting for process to finish
    DEBUG:tmt.run.logger0.provision.provision.queue:        stdout: No errors were found on the image.
    DEBUG:tmt.run.logger0.provision.provision.queue:        stdout: 11441/81920 = 13.97% allocated, 91.29% fragmented, 88.97% compressed clusters
    DEBUG:tmt.run.logger0.provision.provision.queue:        stdout: Image end offset: 583335936
    DEBUG:tmt.run.logger0.provision.provision.queue:        Command event: 0.00551 waiting for process completed
    DEBUG:tmt.run.logger0.provision.provision.queue:        Command event: 0.00559 waiting for stream readers
    ....

Log through the testcloud.util module logger instead, preserving the
existing library-mode NullHandler behavior and avoiding implicit root
logger configuration. Add a regression test for the missing
selinuxenabled path.

[1] https://github.com/coiby/kernel-auto-bisect/actions/runs/27798088731/job/82262170969?pr=5

Assisted-by: Codex:gpt-5.5
@coiby coiby force-pushed the has_selinux_log branch from 2e1cc64 to eda374a Compare June 20, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant