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:
Kubernetes Submit Queue 2016-08-08 12:59:52 -07:00 committed by GitHub
commit fbcb946db9
3 changed files with 17 additions and 4 deletions

View File

@ -175,6 +175,8 @@ type FsStats struct {
UsedBytes *uint64 `json:"usedBytes,omitempty"`
// InodesFree represents the free inodes in the filesystem.
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.

View File

@ -125,7 +125,8 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) {
AvailableBytes: &sb.rootFsInfo.Available,
CapacityBytes: &sb.rootFsInfo.Capacity,
UsedBytes: &sb.rootFsInfo.Usage,
InodesFree: sb.rootFsInfo.InodesFree},
InodesFree: sb.rootFsInfo.InodesFree,
Inodes: sb.rootFsInfo.Inodes},
StartTime: rootStats.StartTime,
Runtime: &stats.RuntimeStats{
ImageFs: &stats.FsStats{
@ -133,6 +134,7 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) {
CapacityBytes: &sb.imageFsInfo.Capacity,
UsedBytes: &sb.imageStats.TotalStorageBytes,
InodesFree: sb.imageFsInfo.InodesFree,
Inodes: sb.rootFsInfo.Inodes,
},
},
}
@ -165,6 +167,7 @@ func (sb *summaryBuilder) containerInfoV2FsStats(
AvailableBytes: &sb.rootFsInfo.Available,
CapacityBytes: &sb.rootFsInfo.Capacity,
InodesFree: sb.rootFsInfo.InodesFree,
Inodes: sb.rootFsInfo.Inodes,
}
// 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,
CapacityBytes: &sb.imageFsInfo.Capacity,
InodesFree: sb.imageFsInfo.InodesFree,
Inodes: sb.imageFsInfo.Inodes,
}
lcs, found := sb.latestContainerStats(info)
if !found {

View File

@ -93,9 +93,11 @@ func TestBuildSummary(t *testing.T) {
rootfsCapacity = uint64(10000000)
rootfsAvailable = uint64(5000000)
rootfsInodesFree = uint64(1000)
rootfsInodes = uint64(2000)
imagefsCapacity = uint64(20000000)
imagefsAvailable = uint64(8000000)
imagefsInodesFree = uint64(2000)
imagefsInodes = uint64(4000)
)
prf0 := kubestats.PodReference{Name: pName0, Namespace: namespace0, UID: "UID" + pName0}
@ -119,16 +121,20 @@ func TestBuildSummary(t *testing.T) {
}
freeRootfsInodes := rootfsInodesFree
totalRootfsInodes := rootfsInodes
rootfs := v2.FsInfo{
Capacity: rootfsCapacity,
Available: rootfsAvailable,
InodesFree: &freeRootfsInodes,
Inodes: &totalRootfsInodes,
}
freeImagefsInodes := imagefsInodesFree
totalImagefsInodes := imagefsInodes
imagefs := v2.FsInfo{
Capacity: imagefsCapacity,
Available: imagefsAvailable,
InodesFree: &freeImagefsInodes,
Inodes: &totalImagefsInodes,
}
// 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")
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)
checkFsStats(t, rootfsCapacity, rootfsAvailable, totalRootfsInodes, rootfsInodesFree, sys.Logs)
checkFsStats(t, imagefsCapacity, imagefsAvailable, totalImagefsInodes, imagefsInodesFree, sys.Rootfs)
}
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, Available, *fs.AvailableBytes)
assert.EqualValues(t, inodesFree, *fs.InodesFree)
assert.EqualValues(t, inodes, *fs.Inodes)
}
func TestCustomMetrics(t *testing.T) {