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:
@@ -18,10 +18,12 @@ limitations under the License.
|
||||
|
||||
package cm
|
||||
|
||||
import "fmt"
|
||||
import "errors"
|
||||
|
||||
type unsupportedCgroupManager struct{}
|
||||
|
||||
var errNotSupported = errors.New("Cgroup Manager is not supported in this build")
|
||||
|
||||
// Make sure that unsupportedCgroupManager implements the CgroupManager interface
|
||||
var _ CgroupManager = &unsupportedCgroupManager{}
|
||||
|
||||
@@ -51,11 +53,11 @@ func (m *unsupportedCgroupManager) Update(_ *CgroupConfig) error {
|
||||
}
|
||||
|
||||
func (m *unsupportedCgroupManager) Create(_ *CgroupConfig) error {
|
||||
return fmt.Errorf("Cgroup Manager is not supported in this build")
|
||||
return errNotSupported
|
||||
}
|
||||
|
||||
func (m *unsupportedCgroupManager) GetResourceStats(name CgroupName) (*ResourceStats, error) {
|
||||
return nil, fmt.Errorf("Cgroup Manager is not supported in this build")
|
||||
func (m *unsupportedCgroupManager) MemoryUsage(_ CgroupName) (int64, error) {
|
||||
return -1, errNotSupported
|
||||
}
|
||||
|
||||
func (m *unsupportedCgroupManager) Pids(_ CgroupName) []int {
|
||||
|
Reference in New Issue
Block a user