!15 set the burst value for the pod to enable the container burst

From: @vegbir 
Reviewed-by: @duguhaotian, @Vanient 
Signed-off-by: @duguhaotian
This commit is contained in:
openeuler-ci-bot 2022-11-16 13:51:22 +00:00 committed by Gitee
commit af20583fdb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 76 additions and 3 deletions

View File

@ -1 +1 @@
1.0.0-1
1.0.0-2

View File

@ -1 +1 @@
00439b708862b76e51668b9683f421be5fa2b42d
55da35c3391d84a6f7af898ce39657d5c45709fe

View File

@ -0,0 +1,66 @@
From 1817eb44c25980c5ced63965838fe428c8860540 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Wed, 16 Nov 2022 20:34:20 +0800
Subject: [PATCH] set the burst value for the pod to enable the container burst
---
pkg/quota/quota_burst.go | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/pkg/quota/quota_burst.go b/pkg/quota/quota_burst.go
index 641e514..2d13cec 100644
--- a/pkg/quota/quota_burst.go
+++ b/pkg/quota/quota_burst.go
@@ -27,7 +27,6 @@ import (
"isula.org/rubik/pkg/typedef"
)
-
// SetPodsQuotaBurst sync pod's burst quota when autoconfig is set
func SetPodsQuotaBurst(podInfos map[string]*typedef.PodInfo) {
for _, pi := range podInfos {
@@ -62,6 +61,7 @@ func setPodQuotaBurst(podInfo *typedef.PodInfo) {
if podInfo.QuotaBurst == constant.InvalidBurst {
return
}
+ // 1. Try to write container burst value
burst := big.NewInt(podInfo.QuotaBurst).String()
for _, c := range podInfo.Containers {
err := setCtrQuotaBurst([]byte(burst), c)
@@ -69,20 +69,27 @@ func setPodQuotaBurst(podInfo *typedef.PodInfo) {
log.Errorf("set container quota burst failed: %v", err)
}
}
+ // 2. Try to write pod burst value
+ const subsys = "cpu"
+ podPath := filepath.Join(podInfo.CgroupRoot, subsys, podInfo.CgroupPath)
+ podBurst := big.NewInt(int64(len(podInfo.Containers)) * podInfo.QuotaBurst).String()
+ setQuotaBurst([]byte(podBurst), podPath)
}
func setCtrQuotaBurst(burst []byte, c *typedef.ContainerInfo) error {
- const (
- fname = "cpu.cfs_burst_us"
- subsys = "cpu"
- )
+ const subsys = "cpu"
cgpath := c.CgroupPath(subsys)
- fpath := filepath.Join(cgpath, fname)
+ return setQuotaBurst(burst, cgpath)
+}
+func setQuotaBurst(burst []byte, cgpath string) error {
+ const burst_file_name = "cpu.cfs_burst_us"
+ fpath := filepath.Join(cgpath, burst_file_name)
+ // check whether cgroup support cpu burst
if _, err := os.Stat(fpath); err != nil && os.IsNotExist(err) {
return errors.Errorf("quota-burst path=%v missing", fpath)
}
-
+ // try to write cfs_burst_us
if err := ioutil.WriteFile(fpath, burst, constant.DefaultFileMode); err != nil {
return errors.Errorf("quota-burst path=%v setting failed: %v", fpath, err)
}
--
2.30.0

View File

@ -1,6 +1,6 @@
Name: rubik
Version: 1.0.0
Release: 1
Release: 2
Summary: Hybrid Deployment for Cloud Native
License: Mulan PSL V2
URL: https://gitee.com/openeuler/rubik
@ -50,6 +50,12 @@ install -Dp ./Dockerfile %{buildroot}%{_sharedstatedir}/%{name}/Dockerfile
rm -rf %{buildroot}
%changelog
* Wed Nov 16 2022 yangjiaqi <yangjiaqi16@huawei.com> - 1.0.0-2
- Type:bugfix
- CVE:NA
- SUG:restart
- DESC:set the burst value for the pod to enable the container burst
* Mon Nov 14 2022 hanchao <hanchao47@huawei.com> - 1.0.0-1
- Type:bugfix
- CVE:NA

View File

@ -1,3 +1,4 @@
patch/0001-rubik-enable-GO111MODULE-and-Optimized-compilation-i.patch
patch/0002-rubik-fix-Dockerfile-build-failed.patch
0003-set-the-burst-value-for-the-pod-to-enable-the-contai.patch
#end of file