mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #30231 from derekwaynecarr/inodes-summary-api
Automatic merge from submit-queue Add total inodes to kubelet summary api Needed to support inode based eviction thresholds as a percentage. /cc @ronnielai @vishh @kubernetes/rh-cluster-infra
This commit is contained in:
commit
fbcb946db9
@ -175,6 +175,8 @@ type FsStats struct {
|
|||||||
UsedBytes *uint64 `json:"usedBytes,omitempty"`
|
UsedBytes *uint64 `json:"usedBytes,omitempty"`
|
||||||
// InodesFree represents the free inodes in the filesystem.
|
// InodesFree represents the free inodes in the filesystem.
|
||||||
InodesFree *uint64 `json:"inodesFree,omitempty"`
|
InodesFree *uint64 `json:"inodesFree,omitempty"`
|
||||||
|
// Inodes represents the total inodes in the filesystem.
|
||||||
|
Inodes *uint64 `json:"inodes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserDefinedMetricType defines how the metric should be interpreted by the user.
|
// UserDefinedMetricType defines how the metric should be interpreted by the user.
|
||||||
|
@ -125,7 +125,8 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) {
|
|||||||
AvailableBytes: &sb.rootFsInfo.Available,
|
AvailableBytes: &sb.rootFsInfo.Available,
|
||||||
CapacityBytes: &sb.rootFsInfo.Capacity,
|
CapacityBytes: &sb.rootFsInfo.Capacity,
|
||||||
UsedBytes: &sb.rootFsInfo.Usage,
|
UsedBytes: &sb.rootFsInfo.Usage,
|
||||||
InodesFree: sb.rootFsInfo.InodesFree},
|
InodesFree: sb.rootFsInfo.InodesFree,
|
||||||
|
Inodes: sb.rootFsInfo.Inodes},
|
||||||
StartTime: rootStats.StartTime,
|
StartTime: rootStats.StartTime,
|
||||||
Runtime: &stats.RuntimeStats{
|
Runtime: &stats.RuntimeStats{
|
||||||
ImageFs: &stats.FsStats{
|
ImageFs: &stats.FsStats{
|
||||||
@ -133,6 +134,7 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) {
|
|||||||
CapacityBytes: &sb.imageFsInfo.Capacity,
|
CapacityBytes: &sb.imageFsInfo.Capacity,
|
||||||
UsedBytes: &sb.imageStats.TotalStorageBytes,
|
UsedBytes: &sb.imageStats.TotalStorageBytes,
|
||||||
InodesFree: sb.imageFsInfo.InodesFree,
|
InodesFree: sb.imageFsInfo.InodesFree,
|
||||||
|
Inodes: sb.rootFsInfo.Inodes,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -165,6 +167,7 @@ func (sb *summaryBuilder) containerInfoV2FsStats(
|
|||||||
AvailableBytes: &sb.rootFsInfo.Available,
|
AvailableBytes: &sb.rootFsInfo.Available,
|
||||||
CapacityBytes: &sb.rootFsInfo.Capacity,
|
CapacityBytes: &sb.rootFsInfo.Capacity,
|
||||||
InodesFree: sb.rootFsInfo.InodesFree,
|
InodesFree: sb.rootFsInfo.InodesFree,
|
||||||
|
Inodes: sb.rootFsInfo.Inodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
@ -172,6 +175,7 @@ func (sb *summaryBuilder) containerInfoV2FsStats(
|
|||||||
AvailableBytes: &sb.imageFsInfo.Available,
|
AvailableBytes: &sb.imageFsInfo.Available,
|
||||||
CapacityBytes: &sb.imageFsInfo.Capacity,
|
CapacityBytes: &sb.imageFsInfo.Capacity,
|
||||||
InodesFree: sb.imageFsInfo.InodesFree,
|
InodesFree: sb.imageFsInfo.InodesFree,
|
||||||
|
Inodes: sb.imageFsInfo.Inodes,
|
||||||
}
|
}
|
||||||
lcs, found := sb.latestContainerStats(info)
|
lcs, found := sb.latestContainerStats(info)
|
||||||
if !found {
|
if !found {
|
||||||
|
@ -93,9 +93,11 @@ func TestBuildSummary(t *testing.T) {
|
|||||||
rootfsCapacity = uint64(10000000)
|
rootfsCapacity = uint64(10000000)
|
||||||
rootfsAvailable = uint64(5000000)
|
rootfsAvailable = uint64(5000000)
|
||||||
rootfsInodesFree = uint64(1000)
|
rootfsInodesFree = uint64(1000)
|
||||||
|
rootfsInodes = uint64(2000)
|
||||||
imagefsCapacity = uint64(20000000)
|
imagefsCapacity = uint64(20000000)
|
||||||
imagefsAvailable = uint64(8000000)
|
imagefsAvailable = uint64(8000000)
|
||||||
imagefsInodesFree = uint64(2000)
|
imagefsInodesFree = uint64(2000)
|
||||||
|
imagefsInodes = uint64(4000)
|
||||||
)
|
)
|
||||||
|
|
||||||
prf0 := kubestats.PodReference{Name: pName0, Namespace: namespace0, UID: "UID" + pName0}
|
prf0 := kubestats.PodReference{Name: pName0, Namespace: namespace0, UID: "UID" + pName0}
|
||||||
@ -119,16 +121,20 @@ func TestBuildSummary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
freeRootfsInodes := rootfsInodesFree
|
freeRootfsInodes := rootfsInodesFree
|
||||||
|
totalRootfsInodes := rootfsInodes
|
||||||
rootfs := v2.FsInfo{
|
rootfs := v2.FsInfo{
|
||||||
Capacity: rootfsCapacity,
|
Capacity: rootfsCapacity,
|
||||||
Available: rootfsAvailable,
|
Available: rootfsAvailable,
|
||||||
InodesFree: &freeRootfsInodes,
|
InodesFree: &freeRootfsInodes,
|
||||||
|
Inodes: &totalRootfsInodes,
|
||||||
}
|
}
|
||||||
freeImagefsInodes := imagefsInodesFree
|
freeImagefsInodes := imagefsInodesFree
|
||||||
|
totalImagefsInodes := imagefsInodes
|
||||||
imagefs := v2.FsInfo{
|
imagefs := v2.FsInfo{
|
||||||
Capacity: imagefsCapacity,
|
Capacity: imagefsCapacity,
|
||||||
Available: imagefsAvailable,
|
Available: imagefsAvailable,
|
||||||
InodesFree: &freeImagefsInodes,
|
InodesFree: &freeImagefsInodes,
|
||||||
|
Inodes: &totalImagefsInodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
||||||
@ -177,8 +183,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, rootfsCapacity, rootfsAvailable, totalRootfsInodes, rootfsInodesFree, sys.Logs)
|
||||||
checkFsStats(t, imagefsCapacity, imagefsAvailable, imagefsInodesFree, sys.Rootfs)
|
checkFsStats(t, imagefsCapacity, imagefsAvailable, totalImagefsInodes, imagefsInodesFree, sys.Rootfs)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, 3, len(summary.Pods))
|
assert.Equal(t, 3, len(summary.Pods))
|
||||||
@ -370,10 +376,11 @@ 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) {
|
func checkFsStats(t *testing.T, capacity uint64, Available uint64, inodes uint64, inodesFree uint64, fs *kubestats.FsStats) {
|
||||||
assert.EqualValues(t, capacity, *fs.CapacityBytes)
|
assert.EqualValues(t, capacity, *fs.CapacityBytes)
|
||||||
assert.EqualValues(t, Available, *fs.AvailableBytes)
|
assert.EqualValues(t, Available, *fs.AvailableBytes)
|
||||||
assert.EqualValues(t, inodesFree, *fs.InodesFree)
|
assert.EqualValues(t, inodesFree, *fs.InodesFree)
|
||||||
|
assert.EqualValues(t, inodes, *fs.Inodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCustomMetrics(t *testing.T) {
|
func TestCustomMetrics(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user