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

koordlet: cgroup file read and write is privatized and consolidated into the resource executor package. #1024

Merged
merged 8 commits into from
Mar 7, 2023

Conversation

Re-Grh
Copy link
Contributor

@Re-Grh Re-Grh commented Feb 20, 2023

Ⅰ. Describe what this PR does

Ⅱ. Does this pull request fix one issue?

fix #1017

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

V. Checklist

  • I have written necessary docs and comments
  • I have added necessary unit tests and integration tests
  • All checks passed in make test

@codecov
Copy link

codecov bot commented Feb 21, 2023

Codecov Report

Patch coverage: 61.09% and project coverage change: +0.03 🎉

Comparison is base (a40f96f) 67.41% compared to head (81bcd0a) 67.44%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1024      +/-   ##
==========================================
+ Coverage   67.41%   67.44%   +0.03%     
==========================================
  Files         260      260              
  Lines       28752    28662      -90     
==========================================
- Hits        19382    19330      -52     
+ Misses       8018     7982      -36     
+ Partials     1352     1350       -2     
Flag Coverage Δ
unittests 67.44% <61.09%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/koordlet/resmanager/cpu_burst.go 73.07% <0.00%> (ø)
pkg/koordlet/runtimehooks/hooks/gpu/gpu.go 65.62% <0.00%> (ø)
...oordlet/runtimehooks/protocol/container_context.go 5.36% <0.00%> (-0.12%) ⬇️
.../koordlet/runtimehooks/protocol/kubeqos_context.go 0.00% <0.00%> (ø)
pkg/koordlet/runtimehooks/protocol/pod_context.go 6.95% <0.00%> (-0.39%) ⬇️
pkg/koordlet/runtimehooks/protocol/protocol.go 3.57% <0.00%> (-0.36%) ⬇️
pkg/koordlet/util/meminfo.go 92.68% <ø> (+10.54%) ⬆️
pkg/koordlet/util/stat.go 53.42% <ø> (-4.27%) ⬇️
pkg/koordlet/util/system/cgroup.go 10.98% <ø> (-20.90%) ⬇️
pkg/koordlet/util/system/util_test_tool.go 50.00% <26.92%> (-8.91%) ⬇️
... and 28 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

pkg/koordlet/resmanager/cgroup_reconcile_test.go Outdated Show resolved Hide resolved
pkg/koordlet/resmanager/cgroup_reconcile_test.go Outdated Show resolved Hide resolved
pkg/koordlet/resmanager/cgroup_reconcile_test.go Outdated Show resolved Hide resolved
pkg/koordlet/resourceexecutor/cgroup.go Outdated Show resolved Hide resolved
pkg/koordlet/resourceexecutor/psi.go Outdated Show resolved Hide resolved
pkg/koordlet/runtimehooks/hooks/groupidentity/rule.go Outdated Show resolved Hide resolved
pkg/koordlet/resmanager/cgroup_reconcile_test.go Outdated Show resolved Hide resolved
pkg/koordlet/resourceexecutor/cgroup.go Outdated Show resolved Hide resolved
pkg/koordlet/runtimehooks/hooks/groupidentity/rule.go Outdated Show resolved Hide resolved
pkg/koordlet/runtimehooks/hooks/groupidentity/rule.go Outdated Show resolved Hide resolved
// parsePSIStats parses the specified file for pressure stall information.
func parsePSIStats(r io.Reader) (PSIStats, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other files and struct can also be moved into resourceexecutor

}
return CgroupFileWrite(cgroupTaskDir, r, value)
}

func IsCgroupPathExist(parentDir string, r Resource) (bool, string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mv to resourceexecutor

@@ -193,16 +193,6 @@ func GetContainerCurMemLimitBytes(podParentDir string, c *corev1.ContainerStatus
return strconv.ParseInt(strings.TrimSpace(string(rawContent)), 10, 64)
}

// GetContainerCurTasks gets the TIDs of the given container's cgroup.
// DEPRECATED: use resourceexecutor.CgroupReader instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check other deprecated func

@@ -191,8 +191,10 @@ func (c *ContainerContext) injectForOrigin() {
klog.V(5).Infof("set container %v/%v/%v cpuset %v on cgroup parent %v",
c.Request.PodMeta.Namespace, c.Request.PodMeta.Name, c.Request.ContainerMeta.Name,
*c.Response.Resources.CPUSet, c.Request.CgroupParent)
audit.V(2).Container(c.Request.ContainerMeta.ID).Reason("runtime-hooks").Message(
"set container cpuset to %v", *c.Response.Resources.CPUSet).Do()
if updated {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

independent pr

@Re-Grh Re-Grh force-pushed the cgrouprw branch 3 times, most recently from d2e9566 to d15b39b Compare March 3, 2023 06:05
if err != nil {
klog.Infof("bvtupdater creat failed, dir %v, error %v", kubeQOSCgroupPath, err)
}
if err := bvtUpdater.Update(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set Update as private, use executor here

@Re-Grh
Copy link
Contributor Author

Re-Grh commented Mar 6, 2023

/hold cancel

Signed-off-by: Re-Grh <1271013391@qq.com>
Signed-off-by: Re-Grh <1271013391@qq.com>
Signed-off-by: Re-Grh <1271013391@qq.com>
Signed-off-by: Re-Grh <1271013391@qq.com>
@@ -101,7 +104,8 @@ func injectMemoryLimit(cgroupParent string, memoryLimit int64) error {
if err != nil {
return err
}
return updater.Update()
_, err = resourceexecutor.NewResourceUpdateExecutor().Update(false, updater)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass resourceexecutor into server

@@ -101,7 +104,8 @@ func injectMemoryLimit(cgroupParent string, memoryLimit int64) error {
if err != nil {
return err
}
return updater.Update()
_, err = resourceexecutor.NewResourceUpdateExecutor().Update(false, updater)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass resourceexecutor into server

Signed-off-by: Re-Grh <1271013391@qq.com>
@@ -204,12 +205,18 @@ type Reconciler interface {
Run(stopCh <-chan struct{}) error
}

func NewReconciler(s statesinformer.StatesInformer) Reconciler {
type Options struct {
S statesinformer.StatesInformer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatesInformer

cpuShareStr := strconv.FormatInt(cpuShares, 10)
updater, err := resourceexecutor.DefaultCgroupUpdaterFactory.New(sysutil.CPUSharesName, cgroupParent, cpuShareStr)
if err != nil {
return err
}
_, err = resourceexecutor.NewResourceUpdateExecutor().Update(false, updater)
_, err = e.Update(false, updater)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

Signed-off-by: Re-Grh <1271013391@qq.com>
Signed-off-by: Re-Grh <1271013391@qq.com>
@zwzhang0107
Copy link
Contributor

/lgtm
/approve

@koordinator-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zwzhang0107

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@koordinator-bot koordinator-bot bot merged commit a2880cf into koordinator-sh:main Mar 7, 2023
@zwzhang0107 zwzhang0107 added this to the v1.2 milestone Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[proposal]Gather cgroup read and write operations in resource executor
3 participants