mirror of
https://github.com/siderolabs/talos.git
synced 2025-12-12 21:11:31 +01:00
The new command `talosctl cgroups` fetches cgroups snapshot from the machine, parses it fully, enhances with additional information (e.g. resolves pod names), and presents a customizable view of cgroups configuration (e.g. limits) and current consumption. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
33 lines
822 B
Go
33 lines
822 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package cgroups_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/siderolabs/talos/internal/pkg/cgroups"
|
|
)
|
|
|
|
func TestTreeFromTarGz(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tarFile, err := os.Open("testdata/cgroup.tar.gz")
|
|
require.NoError(t, err)
|
|
|
|
t.Cleanup(func() {
|
|
assert.NoError(t, tarFile.Close())
|
|
})
|
|
|
|
tree, err := cgroups.TreeFromTarGz(tarFile)
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, []string{"init", "kubepods", "podruntime", "system"}, tree.Root.SortedChildren())
|
|
assert.Equal(t, "114712576", tree.Find("init").MemoryCurrent.String())
|
|
}
|