mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Include inode info in container summary
This commit is contained in:
parent
4726b521d1
commit
2c71ce305a
@ -164,12 +164,14 @@ func (sb *summaryBuilder) containerInfoV2FsStats(
|
|||||||
cs.Logs = &stats.FsStats{
|
cs.Logs = &stats.FsStats{
|
||||||
AvailableBytes: &sb.rootFsInfo.Available,
|
AvailableBytes: &sb.rootFsInfo.Available,
|
||||||
CapacityBytes: &sb.rootFsInfo.Capacity,
|
CapacityBytes: &sb.rootFsInfo.Capacity,
|
||||||
|
InodesFree: &sb.rootFsInfo.InodesFree,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The container rootFs lives on the imageFs devices (which may not be the node root fs)
|
// The container rootFs lives on the imageFs devices (which may not be the node root fs)
|
||||||
cs.Rootfs = &stats.FsStats{
|
cs.Rootfs = &stats.FsStats{
|
||||||
AvailableBytes: &sb.imageFsInfo.Available,
|
AvailableBytes: &sb.imageFsInfo.Available,
|
||||||
CapacityBytes: &sb.imageFsInfo.Capacity,
|
CapacityBytes: &sb.imageFsInfo.Capacity,
|
||||||
|
InodesFree: &sb.imageFsInfo.InodesFree,
|
||||||
}
|
}
|
||||||
lcs, found := sb.latestContainerStats(info)
|
lcs, found := sb.latestContainerStats(info)
|
||||||
if !found {
|
if !found {
|
||||||
|
@ -89,6 +89,14 @@ func TestBuildSummary(t *testing.T) {
|
|||||||
cName10 = "c0" // ensure cName10 conflicts with cName02, but is in a different pod
|
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
|
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}
|
prf0 := kubestats.PodReference{Name: pName0, Namespace: namespace0, UID: "UID" + pName0}
|
||||||
prf1 := kubestats.PodReference{Name: pName1, Namespace: namespace0, UID: "UID" + pName1}
|
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),
|
"/pod2-c0": summaryTestContainerInfo(seedPod2Container, pName2, namespace2, cName20),
|
||||||
}
|
}
|
||||||
|
|
||||||
rootfs := v2.FsInfo{}
|
rootfs := v2.FsInfo{
|
||||||
imagefs := 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)
|
// memory limit overrides for each container (used to test available bytes if a memory limit is known)
|
||||||
memoryLimitOverrides := map[string]uint64{
|
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")
|
assert.EqualValues(t, testTime(creationTime, seed).Unix(), sys.StartTime.Time.Unix(), name+".StartTime")
|
||||||
checkCPUStats(t, name, seed, sys.CPU)
|
checkCPUStats(t, name, seed, sys.CPU)
|
||||||
checkMemoryStats(t, name, seed, info, sys.Memory)
|
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))
|
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) {
|
func TestCustomMetrics(t *testing.T) {
|
||||||
spec := []v1.MetricSpec{
|
spec := []v1.MetricSpec{
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user