From 1e0ca5bdc7cb24a9c8cf8ab09f6715e4224ad4c0 Mon Sep 17 00:00:00 2001 From: Joel Smith Date: Mon, 3 May 2021 08:29:28 -0600 Subject: [PATCH] Fix log spam for du failure on pod etc-hosts metrics --- pkg/kubelet/stats/host_stats_provider.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kubelet/stats/host_stats_provider.go b/pkg/kubelet/stats/host_stats_provider.go index 108fbfb8f14..450b832bff5 100644 --- a/pkg/kubelet/stats/host_stats_provider.go +++ b/pkg/kubelet/stats/host_stats_provider.go @@ -18,6 +18,7 @@ package stats import ( "fmt" + "os" "path/filepath" cadvisorapiv2 "github.com/google/cadvisor/info/v2" @@ -84,6 +85,10 @@ func (h hostStatsProvider) getPodEtcHostsStats(podUID types.UID, rootFsInfo *cad if !isEtcHostsSupported { return nil, nil } + // Some pods have an explicit /etc/hosts mount and the Kubelet will not create an etc-hosts file for them + if _, err := os.Stat(podEtcHostsPath); os.IsNotExist(err) { + return nil, nil + } metrics := volume.NewMetricsDu(podEtcHostsPath) hostMetrics, err := metrics.GetMetrics()