From 1d864b6cb680145104134d96fa9840ee2663d28a Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Wed, 30 Oct 2024 05:02:33 -0700 Subject: [PATCH] [receiver/hostmetrics] Fix filesystems scraper behavior when root file system is mounted (#36000) #### Description Do not set the default value of HOST_PROC_MOUNTINFO to respect root_path #### Link to tracking issue Fixes #35990 --- .chloggen/fix_filesystems_scraping.yaml | 27 +++++++++++++++++++ .../hostmetricsreceiver/hostmetrics_linux.go | 13 +++++---- .../hostmetrics_linux_test.go | 11 ++++---- 3 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 .chloggen/fix_filesystems_scraping.yaml diff --git a/.chloggen/fix_filesystems_scraping.yaml b/.chloggen/fix_filesystems_scraping.yaml new file mode 100644 index 000000000000..cb5454490da5 --- /dev/null +++ b/.chloggen/fix_filesystems_scraping.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: hostmetricsreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Do not set the default value of HOST_PROC_MOUNTINFO to respect root_path + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35990] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/receiver/hostmetricsreceiver/hostmetrics_linux.go b/receiver/hostmetricsreceiver/hostmetrics_linux.go index 132eb3978d08..43b83fcea692 100644 --- a/receiver/hostmetricsreceiver/hostmetrics_linux.go +++ b/receiver/hostmetricsreceiver/hostmetrics_linux.go @@ -14,13 +14,12 @@ import ( ) var gopsutilEnvVars = map[common.EnvKeyType]string{ - common.HostProcEnvKey: "/proc", - common.HostSysEnvKey: "/sys", - common.HostEtcEnvKey: "/etc", - common.HostVarEnvKey: "/var", - common.HostRunEnvKey: "/run", - common.HostDevEnvKey: "/dev", - common.HostProcMountinfo: "", + common.HostProcEnvKey: "/proc", + common.HostSysEnvKey: "/sys", + common.HostEtcEnvKey: "/etc", + common.HostVarEnvKey: "/var", + common.HostRunEnvKey: "/run", + common.HostDevEnvKey: "/dev", } // This exists to validate that different instances of the hostmetricsreceiver do not diff --git a/receiver/hostmetricsreceiver/hostmetrics_linux_test.go b/receiver/hostmetricsreceiver/hostmetrics_linux_test.go index d6c3cd7f1ad3..3876c4444cda 100644 --- a/receiver/hostmetricsreceiver/hostmetrics_linux_test.go +++ b/receiver/hostmetricsreceiver/hostmetrics_linux_test.go @@ -50,12 +50,11 @@ func TestLoadConfigRootPath(t *testing.T) { cpuScraperCfg := (&cpuscraper.Factory{}).CreateDefaultConfig() cpuScraperCfg.SetRootPath("testdata") cpuScraperCfg.SetEnvMap(common.EnvMap{ - common.HostDevEnvKey: "testdata/dev", - common.HostEtcEnvKey: "testdata/etc", - common.HostProcMountinfo: "testdata", - common.HostRunEnvKey: "testdata/run", - common.HostSysEnvKey: "testdata/sys", - common.HostVarEnvKey: "testdata/var", + common.HostDevEnvKey: "testdata/dev", + common.HostEtcEnvKey: "testdata/etc", + common.HostRunEnvKey: "testdata/run", + common.HostSysEnvKey: "testdata/sys", + common.HostVarEnvKey: "testdata/var", }) expectedConfig.Scrapers = map[string]internal.Config{cpuscraper.TypeStr: cpuScraperCfg}