mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
e2e: change memory fields to use unit64
This commit is contained in:
parent
715ea4c8b1
commit
082da18e8a
@ -197,8 +197,8 @@ type containerResourceUsage struct {
|
|||||||
Name string
|
Name string
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
CPUUsageInCores float64
|
CPUUsageInCores float64
|
||||||
MemoryUsageInBytes int64
|
MemoryUsageInBytes uint64
|
||||||
MemoryWorkingSetInBytes int64
|
MemoryWorkingSetInBytes uint64
|
||||||
MemoryRSSInBytes uint64
|
MemoryRSSInBytes uint64
|
||||||
// The interval used to calculate CPUUsageInCores.
|
// The interval used to calculate CPUUsageInCores.
|
||||||
CPUInterval time.Duration
|
CPUInterval time.Duration
|
||||||
@ -303,16 +303,16 @@ func formatResourceUsageStats(nodeName string, containerStats resourceUsagePerCo
|
|||||||
return fmt.Sprintf("Resource usage on node %q:\n%s", nodeName, buf.String())
|
return fmt.Sprintf("Resource usage on node %q:\n%s", nodeName, buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
type int64arr []int64
|
type uint64arr []uint64
|
||||||
|
|
||||||
func (a int64arr) Len() int { return len(a) }
|
func (a uint64arr) Len() int { return len(a) }
|
||||||
func (a int64arr) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
func (a uint64arr) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||||
func (a int64arr) Less(i, j int) bool { return a[i] < a[j] }
|
func (a uint64arr) Less(i, j int) bool { return a[i] < a[j] }
|
||||||
|
|
||||||
type usageDataPerContainer struct {
|
type usageDataPerContainer struct {
|
||||||
cpuData []float64
|
cpuData []float64
|
||||||
memUseData []int64
|
memUseData []uint64
|
||||||
memWorkSetData []int64
|
memWorkSetData []uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performs a get on a node proxy endpoint given the nodename and rest client.
|
// Performs a get on a node proxy endpoint given the nodename and rest client.
|
||||||
@ -365,8 +365,8 @@ func computeContainerResourceUsage(name string, oldStats, newStats *cadvisorapi.
|
|||||||
Name: name,
|
Name: name,
|
||||||
Timestamp: newStats.Timestamp,
|
Timestamp: newStats.Timestamp,
|
||||||
CPUUsageInCores: float64(newStats.Cpu.Usage.Total-oldStats.Cpu.Usage.Total) / float64(newStats.Timestamp.Sub(oldStats.Timestamp).Nanoseconds()),
|
CPUUsageInCores: float64(newStats.Cpu.Usage.Total-oldStats.Cpu.Usage.Total) / float64(newStats.Timestamp.Sub(oldStats.Timestamp).Nanoseconds()),
|
||||||
MemoryUsageInBytes: int64(newStats.Memory.Usage),
|
MemoryUsageInBytes: newStats.Memory.Usage,
|
||||||
MemoryWorkingSetInBytes: int64(newStats.Memory.WorkingSet),
|
MemoryWorkingSetInBytes: newStats.Memory.WorkingSet,
|
||||||
MemoryRSSInBytes: newStats.Memory.RSS,
|
MemoryRSSInBytes: newStats.Memory.RSS,
|
||||||
CPUInterval: newStats.Timestamp.Sub(oldStats.Timestamp),
|
CPUInterval: newStats.Timestamp.Sub(oldStats.Timestamp),
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ const (
|
|||||||
|
|
||||||
type resourceConstraint struct {
|
type resourceConstraint struct {
|
||||||
cpuConstraint float64
|
cpuConstraint float64
|
||||||
memoryConstraint int64
|
memoryConstraint uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type containerResourceGatherer struct {
|
type containerResourceGatherer struct {
|
||||||
@ -51,7 +51,7 @@ type containerResourceGatherer struct {
|
|||||||
type SingleContainerSummary struct {
|
type SingleContainerSummary struct {
|
||||||
Name string
|
Name string
|
||||||
Cpu float64
|
Cpu float64
|
||||||
Mem int64
|
Mem uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can't have int here, as JSON does not accept integer keys.
|
// we can't have int here, as JSON does not accept integer keys.
|
||||||
@ -165,8 +165,8 @@ func (g *containerResourceGatherer) computePercentiles(timeSeries map[time.Time]
|
|||||||
if dataMap[name] == nil {
|
if dataMap[name] == nil {
|
||||||
dataMap[name] = &usageDataPerContainer{
|
dataMap[name] = &usageDataPerContainer{
|
||||||
cpuData: make([]float64, len(timeSeries)),
|
cpuData: make([]float64, len(timeSeries)),
|
||||||
memUseData: make([]int64, len(timeSeries)),
|
memUseData: make([]uint64, len(timeSeries)),
|
||||||
memWorkSetData: make([]int64, len(timeSeries)),
|
memWorkSetData: make([]uint64, len(timeSeries)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dataMap[name].cpuData = append(dataMap[name].cpuData, data.CPUUsageInCores)
|
dataMap[name].cpuData = append(dataMap[name].cpuData, data.CPUUsageInCores)
|
||||||
@ -176,8 +176,8 @@ func (g *containerResourceGatherer) computePercentiles(timeSeries map[time.Time]
|
|||||||
}
|
}
|
||||||
for _, v := range dataMap {
|
for _, v := range dataMap {
|
||||||
sort.Float64s(v.cpuData)
|
sort.Float64s(v.cpuData)
|
||||||
sort.Sort(int64arr(v.memUseData))
|
sort.Sort(uint64arr(v.memUseData))
|
||||||
sort.Sort(int64arr(v.memWorkSetData))
|
sort.Sort(uint64arr(v.memWorkSetData))
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[int]resourceUsagePerContainer)
|
result := make(map[int]resourceUsagePerContainer)
|
||||||
|
Loading…
Reference in New Issue
Block a user