Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tmo fix #688

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ require (
)

replace (
github.com/kubewharf/katalyst-api => github.com/yadzhang/katalyst-api v0.0.0-20240902073003-a72eb9ae209c
k8s.io/api => k8s.io/api v0.24.6
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.6
k8s.io/apimachinery => k8s.io/apimachinery v0.24.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubewharf/katalyst-api v0.5.1-0.20240702044746-be552fd7ea7d h1:6CuK3axf2B63zIkEu5XyxbaC+JArE/3Jo3QHvb+Hn0M=
github.com/kubewharf/katalyst-api v0.5.1-0.20240702044746-be552fd7ea7d/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k=
github.com/kubewharf/kubelet v1.24.6-kubewharf.9 h1:jOTYZt7h/J7I8xQMKMUcJjKf5UFBv37jHWvNp5VRFGc=
github.com/kubewharf/kubelet v1.24.6-kubewharf.9/go.mod h1:MxbSZUx3wXztFneeelwWWlX7NAAStJ6expqq7gY2J3c=
github.com/kyoh86/exportloopref v0.1.7/go.mod h1:h1rDl2Kdj97+Kwh4gdz3ujE7XHmH51Q0lUiZ1z4NLj8=
Expand Down Expand Up @@ -913,6 +911,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yadzhang/katalyst-api v0.0.0-20240902073003-a72eb9ae209c h1:AaS5COARc7Hl1Flu209pTushx87DWTHLM4rY15gCCEc=
github.com/yadzhang/katalyst-api v0.0.0-20240902073003-a72eb9ae209c/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
261 changes: 249 additions & 12 deletions pkg/agent/sysadvisor/plugin/qosaware/resource/memory/advisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,11 @@ func TestUpdate(t *testing.T) {
0: machine.MustParse("1"),
1: machine.MustParse("25"),
}, 200<<30),
makeContainerInfo("uid4", "default", "pod4", "c4", consts.PodAnnotationQoSLevelReclaimedCores, nil,
map[int]machine.CPUSet{
0: machine.MustParse("1"),
1: machine.MustParse("25"),
}, 200<<30),
},
pods: []*v1.Pod{
{
Expand Down Expand Up @@ -874,6 +879,62 @@ func TestUpdate(t *testing.T) {
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod3",
Namespace: "default",
UID: "uid3",
Annotations: map[string]string{
consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores,
},
Labels: map[string]string{
consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelSharedCores,
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "c3",
},
},
},
Status: v1.PodStatus{
ContainerStatuses: []v1.ContainerStatus{
{
Name: "c3",
ContainerID: "containerd://c3",
},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod4",
Namespace: "default",
UID: "uid4",
Annotations: map[string]string{
consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelReclaimedCores,
},
Labels: map[string]string{
consts.PodAnnotationQoSLevelKey: consts.PodAnnotationQoSLevelReclaimedCores,
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "c4",
},
},
},
Status: v1.PodStatus{
ContainerStatuses: []v1.ContainerStatus{
{
Name: "c4",
ContainerID: "containerd://c4",
},
},
},
},
},
wantHeadroom: *resource.NewQuantity(996<<30, resource.DecimalSI),
nodeMetrics: defaultNodeMetrics,
Expand All @@ -891,6 +952,18 @@ func TestUpdate(t *testing.T) {
podUID: "uid1",
containerName: "c1",
},
{
metricName: coreconsts.MetricMemCacheContainer,
metricValue: metricutil.MetricData{Value: 5 << 30},
podUID: "uid1",
containerName: "c1",
},
{
metricName: coreconsts.MetricMemMappedContainer,
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid1",
containerName: "c1",
},
{
metricName: coreconsts.MetricMemInactiveAnonContainer,
metricValue: metricutil.MetricData{Value: 1 << 30},
Expand Down Expand Up @@ -939,9 +1012,21 @@ func TestUpdate(t *testing.T) {
podUID: "uid2",
containerName: "c2",
},
{
metricName: coreconsts.MetricMemCacheContainer,
metricValue: metricutil.MetricData{Value: 3 << 30},
podUID: "uid2",
containerName: "c2",
},
{
metricName: coreconsts.MetricMemMappedContainer,
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid2",
containerName: "c2",
},
{
metricName: coreconsts.MetricMemInactiveAnonContainer,
metricValue: metricutil.MetricData{Value: 1 << 30},
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid2",
containerName: "c2",
},
Expand Down Expand Up @@ -975,6 +1060,126 @@ func TestUpdate(t *testing.T) {
podUID: "uid2",
containerName: "c2",
},
{
metricName: coreconsts.MetricMemPsiAvg60Container,
metricValue: metricutil.MetricData{Value: 0.01},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemUsageContainer,
metricValue: metricutil.MetricData{Value: 10 << 30},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemCacheContainer,
metricValue: metricutil.MetricData{Value: 3 << 30},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemMappedContainer,
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemInactiveAnonContainer,
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemInactiveFileContainer,
metricValue: metricutil.MetricData{Value: 1 << 30},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemPgscanContainer,
metricValue: metricutil.MetricData{Value: 15000},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemPgstealContainer,
metricValue: metricutil.MetricData{Value: 10000},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemWorkingsetRefaultContainer,
metricValue: metricutil.MetricData{Value: 1000},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemWorkingsetActivateContainer,
metricValue: metricutil.MetricData{Value: 1000},
podUID: "uid3",
containerName: "c3",
},
{
metricName: coreconsts.MetricMemPsiAvg60Container,
metricValue: metricutil.MetricData{Value: 0.01},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemUsageContainer,
metricValue: metricutil.MetricData{Value: 10 << 30},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemCacheContainer,
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemMappedContainer,
metricValue: metricutil.MetricData{Value: 2 << 30},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemInactiveAnonContainer,
metricValue: metricutil.MetricData{Value: 1 << 30},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemInactiveFileContainer,
metricValue: metricutil.MetricData{Value: 1 << 30},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemPgscanContainer,
metricValue: metricutil.MetricData{Value: 15000},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemPgstealContainer,
metricValue: metricutil.MetricData{Value: 10000},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemWorkingsetRefaultContainer,
metricValue: metricutil.MetricData{Value: 1000},
podUID: "uid4",
containerName: "c4",
},
{
metricName: coreconsts.MetricMemWorkingsetActivateContainer,
metricValue: metricutil.MetricData{Value: 1000},
podUID: "uid4",
containerName: "c4",
},
},
cgroupMetrics: []cgroupMetric{
{
Expand Down Expand Up @@ -1007,6 +1212,16 @@ func TestUpdate(t *testing.T) {
metricValue: metricutil.MetricData{Value: 4 << 30},
cgroupPath: "/hdfs",
},
{
metricName: coreconsts.MetricMemCacheCgroup,
metricValue: metricutil.MetricData{Value: 3 << 30},
cgroupPath: "/hdfs",
},
{
metricName: coreconsts.MetricMemMappedCgroup,
metricValue: metricutil.MetricData{Value: 1 << 30},
cgroupPath: "/hdfs",
},
{
metricName: coreconsts.MetricMemInactiveAnonCgroup,
metricValue: metricutil.MetricData{Value: 1 << 30},
Expand All @@ -1024,19 +1239,37 @@ func TestUpdate(t *testing.T) {
{
CgroupPath: "/hdfs",
Values: map[string]string{
string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobON,
string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobOFF,
string(memoryadvisor.ControlKnowKeyMemoryOffloading): "38654705",
},
},
},
ContainerEntries: []types.ContainerMemoryAdvices{{
PodUID: "uid1",
ContainerName: "c1",
Values: map[string]string{
string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobON,
string(memoryadvisor.ControlKnowKeyMemoryOffloading): "96636764",
ContainerEntries: []types.ContainerMemoryAdvices{
{
PodUID: "uid1",
ContainerName: "c1",
Values: map[string]string{
string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobOFF,
string(memoryadvisor.ControlKnowKeyMemoryOffloading): "96636764",
},
},
}},
{
PodUID: "uid3",
ContainerName: "c3",
Values: map[string]string{
string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobON,
string(memoryadvisor.ControlKnowKeyMemoryOffloading): "96636764",
},
},
//{
// PodUID: "uid4",
// ContainerName: "c4",
// Values: map[string]string{
// string(memoryadvisor.ControlKnobKeySwapMax): coreconsts.ControlKnobOFF,
// string(memoryadvisor.ControlKnowKeyMemoryOffloading): "96636764",
// },
//},
},
},
},
{
Expand Down Expand Up @@ -2226,12 +2459,16 @@ func TestUpdate(t *testing.T) {
transparentMemoryOffloadingConfiguration := tmo.NewTransparentMemoryOffloadingConfiguration()
transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelReclaimedCores] = tmo.NewTMOConfigDetail(transparentMemoryOffloadingConfiguration.DefaultConfigurations)
transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelReclaimedCores].EnableTMO = true
transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelReclaimedCores].EnableSwap = true
transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelReclaimedCores].EnableSwap = false

transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelSharedCores] = tmo.NewTMOConfigDetail(transparentMemoryOffloadingConfiguration.DefaultConfigurations)
transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelSharedCores].EnableTMO = true
transparentMemoryOffloadingConfiguration.QoSLevelConfigs[consts.QoSLevelSharedCores].EnableSwap = true

// cgroup level
transparentMemoryOffloadingConfiguration.CgroupConfigs["/sys/fs/cgroup/hdfs"] = tmo.NewTMOConfigDetail(transparentMemoryOffloadingConfiguration.DefaultConfigurations)
transparentMemoryOffloadingConfiguration.CgroupConfigs["/sys/fs/cgroup/hdfs"].EnableTMO = true
transparentMemoryOffloadingConfiguration.CgroupConfigs["/sys/fs/cgroup/hdfs"].EnableSwap = true
transparentMemoryOffloadingConfiguration.CgroupConfigs["/sys/fs/cgroup/hdfs"].EnableSwap = false

advisor.conf.GetDynamicConfiguration().TransparentMemoryOffloadingConfiguration = transparentMemoryOffloadingConfiguration
_, advisorRecvChInterface := advisor.GetChannels()
Expand All @@ -2256,7 +2493,7 @@ func TestUpdate(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
advisor.Run(ctx)

time.Sleep(10 * time.Millisecond) // Wait some time because no signal will be sent to channel
time.Sleep(100 * time.Millisecond) // Wait some time because no signal will be sent to channel
if tt.needRecvAdvices {
result := <-recvCh

Expand Down
Loading