From b74cdd22141cf287d29e21589566119e5d15905c Mon Sep 17 00:00:00 2001 From: Katarzyna Kujawa Date: Wed, 24 Jun 2020 11:01:10 +0200 Subject: [PATCH 1/3] Change warning for resctrl path to Info with verbosity level Change info log to Info with verbosity level Change imports grouping Signed-off-by: Katarzyna Kujawa --- manager/manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager/manager.go b/manager/manager.go index 67a424ad..957e6c2a 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -18,7 +18,6 @@ package manager import ( "flag" "fmt" - "github.com/opencontainers/runc/libcontainer/cgroups/fs2" "net/http" "os" "path" @@ -46,6 +45,7 @@ import ( "github.com/google/cadvisor/utils/sysfs" "github.com/google/cadvisor/version" "github.com/google/cadvisor/watcher" + "github.com/opencontainers/runc/libcontainer/cgroups/fs2" "github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/intelrdt" @@ -957,11 +957,11 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche resctrlPath, err := intelrdt.GetIntelRdtPath(containerName) if err != nil { - klog.Warningf("Error getting resctrl path: %q", err) + klog.V(4).Infof("Error getting resctrl path: %q", err) } else { cont.resctrlCollector, err = m.resctrlManager.GetCollector(resctrlPath) if err != nil { - klog.Infof("resctrl metrics will not be available for container %s: %s", cont.info.Name, err) + klog.V(4).Infof("resctrl metrics will not be available for container %s: %s", cont.info.Name, err) } } From a8139dcf2ed1cc2f35cd19026b67e91302fb69b4 Mon Sep 17 00:00:00 2001 From: Katarzyna Kujawa Date: Wed, 24 Jun 2020 11:22:16 +0200 Subject: [PATCH 2/3] Add verbosity level to perf Info logs Signed-off-by: Katarzyna Kujawa --- manager/manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager/manager.go b/manager/manager.go index 957e6c2a..de25923b 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -45,9 +45,9 @@ import ( "github.com/google/cadvisor/utils/sysfs" "github.com/google/cadvisor/version" "github.com/google/cadvisor/watcher" - "github.com/opencontainers/runc/libcontainer/cgroups/fs2" "github.com/opencontainers/runc/libcontainer/cgroups" + "github.com/opencontainers/runc/libcontainer/cgroups/fs2" "github.com/opencontainers/runc/libcontainer/intelrdt" "k8s.io/klog/v2" @@ -932,7 +932,7 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche perfCgroupPath := path.Join(fs2.UnifiedMountpoint, containerName) cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath) if err != nil { - klog.Infof("perf_event metrics will not be available for container %s: %s", containerName, err) + klog.V(4).Infof("perf_event metrics will not be available for container %s: %s", containerName, err) } } else { devicesCgroupPath, err := handler.GetCgroupPath("devices") @@ -950,7 +950,7 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche } else { cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath) if err != nil { - klog.Infof("perf_event metrics will not be available for container %s: %s", containerName, err) + klog.V(4).Infof("perf_event metrics will not be available for container %s: %s", containerName, err) } } } From f0721fff43a1e1cbaf9002b185c787c7e7800a79 Mon Sep 17 00:00:00 2001 From: Katarzyna Kujawa Date: Thu, 25 Jun 2020 05:01:36 +0200 Subject: [PATCH 3/3] Add checking if resctrl path exists Signed-off-by: Katarzyna Kujawa --- resctrl/manager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resctrl/manager.go b/resctrl/manager.go index bc9f0b35..cceb28e6 100644 --- a/resctrl/manager.go +++ b/resctrl/manager.go @@ -18,6 +18,8 @@ package resctrl import ( + "os" + "github.com/google/cadvisor/stats" "github.com/opencontainers/runc/libcontainer/intelrdt" @@ -29,6 +31,9 @@ type manager struct { } func (m manager) GetCollector(resctrlPath string) (stats.Collector, error) { + if _, err := os.Stat(resctrlPath); err != nil { + return &stats.NoopCollector{}, err + } collector := newCollector(m.id, resctrlPath) return collector, nil }