diff --git a/pkg/kubelet/server/stats/summary.go b/pkg/kubelet/server/stats/summary.go index a2f8c663b81..b0ad72590ca 100644 --- a/pkg/kubelet/server/stats/summary.go +++ b/pkg/kubelet/server/stats/summary.go @@ -164,12 +164,14 @@ func (sb *summaryBuilder) containerInfoV2FsStats( cs.Logs = &stats.FsStats{ AvailableBytes: &sb.rootFsInfo.Available, CapacityBytes: &sb.rootFsInfo.Capacity, + InodesFree: &sb.rootFsInfo.InodesFree, } // The container rootFs lives on the imageFs devices (which may not be the node root fs) cs.Rootfs = &stats.FsStats{ AvailableBytes: &sb.imageFsInfo.Available, CapacityBytes: &sb.imageFsInfo.Capacity, + InodesFree: &sb.imageFsInfo.InodesFree, } lcs, found := sb.latestContainerStats(info) if !found { diff --git a/pkg/kubelet/server/stats/summary_test.go b/pkg/kubelet/server/stats/summary_test.go index cb38951f070..5b57748e819 100644 --- a/pkg/kubelet/server/stats/summary_test.go +++ b/pkg/kubelet/server/stats/summary_test.go @@ -89,6 +89,14 @@ func TestBuildSummary(t *testing.T) { cName10 = "c0" // ensure cName10 conflicts with cName02, but is in a different pod cName20 = "c1" // ensure cName20 conflicts with cName01, but is in a different pod + namespace ) + const ( + rootfsCapacity = uint64(10000000) + rootfsAvailable = uint64(5000000) + rootfsInodesFree = uint64(1000) + imagefsCapacity = uint64(20000000) + imagefsAvailable = uint64(8000000) + imagefsInodesFree = uint64(2000) + ) prf0 := kubestats.PodReference{Name: pName0, Namespace: namespace0, UID: "UID" + pName0} prf1 := kubestats.PodReference{Name: pName1, Namespace: namespace0, UID: "UID" + pName1} @@ -110,8 +118,16 @@ func TestBuildSummary(t *testing.T) { "/pod2-c0": summaryTestContainerInfo(seedPod2Container, pName2, namespace2, cName20), } - rootfs := v2.FsInfo{} - imagefs := v2.FsInfo{} + rootfs := v2.FsInfo{ + Capacity: rootfsCapacity, + Available: rootfsAvailable, + InodesFree: rootfsInodesFree, + } + imagefs := v2.FsInfo{ + Capacity: imagefsCapacity, + Available: imagefsAvailable, + InodesFree: imagefsInodesFree, + } // memory limit overrides for each container (used to test available bytes if a memory limit is known) memoryLimitOverrides := map[string]uint64{ @@ -159,6 +175,8 @@ func TestBuildSummary(t *testing.T) { assert.EqualValues(t, testTime(creationTime, seed).Unix(), sys.StartTime.Time.Unix(), name+".StartTime") checkCPUStats(t, name, seed, sys.CPU) checkMemoryStats(t, name, seed, info, sys.Memory) + checkFsStats(t, rootfsCapacity, rootfsAvailable, rootfsInodesFree, sys.Logs) + checkFsStats(t, imagefsCapacity, imagefsAvailable, imagefsInodesFree, sys.Rootfs) } assert.Equal(t, 3, len(summary.Pods)) @@ -350,6 +368,12 @@ func checkMemoryStats(t *testing.T, label string, seed int, info v2.ContainerInf } } +func checkFsStats(t *testing.T, capacity uint64, Available uint64, inodesFree uint64, fs *kubestats.FsStats) { + assert.EqualValues(t, capacity, *fs.CapacityBytes) + assert.EqualValues(t, Available, *fs.AvailableBytes) + assert.EqualValues(t, inodesFree, *fs.InodesFree) +} + func TestCustomMetrics(t *testing.T) { spec := []v1.MetricSpec{ {