Skip to content

Suppress warnings for virtualization detection when access is denied (Android / OpenTelemetry Collector context) #1924

@cforce

Description

@cforce

When gopsutil tries to determine if it is running inside a virtual machine, it currently attempts to access /proc/bus/pci/devices and similar paths.
On Android, this is blocked by SELinux neverallow rules. The access attempt results in repeated AVC denials being logged (avc: denied { getattr } …), which show up as warnings in the logs.

From an application perspective (e.g. when running the OpenTelemetry Collector inside an Android emulator), this creates a lot of noise:

The check for virtualization is expected and normal.

Failing to read those files should not be treated as a warning condition, since it is not an actionable error.

The noise makes it harder to spot real warnings or problems in the logs.

Proposal:

Make virtualization detection more tolerant:

If access is denied (EACCES / EPERM), treat this as "information not available" rather than logging a warning.

Return a neutral/fallback result (false or "unknown") silently.

Only log a warning if the failure is unexpected or indicates a real problem (e.g. corrupted file, unexpected read error).

Context / Motivation:
We are using the OpenTelemetry Collector in an Android emulator environment. Because the collector depends on gopsutil, we get repeated SELinux AVC warnings for this check. The result is a lot of distracting log noise, even though the software works correctly.

Having a way to suppress or downgrade these messages (e.g. to debug level, or ignore entirely) would improve developer and operator experience. The goal is to only have real warnings in the logs, not expected denials from environment-specific checks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions