From f919a1e295087cddf5a7b7a2b7bf42f6d0e99d6b Mon Sep 17 00:00:00 2001 From: yangjiaqi Date: Wed, 16 Nov 2022 20:42:15 +0800 Subject: [PATCH] set the burst value for the pod to enable the container burst --- VERSION-openeuler | 2 +- git-commit | 2 +- ...lue-for-the-pod-to-enable-the-contai.patch | 66 +++++++++++++++++++ rubik.spec | 8 ++- series.conf | 1 + 5 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 patch/0003-set-the-burst-value-for-the-pod-to-enable-the-contai.patch diff --git a/VERSION-openeuler b/VERSION-openeuler index 8269426..bfd9ea6 100644 --- a/VERSION-openeuler +++ b/VERSION-openeuler @@ -1 +1 @@ -1.0.0-1 +1.0.0-2 diff --git a/git-commit b/git-commit index 7828cee..aa31743 100644 --- a/git-commit +++ b/git-commit @@ -1 +1 @@ -00439b708862b76e51668b9683f421be5fa2b42d +55da35c3391d84a6f7af898ce39657d5c45709fe diff --git a/patch/0003-set-the-burst-value-for-the-pod-to-enable-the-contai.patch b/patch/0003-set-the-burst-value-for-the-pod-to-enable-the-contai.patch new file mode 100644 index 0000000..c79c251 --- /dev/null +++ b/patch/0003-set-the-burst-value-for-the-pod-to-enable-the-contai.patch @@ -0,0 +1,66 @@ +From 1817eb44c25980c5ced63965838fe428c8860540 Mon Sep 17 00:00:00 2001 +From: yangjiaqi +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 + diff --git a/rubik.spec b/rubik.spec index 07ac1a4..dfe857c 100644 --- a/rubik.spec +++ b/rubik.spec @@ -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 - 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 - 1.0.0-1 - Type:bugfix - CVE:NA diff --git a/series.conf b/series.conf index ceb6f3f..d1dc491 100644 --- a/series.conf +++ b/series.conf @@ -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