drivers/exec: Account for cgroup-v2 memory stats
If the host is running with cgroup-v2, RSS and Max Usage doesn't get reported anymore.
This commit is contained in:
parent
466b620fa4
commit
edec658e50
|
@ -39,8 +39,11 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
// ExecutorCgroupMeasuredMemStats is the list of memory stats captured by the executor
|
||||
ExecutorCgroupMeasuredMemStats = []string{"RSS", "Cache", "Swap", "Usage", "Max Usage", "Kernel Usage", "Kernel Max Usage"}
|
||||
// ExecutorCgroupV1MeasuredMemStats is the list of memory stats captured by the executor with cgroup-v1
|
||||
ExecutorCgroupV1MeasuredMemStats = []string{"RSS", "Cache", "Swap", "Usage", "Max Usage", "Kernel Usage", "Kernel Max Usage"}
|
||||
|
||||
// ExecutorCgroupV2MeasuredMemStats is the list of memory stats captured by the executor with cgroup-v2. cgroup-v2 exposes different memory stats and no longer reports rss or max usage.
|
||||
ExecutorCgroupV2MeasuredMemStats = []string{"Cache", "Swap", "Usage"}
|
||||
|
||||
// ExecutorCgroupMeasuredCpuStats is the list of CPU stats captures by the executor
|
||||
ExecutorCgroupMeasuredCpuStats = []string{"System Mode", "User Mode", "Throttled Periods", "Throttled Time", "Percent"}
|
||||
|
@ -342,6 +345,12 @@ func (l *LibcontainerExecutor) Stats(ctx context.Context, interval time.Duration
|
|||
func (l *LibcontainerExecutor) handleStats(ch chan *cstructs.TaskResourceUsage, ctx context.Context, interval time.Duration) {
|
||||
defer close(ch)
|
||||
timer := time.NewTimer(0)
|
||||
|
||||
measuredMemStats := ExecutorCgroupV1MeasuredMemStats
|
||||
if cgroups.IsCgroup2UnifiedMode() {
|
||||
measuredMemStats = ExecutorCgroupV2MeasuredMemStats
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
@ -379,7 +388,7 @@ func (l *LibcontainerExecutor) handleStats(ch chan *cstructs.TaskResourceUsage,
|
|||
MaxUsage: maxUsage,
|
||||
KernelUsage: stats.MemoryStats.KernelUsage.Usage,
|
||||
KernelMaxUsage: stats.MemoryStats.KernelUsage.MaxUsage,
|
||||
Measured: ExecutorCgroupMeasuredMemStats,
|
||||
Measured: measuredMemStats,
|
||||
}
|
||||
|
||||
// CPU Related Stats
|
||||
|
|
Loading…
Reference in New Issue