Skip to content

Commit 7ee17ce

Browse files
authored
Merge pull request kubernetes#126488 from haircommander/cri-stats-suffix-hack
kubelet: don't use cadvisor stats if PodAndContainerStatsFromCRI feature is enabled
2 parents 2fb37e2 + 3d3ba6f commit 7ee17ce

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/kubelet/cadvisor/util.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ import (
2323
cadvisorapi2 "github.com/google/cadvisor/info/v2"
2424
"k8s.io/api/core/v1"
2525
"k8s.io/apimachinery/pkg/api/resource"
26+
utilfeature "k8s.io/apiserver/pkg/util/feature"
2627
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
28+
"k8s.io/kubernetes/pkg/features"
2729
)
2830

2931
const (
@@ -73,5 +75,11 @@ func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceLis
7375
// be removed. Related issue:
7476
// https://github.com/kubernetes/kubernetes/issues/51798
7577
func UsingLegacyCadvisorStats(runtimeEndpoint string) bool {
78+
// If PodAndContainerStatsFromCRI feature is enabled, then assume the user
79+
// wants to use CRI stats, as the aforementioned workaround isn't needed
80+
// when this feature is enabled.
81+
if utilfeature.DefaultFeatureGate.Enabled(features.PodAndContainerStatsFromCRI) {
82+
return false
83+
}
7684
return strings.HasSuffix(runtimeEndpoint, CrioSocketSuffix)
7785
}

0 commit comments

Comments
 (0)