Merge pull request #2596 from katarzyna-z/kk-logs-resctrl

Verbosity level for resctrl and perf logs
This commit is contained in:
David Ashpole 2020-06-25 09:47:21 -07:00 committed by GitHub
commit 922aa83feb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -18,7 +18,6 @@ package manager
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
"net/http" "net/http"
"os" "os"
"path" "path"
@ -48,6 +47,7 @@ import (
"github.com/google/cadvisor/watcher" "github.com/google/cadvisor/watcher"
"github.com/opencontainers/runc/libcontainer/cgroups" "github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
"github.com/opencontainers/runc/libcontainer/intelrdt" "github.com/opencontainers/runc/libcontainer/intelrdt"
"k8s.io/klog/v2" "k8s.io/klog/v2"
@ -932,7 +932,7 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
perfCgroupPath := path.Join(fs2.UnifiedMountpoint, containerName) perfCgroupPath := path.Join(fs2.UnifiedMountpoint, containerName)
cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath) cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath)
if err != nil { 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 { } else {
devicesCgroupPath, err := handler.GetCgroupPath("devices") devicesCgroupPath, err := handler.GetCgroupPath("devices")
@ -950,18 +950,18 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
} else { } else {
cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath) cont.perfCollector, err = m.perfManager.GetCollector(perfCgroupPath)
if err != nil { 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)
} }
} }
} }
resctrlPath, err := intelrdt.GetIntelRdtPath(containerName) resctrlPath, err := intelrdt.GetIntelRdtPath(containerName)
if err != nil { if err != nil {
klog.Warningf("Error getting resctrl path: %q", err) klog.V(4).Infof("Error getting resctrl path: %q", err)
} else { } else {
cont.resctrlCollector, err = m.resctrlManager.GetCollector(resctrlPath) cont.resctrlCollector, err = m.resctrlManager.GetCollector(resctrlPath)
if err != nil { 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)
} }
} }

View File

@ -18,6 +18,8 @@
package resctrl package resctrl
import ( import (
"os"
"github.com/google/cadvisor/stats" "github.com/google/cadvisor/stats"
"github.com/opencontainers/runc/libcontainer/intelrdt" "github.com/opencontainers/runc/libcontainer/intelrdt"
@ -29,6 +31,9 @@ type manager struct {
} }
func (m manager) GetCollector(resctrlPath string) (stats.Collector, error) { 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) collector := newCollector(m.id, resctrlPath)
return collector, nil return collector, nil
} }