kubelet/cm: GetResourceStats -> MemoryUsage
Commit cc50aa9dfb
introduced GetResourceStats, a method which collected
all the statistics from various cgroup controllers, only to discard all
of the info collected except a single value (memory usage).
While one may argue that this method can potentially be used from other
places, this did not happen since it was added 4+ years ago.
Let's streamline this code and only collect what we need, i.e. memory
usage. Rename the method accordingly.
While at it, fix pkg/kubelet/cm/cgroup_manager_unsupported.go to not
instantiate a new error every time a method is called.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -28,7 +28,7 @@ import (
|
||||
|
||||
units "github.com/docker/go-units"
|
||||
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/kubernetes/pkg/api/v1/resource"
|
||||
v1qos "k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
|
||||
@@ -247,12 +247,11 @@ func (m *qosContainerManagerImpl) retrySetMemoryReserve(configs map[v1.PodQOSCla
|
||||
// Attempt to set the limit near the current usage to put pressure
|
||||
// on the cgroup and prevent further growth.
|
||||
for qos, config := range configs {
|
||||
stats, err := m.cgroupManager.GetResourceStats(config.Name)
|
||||
usage, err := m.cgroupManager.MemoryUsage(config.Name)
|
||||
if err != nil {
|
||||
klog.V(2).InfoS("Failed to get resource stats", "err", err)
|
||||
return
|
||||
}
|
||||
usage := stats.MemoryStats.Usage
|
||||
|
||||
// Because there is no good way to determine of the original Update()
|
||||
// on the memory resource was successful, we determine failure of the
|
||||
|
Reference in New Issue
Block a user