rubik: support nri & optimize
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
This commit is contained in:
parent
0f26cb4552
commit
a1d5d5f63d
@ -1 +1 @@
|
||||
2.0.0-3
|
||||
2.0.0-8
|
||||
|
||||
@ -1 +1 @@
|
||||
fdaef8a93069235bac826890a028f8fa7e7d1620
|
||||
25197e4c5ef5b67040f64ecc54ac000a13506bc1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From b8e000527f7129242bd71f9c79697bef3a8b2111 Mon Sep 17 00:00:00 2001
|
||||
From aaa33596e0acb9e2ddb32bb888c15d86c242a388 Mon Sep 17 00:00:00 2001
|
||||
From: wujing <wujing50@huawei.com>
|
||||
Date: Wed, 10 May 2023 19:26:36 +0800
|
||||
Subject: [PATCH 1/7] Support Labels field to configure QoSLevel
|
||||
Subject: [PATCH 01/13] Support Labels field to configure QoSLevel
|
||||
|
||||
Signed-off-by: wujing <wujing50@huawei.com>
|
||||
---
|
||||
@ -184,5 +184,5 @@ index 18cb0ec..8053c4b 100644
|
||||
return fakePod
|
||||
}
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
From 804ff7873331cf745bc49aab5f5d2857ec1597c6 Mon Sep 17 00:00:00 2001
|
||||
From: hanchao <hanchao63@huawei.com>
|
||||
Date: Mon, 5 Jun 2023 13:56:01 +0800
|
||||
Subject: [PATCH 2/7] rubik: fix weight for iocost does not take effect
|
||||
From 347c81278ba63b6fe05476ad4dd9dd960b4b70a4 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Tue, 20 Aug 2024 13:26:04 +0000
|
||||
Subject: [PATCH 02/13] rubik-fix-weight-for-iocost-does-not-take-effect
|
||||
|
||||
reason: Fix weight for iocost does not take effect.
|
||||
The iocost weight is at pod level, not container
|
||||
level.
|
||||
---
|
||||
pkg/services/iocost/iocost.go | 7 +------
|
||||
pkg/services/iocost/iocost_origin.go | 8 ++++----
|
||||
@ -13,11 +10,11 @@ level.
|
||||
3 files changed, 6 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/pkg/services/iocost/iocost.go b/pkg/services/iocost/iocost.go
|
||||
index e5298b1..34f508a 100644
|
||||
index c11ef60..0f77edc 100644
|
||||
--- a/pkg/services/iocost/iocost.go
|
||||
+++ b/pkg/services/iocost/iocost.go
|
||||
@@ -239,10 +239,5 @@ func (b *IOCost) configPodIOCostWeight(podInfo *typedef.PodInfo) error {
|
||||
if podInfo.Annotations[constant.PriorityAnnotationKey] == "false" {
|
||||
if podInfo.Online() {
|
||||
weight = onlineWeight
|
||||
}
|
||||
- for _, container := range podInfo.IDContainersMap {
|
||||
@ -65,5 +62,5 @@ index 95b6d97..3bdadad 100644
|
||||
assert.Contains(t, err.Error(), tt.errMsg)
|
||||
return
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From e7c89f1935d117a2778339cc4774393331002254 Mon Sep 17 00:00:00 2001
|
||||
From eaa82db55dbc543f9911e3c5ef4dd550711deb63 Mon Sep 17 00:00:00 2001
|
||||
From: jingxiaolu <lujingxiao@huawei.com>
|
||||
Date: Mon, 12 Jun 2023 23:12:37 +0800
|
||||
Subject: [PATCH 3/7] rubik: test coverage for PSI Manager
|
||||
Subject: [PATCH 03/13] rubik: test coverage for PSI Manager
|
||||
|
||||
Adding test cases for PSI Manager
|
||||
|
||||
@ -260,5 +260,5 @@ index a6e0298..537d0b3 100644
|
||||
|
||||
func TestErrorInitServiceComponents(t *testing.T) {
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.41.0
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
From c74d87538bc27a20c24d27319c5d60970ab3ccab Mon Sep 17 00:00:00 2001
|
||||
From 780a5e80311f5f3d188666733dcf276abc8e7e81 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Wed, 14 Jun 2023 17:14:16 +0800
|
||||
Subject: [PATCH 5/7] rubik: move fssr design document to design dir
|
||||
Subject: [PATCH 05/13] rubik: move fssr design document to design dir
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
@ -79,5 +79,5 @@ similarity index 100%
|
||||
rename from docs/png/rubik_fssr_1.png
|
||||
rename to docs/images/fssr/sequence_diagram.png
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 526bd12a3b77135ce5f112f3195f1e7d41d965d5 Mon Sep 17 00:00:00 2001
|
||||
From f7d9bc26368763d9c0bc9e7fc462dc0ab99a1784 Mon Sep 17 00:00:00 2001
|
||||
From: hanchao <hanchao63@huawei.com>
|
||||
Date: Fri, 16 Jun 2023 13:10:42 +0800
|
||||
Subject: [PATCH 6/7] rubik: fix that value of memory.high_async_ratio lost
|
||||
Subject: [PATCH 06/13] rubik: fix that value of memory.high_async_ratio lost
|
||||
efficacy
|
||||
|
||||
---
|
||||
@ -242,5 +242,5 @@ index 9fe4042..e23a4bc 100644
|
||||
if !util.PathExist(memInfoFile) {
|
||||
return 0, fmt.Errorf("%v: no such file or diretory", memInfoFile)
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 6b9d862857a1b302b26d8d51e7df5fed3062ba94 Mon Sep 17 00:00:00 2001
|
||||
From 5d84595d50dc898b1c7307719cbd0807aff3fd99 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Mon, 19 Jun 2023 11:47:53 +0800
|
||||
Subject: [PATCH 7/7] bugfix: fix typos & calling order of waitgroup
|
||||
Subject: [PATCH 07/13] bugfix: fix typos & calling order of waitgroup
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
@ -123,5 +123,5 @@ index 3e162b6..c3b252a 100644
|
||||
}
|
||||
wg.Wait()
|
||||
--
|
||||
2.32.1 (Apple Git-133)
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From e30c428721ac2fd0da5152a28de04dbbf9c9d1ea Mon Sep 17 00:00:00 2001
|
||||
From 0403c7860be078ba67c5e05d7628411f72977d6b Mon Sep 17 00:00:00 2001
|
||||
From: jingxiaolu <lujingxiao@huawei.com>
|
||||
Date: Sun, 11 Jun 2023 22:34:08 +0800
|
||||
Subject: [PATCH 1/2] rubik: test coverage improvement for pkg/config
|
||||
Subject: [PATCH 08/13] rubik: test coverage improvement for pkg/config
|
||||
|
||||
1. improve test coverage for pkg/config from 57.4% to 80.3%
|
||||
2. change cpuLimit to 1 in TestStatusStore_AddCgroup-TC5 for nano vm
|
||||
@ -131,5 +131,5 @@ index 68c01c5..ce1684d 100644
|
||||
fields: fields{
|
||||
Config: &Config{
|
||||
--
|
||||
2.30.0
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 72dbcc6acf989f7c3423b24091c0b9875d1f4872 Mon Sep 17 00:00:00 2001
|
||||
From 3d63470cb0638f9b426f2060c260c45f27c36f04 Mon Sep 17 00:00:00 2001
|
||||
From: hanchao <hanchao63@huawei.com>
|
||||
Date: Mon, 19 Jun 2023 20:29:41 +0800
|
||||
Subject: [PATCH 2/2] rubik: optimize `dynamicAdjust` to be clear and add log
|
||||
Subject: [PATCH 09/13] rubik: optimize `dynamicAdjust` to be clear and add log
|
||||
for error
|
||||
|
||||
---
|
||||
@ -61,5 +61,5 @@ index e23a4bc..2c81ccf 100644
|
||||
|
||||
// adjustOfflinePodHighMemory adjusts the memory.high of offline pods.
|
||||
--
|
||||
2.30.0
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From d704f38600a31138107460b7eba4a68a0b8362ea Mon Sep 17 00:00:00 2001
|
||||
From f2322711a03a998b34b54a5cc784c727f814cc96 Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Tue, 26 Sep 2023 17:05:06 +0800
|
||||
Subject: [PATCH] support isulad container engine
|
||||
Subject: [PATCH 10/13] support isulad container engine
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
@ -72,5 +72,5 @@ index 59dfb59..138c580 100644
|
||||
|
||||
cid := cont.status.ContainerID[len(currentContainerEngines.Prefix()):]
|
||||
--
|
||||
2.25.1
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From f7cad7376bd823440df1f2f76c1d13cdfa8d4cbe Mon Sep 17 00:00:00 2001
|
||||
From 75075dbb1845e8714fa87ee0e19f80b8845dce71 Mon Sep 17 00:00:00 2001
|
||||
From: suoxiaocong <suoxiaocong@kylinos.cn>
|
||||
Date: Mon, 22 Apr 2024 15:52:03 +0800
|
||||
Subject: [PATCH] support systemd cgroup driver
|
||||
Subject: [PATCH 11/13] support systemd cgroup driver
|
||||
|
||||
---
|
||||
pkg/common/constant/constant.go | 7 +++++++
|
||||
@ -13,10 +13,10 @@ Subject: [PATCH] support systemd cgroup driver
|
||||
6 files changed, 71 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go
|
||||
index 6a1f69d..cf780b8 100644
|
||||
index 2df0b81..4f22ef0 100644
|
||||
--- a/pkg/common/constant/constant.go
|
||||
+++ b/pkg/common/constant/constant.go
|
||||
@@ -113,3 +113,10 @@ const (
|
||||
@@ -111,3 +111,10 @@ const (
|
||||
// PSIIOCgroupFileName is name of cgroup file used for detecting io psi
|
||||
PSIIOCgroupFileName = "io.pressure"
|
||||
)
|
||||
@ -28,7 +28,7 @@ index 6a1f69d..cf780b8 100644
|
||||
+ CgroupDriverCgroupfs = "cgroupfs"
|
||||
+)
|
||||
diff --git a/pkg/config/config.go b/pkg/config/config.go
|
||||
index e0caef3..b8d31a5 100644
|
||||
index 16ab6e1..6ae775f 100644
|
||||
--- a/pkg/config/config.go
|
||||
+++ b/pkg/config/config.go
|
||||
@@ -44,6 +44,7 @@ type AgentConfig struct {
|
||||
@ -58,7 +58,7 @@ index e0caef3..b8d31a5 100644
|
||||
}
|
||||
return c
|
||||
diff --git a/pkg/core/typedef/cgroup/common.go b/pkg/core/typedef/cgroup/common.go
|
||||
index 11002ab..668f951 100644
|
||||
index 8c0bd81..a952959 100644
|
||||
--- a/pkg/core/typedef/cgroup/common.go
|
||||
+++ b/pkg/core/typedef/cgroup/common.go
|
||||
@@ -25,6 +25,17 @@ import (
|
||||
@ -179,7 +179,7 @@ index 138c580..895e9d4 100644
|
||||
|
||||
// ListRawContainers returns all RawContainers in the RawPod
|
||||
diff --git a/pkg/rubik/rubik.go b/pkg/rubik/rubik.go
|
||||
index f55e834..c4fc583 100644
|
||||
index 3864956..3595ff1 100644
|
||||
--- a/pkg/rubik/rubik.go
|
||||
+++ b/pkg/rubik/rubik.go
|
||||
@@ -126,6 +126,9 @@ func runAgent(ctx context.Context) error {
|
||||
@ -193,5 +193,5 @@ index f55e834..c4fc583 100644
|
||||
// 4. init service components
|
||||
services.InitServiceComponents(defaultRubikFeature)
|
||||
--
|
||||
2.25.1
|
||||
2.41.0
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
From 8f7117653503d1f72df7ae35b45d48decce62154 Mon Sep 17 00:00:00 2001
|
||||
From 3741f7254be1a6766f7ca2056e689d6e84febb95 Mon Sep 17 00:00:00 2001
|
||||
From: weiyuan <weiyuan@kylinos.cn>
|
||||
Date: Mon, 20 May 2024 15:23:01 +0800
|
||||
Subject: [PATCH] support crio container engine
|
||||
Date: Tue, 21 May 2024 09:37:59 +0800
|
||||
Subject: [PATCH 12/13] support crio container engine
|
||||
|
||||
---
|
||||
pkg/core/typedef/containerinfo.go | 4 ++++
|
||||
@ -37,5 +37,5 @@ index f751b25..845105f 100644
|
||||
)
|
||||
|
||||
--
|
||||
2.39.2 (Apple Git-143)
|
||||
2.41.0
|
||||
|
||||
|
||||
191580
patch/0013-informer-add-nri-support.patch
Normal file
191580
patch/0013-informer-add-nri-support.patch
Normal file
File diff suppressed because it is too large
Load Diff
44
patch/0014-update-pkg-podmanager-podmanager.go.patch
Normal file
44
patch/0014-update-pkg-podmanager-podmanager.go.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From f7f84f78b3ec4d19e712404c80757f208a86b18a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=E5=B0=8F=E8=8D=89=E5=84=BF=E8=A6=81=E7=9D=A1=E8=A7=89?=
|
||||
<18503470247@163.com>
|
||||
Date: Wed, 4 Sep 2024 07:47:35 +0000
|
||||
Subject: [PATCH 1/2] =?UTF-8?q?update=20pkg/podmanager/podmanager.go.=20?=
|
||||
=?UTF-8?q?=E4=BF=AE=E5=A4=8Dpodmanager.go=E4=B8=ADeventToNRIRawContainers?=
|
||||
=?UTF-8?q?=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF=20toRawContainerPointer?=
|
||||
=?UTF-8?q?=E7=9A=84=E5=85=A5=E5=8F=82=E5=BA=94=E4=B8=BAcontainer=20,conta?=
|
||||
=?UTF-8?q?iners=E9=81=8D=E5=8E=86=E7=9A=84=E5=AD=90=E9=A1=B9=E4=B9=9F?=
|
||||
=?UTF-8?q?=E5=BA=94=E8=AF=A5=E6=98=AFcontainer?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: 小草儿要睡觉 <18503470247@163.com>
|
||||
---
|
||||
pkg/podmanager/podmanager.go | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/pkg/podmanager/podmanager.go b/pkg/podmanager/podmanager.go
|
||||
index d415018..17f95d3 100644
|
||||
--- a/pkg/podmanager/podmanager.go
|
||||
+++ b/pkg/podmanager/podmanager.go
|
||||
@@ -173,13 +173,13 @@ func eventToNRIRawContainers(e typedef.Event) ([]*typedef.NRIRawContainer, error
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("fail to get *typedef.NRIRawContainer which type is %T", e)
|
||||
}
|
||||
- toRawContainerPointer := func(pod nriapi.Container) *typedef.NRIRawContainer {
|
||||
- tmp := typedef.NRIRawContainer(pod)
|
||||
+ toRawContainerPointer := func(container nriapi.Container) *typedef.NRIRawContainer {
|
||||
+ tmp := typedef.NRIRawContainer(container)
|
||||
return &tmp
|
||||
}
|
||||
var pointerContainers []*typedef.NRIRawContainer
|
||||
- for _, pod := range containers {
|
||||
- pointerContainers = append(pointerContainers, toRawContainerPointer(*pod))
|
||||
+ for _, container := range containers {
|
||||
+ pointerContainers = append(pointerContainers, toRawContainerPointer(*container))
|
||||
}
|
||||
return pointerContainers, nil
|
||||
}
|
||||
--
|
||||
2.46.0
|
||||
|
||||
@ -0,0 +1,485 @@
|
||||
From fe585042518f7c1a1da09028fe56177fa573ebbc Mon Sep 17 00:00:00 2001
|
||||
From: vegbir <yangjiaqi16@huawei.com>
|
||||
Date: Wed, 4 Sep 2024 10:35:50 +0800
|
||||
Subject: [PATCH 2/2] rubik: set container engine when getting container id
|
||||
|
||||
reason:
|
||||
bugfix: `/proc/self/cgroup` is not a sure way to get container engine because of the different cgroup path format.
|
||||
So we have two approaches to get container engines: `proc/self/cgroup` or containerdID passed by k8s.
|
||||
reconstruct: We abstract the cgroup driver, i.e., systemd &cgroupfs, to simplify the code for splicing cgroup paths.
|
||||
Currently, only the path to the apiserver has been simplified, and the nri method needs to be reconstructed.
|
||||
|
||||
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
|
||||
---
|
||||
pkg/core/typedef/cgroup/cgroupfs/driver.go | 37 +++++++++
|
||||
pkg/core/typedef/cgroup/common.go | 5 --
|
||||
pkg/core/typedef/cgroup/driver.go | 48 +++++++++++
|
||||
pkg/core/typedef/cgroup/systemd/driver.go | 51 ++++++++++++
|
||||
pkg/core/typedef/containerinfo.go | 34 ++++----
|
||||
pkg/core/typedef/nrirawpod.go | 63 +--------------
|
||||
pkg/core/typedef/rawpod.go | 92 ++++++----------------
|
||||
7 files changed, 175 insertions(+), 155 deletions(-)
|
||||
create mode 100644 pkg/core/typedef/cgroup/cgroupfs/driver.go
|
||||
create mode 100644 pkg/core/typedef/cgroup/driver.go
|
||||
create mode 100644 pkg/core/typedef/cgroup/systemd/driver.go
|
||||
|
||||
diff --git a/pkg/core/typedef/cgroup/cgroupfs/driver.go b/pkg/core/typedef/cgroup/cgroupfs/driver.go
|
||||
new file mode 100644
|
||||
index 0000000..4256deb
|
||||
--- /dev/null
|
||||
+++ b/pkg/core/typedef/cgroup/cgroupfs/driver.go
|
||||
@@ -0,0 +1,37 @@
|
||||
+// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
|
||||
+// rubik licensed under the Mulan PSL v2.
|
||||
+// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
+// You may obtain a copy of Mulan PSL v2 at:
|
||||
+// http://license.coscl.org.cn/MulanPSL2
|
||||
+// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
+// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
+// PURPOSE.
|
||||
+// See the Mulan PSL v2 for more details.
|
||||
+// Author: Jiaqi Yang
|
||||
+// Date: 2024-09-03
|
||||
+// Description: This file is used for cgroupfs driver
|
||||
+
|
||||
+package cgroupfs
|
||||
+
|
||||
+import (
|
||||
+ "path/filepath"
|
||||
+
|
||||
+ "isula.org/rubik/pkg/common/constant"
|
||||
+)
|
||||
+
|
||||
+const Name = "cgroupfs"
|
||||
+
|
||||
+type Driver struct{}
|
||||
+
|
||||
+func (d *Driver) Name() string {
|
||||
+ return Name
|
||||
+}
|
||||
+
|
||||
+func (d *Driver) ConcatPodCgroupPath(qosClass string, id string) string {
|
||||
+ // When using cgroupfs as cgroup driver:
|
||||
+ // 1. The Burstable path looks like: kubepods/burstable/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
+ // 2. The BestEffort path is in the form: kubepods/bestEffort/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
+ // 3. The Guaranteed path is in the form: kubepods/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
+
|
||||
+ return filepath.Join(constant.KubepodsCgroup, qosClass, constant.PodCgroupNamePrefix+id)
|
||||
+}
|
||||
diff --git a/pkg/core/typedef/cgroup/common.go b/pkg/core/typedef/cgroup/common.go
|
||||
index 668f951..5252e7d 100644
|
||||
--- a/pkg/core/typedef/cgroup/common.go
|
||||
+++ b/pkg/core/typedef/cgroup/common.go
|
||||
@@ -27,11 +27,6 @@ import (
|
||||
var rootDir = constant.DefaultCgroupRoot
|
||||
var cgroupDriver = constant.CgroupDriverCgroupfs
|
||||
|
||||
-// SetCgroupDriver is the setter of global cgroup driver
|
||||
-func SetCgroupDriver(driver string) {
|
||||
- cgroupDriver = driver
|
||||
-}
|
||||
-
|
||||
// GetCgroupDriver is the getter of global cgroup driver
|
||||
func GetCgroupDriver() string {
|
||||
return cgroupDriver
|
||||
diff --git a/pkg/core/typedef/cgroup/driver.go b/pkg/core/typedef/cgroup/driver.go
|
||||
new file mode 100644
|
||||
index 0000000..b8cd4d5
|
||||
--- /dev/null
|
||||
+++ b/pkg/core/typedef/cgroup/driver.go
|
||||
@@ -0,0 +1,48 @@
|
||||
+// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
|
||||
+// rubik licensed under the Mulan PSL v2.
|
||||
+// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
+// You may obtain a copy of Mulan PSL v2 at:
|
||||
+// http://license.coscl.org.cn/MulanPSL2
|
||||
+// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
+// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
+// PURPOSE.
|
||||
+// See the Mulan PSL v2 for more details.
|
||||
+// Author: Jiaqi Yang
|
||||
+// Date: 2024-09-03
|
||||
+// Description: This file is used for cgroup driver
|
||||
+
|
||||
+package cgroup
|
||||
+
|
||||
+import (
|
||||
+ "isula.org/rubik/pkg/core/typedef/cgroup/cgroupfs"
|
||||
+ "isula.org/rubik/pkg/core/typedef/cgroup/systemd"
|
||||
+)
|
||||
+
|
||||
+type Driver interface {
|
||||
+ Name() string
|
||||
+ ConcatPodCgroupPath(qosClass string, id string) string
|
||||
+}
|
||||
+
|
||||
+var driver Driver = &cgroupfs.Driver{}
|
||||
+
|
||||
+// SetCgroupDriver is the setter of global cgroup driver
|
||||
+func SetCgroupDriver(driverTyp string) {
|
||||
+ cgroupDriver = driverTyp
|
||||
+ switch driverTyp {
|
||||
+ case systemd.Name:
|
||||
+ driver = &systemd.Driver{}
|
||||
+ case cgroupfs.Name:
|
||||
+ driver = &cgroupfs.Driver{}
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+func Type() string {
|
||||
+ return driver.Name()
|
||||
+}
|
||||
+func ConcatPodCgroupPath(qosClass, id string) string {
|
||||
+ return driver.ConcatPodCgroupPath(qosClass, id)
|
||||
+}
|
||||
+
|
||||
+func ConcatContainerCgroupPath(podCgroupPath string, containerScope string) string {
|
||||
+ return driver.ConcatPodCgroupPath(podCgroupPath, containerScope)
|
||||
+}
|
||||
diff --git a/pkg/core/typedef/cgroup/systemd/driver.go b/pkg/core/typedef/cgroup/systemd/driver.go
|
||||
new file mode 100644
|
||||
index 0000000..740b7ba
|
||||
--- /dev/null
|
||||
+++ b/pkg/core/typedef/cgroup/systemd/driver.go
|
||||
@@ -0,0 +1,51 @@
|
||||
+// Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
|
||||
+// rubik licensed under the Mulan PSL v2.
|
||||
+// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
+// You may obtain a copy of Mulan PSL v2 at:
|
||||
+// http://license.coscl.org.cn/MulanPSL2
|
||||
+// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
+// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
+// PURPOSE.
|
||||
+// See the Mulan PSL v2 for more details.
|
||||
+// Author: Jiaqi Yang
|
||||
+// Date: 2024-09-03
|
||||
+// Description: This file is used for system cgroup driver
|
||||
+
|
||||
+package systemd
|
||||
+
|
||||
+import (
|
||||
+ "path/filepath"
|
||||
+ "strings"
|
||||
+
|
||||
+ "isula.org/rubik/pkg/common/constant"
|
||||
+)
|
||||
+
|
||||
+const Name = "systemd"
|
||||
+
|
||||
+type Driver struct{}
|
||||
+
|
||||
+func (d *Driver) Name() string {
|
||||
+ return Name
|
||||
+}
|
||||
+
|
||||
+func (d *Driver) ConcatPodCgroupPath(qosClass string, id string) string {
|
||||
+ // When using systemd as cgroup driver:
|
||||
+ // 1. The Burstable path looks like: kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice
|
||||
+ // 2. The BestEffort path is in the form: kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice
|
||||
+ // 3. The Guaranteed path is in the form: kubepods.slice/kubepods-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice/
|
||||
+ const suffix = ".slice"
|
||||
+ var (
|
||||
+ prefix = constant.KubepodsCgroup
|
||||
+ podPath = constant.KubepodsCgroup + suffix
|
||||
+ )
|
||||
+ if qosClass != "" {
|
||||
+ podPath = filepath.Join(podPath, constant.KubepodsCgroup+"-"+qosClass+suffix)
|
||||
+ prefix = strings.Join([]string{prefix, qosClass}, "-")
|
||||
+ }
|
||||
+ return filepath.Join(podPath,
|
||||
+ strings.Join([]string{prefix, constant.PodCgroupNamePrefix + strings.Replace(id, "-", "_", -1) + suffix}, "-"))
|
||||
+}
|
||||
+
|
||||
+func (d *Driver) ConcatContainerCgroupPath(podCgroupPath string, containerScope string) string {
|
||||
+ return filepath.Join(podCgroupPath, containerScope+".scope")
|
||||
+}
|
||||
diff --git a/pkg/core/typedef/containerinfo.go b/pkg/core/typedef/containerinfo.go
|
||||
index 841c800..ec04ed8 100644
|
||||
--- a/pkg/core/typedef/containerinfo.go
|
||||
+++ b/pkg/core/typedef/containerinfo.go
|
||||
@@ -85,33 +85,30 @@ type ContainerInfo struct {
|
||||
PodSandboxId string `json:"podisandid,omitempty"`
|
||||
}
|
||||
|
||||
+func containerPath(id, podCgroupPath string) string {
|
||||
+ if cgroup.Type() == constant.CgroupDriverSystemd {
|
||||
+ return filepath.Join(podCgroupPath, containerEngineScopes[currentContainerEngines]+"-"+id+".scope")
|
||||
+ }
|
||||
+ // In the case of cgroupfs, the path of crio contains a special prefix
|
||||
+ if containerEngineScopes[currentContainerEngines] == constant.ContainerEngineCrio {
|
||||
+ return filepath.Join(podCgroupPath, constant.ContainerEngineCrio+"-"+id)
|
||||
+ }
|
||||
+ return filepath.Join(podCgroupPath, id)
|
||||
+}
|
||||
+
|
||||
// NewContainerInfo creates a ContainerInfo instance
|
||||
func NewContainerInfo(id, podCgroupPath string, rawContainer *RawContainer) *ContainerInfo {
|
||||
- scopeName := containerEngineScopes[currentContainerEngines]
|
||||
requests, limits := rawContainer.GetResourceMaps()
|
||||
- var path string
|
||||
- if cgroup.GetCgroupDriver() == constant.CgroupDriverSystemd {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineCrio, constant.ContainerEngineDocker, constant.ContainerEngineIsula:
|
||||
- path = filepath.Join(podCgroupPath, scopeName+"-"+id+".scope")
|
||||
- }
|
||||
- } else {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineDocker, constant.ContainerEngineIsula:
|
||||
- path = filepath.Join(podCgroupPath, id)
|
||||
- case constant.ContainerEngineCrio:
|
||||
- path = filepath.Join(podCgroupPath, scopeName+"-"+id)
|
||||
- }
|
||||
- }
|
||||
return &ContainerInfo{
|
||||
Name: rawContainer.status.Name,
|
||||
ID: id,
|
||||
- Hierarchy: cgroup.Hierarchy{Path: path},
|
||||
+ Hierarchy: cgroup.Hierarchy{Path: containerPath(id, podCgroupPath)},
|
||||
RequestResources: requests,
|
||||
- LimitResources: limits}
|
||||
+ LimitResources: limits,
|
||||
+ }
|
||||
}
|
||||
|
||||
-func fixContainerEngine(containerID string) {
|
||||
+func getEngineFromContainerID(containerID string) {
|
||||
for engine, prefix := range supportEnginesPrefixMap {
|
||||
if strings.HasPrefix(containerID, prefix) {
|
||||
currentContainerEngines = engine
|
||||
@@ -119,7 +116,6 @@ func fixContainerEngine(containerID string) {
|
||||
return
|
||||
}
|
||||
}
|
||||
- currentContainerEngines = UNDEFINED
|
||||
}
|
||||
|
||||
// DeepCopy returns deepcopy object.
|
||||
diff --git a/pkg/core/typedef/nrirawpod.go b/pkg/core/typedef/nrirawpod.go
|
||||
index 0749c8a..d060923 100644
|
||||
--- a/pkg/core/typedef/nrirawpod.go
|
||||
+++ b/pkg/core/typedef/nrirawpod.go
|
||||
@@ -49,10 +49,6 @@ const (
|
||||
fileMode os.FileMode = 0666
|
||||
)
|
||||
|
||||
-func init() {
|
||||
- setContainerEnginesOnce.Do(FixContainerEngine)
|
||||
-}
|
||||
-
|
||||
// convert NRIRawPod structure to PodInfo structure
|
||||
func (pod *NRIRawPod) ConvertNRIRawPod2PodInfo() *PodInfo {
|
||||
if pod == nil {
|
||||
@@ -87,7 +83,6 @@ func (pod *NRIRawPod) GetQosClass() string {
|
||||
|
||||
// get pod cgroupPath
|
||||
func (pod *NRIRawPod) CgroupPath() string {
|
||||
- var path string
|
||||
id := pod.Uid
|
||||
|
||||
qosClassPath := ""
|
||||
@@ -100,61 +95,7 @@ func (pod *NRIRawPod) CgroupPath() string {
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
- /*
|
||||
- Kubernetes defines three different pods:
|
||||
- 1. Burstable: pod requests are less than the value of limits and not 0;
|
||||
- 2. BestEffort: pod requests and limits are both 0;
|
||||
- 3. Guaranteed: pod requests are equal to the value set by limits;
|
||||
-
|
||||
- When using cgroupfs as cgroup driver,
|
||||
- 1. The Burstable path looks like: kubepods/burstable/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
- 2. The BestEffort path is in the form: kubepods/besteffort/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
- 3. The Guaranteed path is in the form: kubepods/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
-
|
||||
- When using systemd as cgroup driver:
|
||||
- 1. The Burstable path looks like: kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice
|
||||
- 2. The BestEffort path is in the form: kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice
|
||||
- 3. The Guaranteed path is in the form: kubepods.slice/kubepods-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice/
|
||||
- */
|
||||
-
|
||||
- if cgroup.GetCgroupDriver() == constant.CgroupDriverSystemd {
|
||||
- if qosClassPath == "" {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineCrio, constant.ContainerEngineDocker, constant.ContainerEngineIsula:
|
||||
- path = filepath.Join(
|
||||
- constant.KubepodsCgroup+".slice",
|
||||
- constant.KubepodsCgroup+"-"+constant.PodCgroupNamePrefix+strings.Replace(id, "-", "_", -1)+".slice",
|
||||
- )
|
||||
- }
|
||||
- } else {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineCrio, constant.ContainerEngineDocker, constant.ContainerEngineIsula:
|
||||
- path = filepath.Join(
|
||||
- constant.KubepodsCgroup+".slice",
|
||||
- constant.KubepodsCgroup+"-"+qosClassPath+".slice",
|
||||
- pod.Linux.CgroupParent,
|
||||
- )
|
||||
-
|
||||
- }
|
||||
- }
|
||||
- } else {
|
||||
- if qosClassPath == "" {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineDocker, constant.ContainerEngineIsula, constant.ContainerEngineCrio:
|
||||
- path = filepath.Join(constant.KubepodsCgroup, constant.PodCgroupNamePrefix+id)
|
||||
- }
|
||||
- } else {
|
||||
-
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineDocker, constant.ContainerEngineIsula, constant.ContainerEngineCrio:
|
||||
- path = filepath.Join(constant.KubepodsCgroup, qosClassPath, constant.PodCgroupNamePrefix+id)
|
||||
- default:
|
||||
- path = ""
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- }
|
||||
- return path
|
||||
+ return cgroup.ConcatPodCgroupPath(qosClassPath, id)
|
||||
}
|
||||
|
||||
// get pod running state
|
||||
@@ -437,7 +378,7 @@ func (container *NRIRawContainer) GetResourceMaps() (ResourceMap, ResourceMap) {
|
||||
}
|
||||
|
||||
// get current container engine
|
||||
-func FixContainerEngine() {
|
||||
+func getEngineFromCgroup() {
|
||||
file, err := os.OpenFile(procSelfCgroupFile, os.O_RDONLY, fileMode)
|
||||
if err != nil {
|
||||
return
|
||||
diff --git a/pkg/core/typedef/rawpod.go b/pkg/core/typedef/rawpod.go
|
||||
index b67126a..b653c71 100644
|
||||
--- a/pkg/core/typedef/rawpod.go
|
||||
+++ b/pkg/core/typedef/rawpod.go
|
||||
@@ -16,13 +16,11 @@ package typedef
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
- "path/filepath"
|
||||
"strings"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
- "isula.org/rubik/pkg/common/constant"
|
||||
"isula.org/rubik/pkg/core/typedef/cgroup"
|
||||
)
|
||||
|
||||
@@ -86,83 +84,30 @@ func (pod *RawPod) ID() string {
|
||||
return string(pod.UID)
|
||||
}
|
||||
|
||||
+// Kubernetes defines three different pods:
|
||||
+// 1. Burstable: pod requests are less than the value of limits and not 0;
|
||||
+// 2. BestEffort: pod requests and limits are both 0;
|
||||
+// 3. Guaranteed: pod requests are equal to the value set by limits;
|
||||
+var k8sQosClass = map[corev1.PodQOSClass]string{
|
||||
+ corev1.PodQOSGuaranteed: "",
|
||||
+ corev1.PodQOSBurstable: strings.ToLower(string(corev1.PodQOSBurstable)),
|
||||
+ corev1.PodQOSBestEffort: strings.ToLower(string(corev1.PodQOSBestEffort)),
|
||||
+}
|
||||
+
|
||||
// CgroupPath returns cgroup path of raw pod
|
||||
// handle different combinations of cgroupdriver and pod qos and container runtime
|
||||
-func (pod *RawPod) CgroupPath() string {
|
||||
+func (pod *RawPod) CgroupPath() (res string) {
|
||||
id := string(pod.UID)
|
||||
if configHash := pod.Annotations[configHashAnnotationKey]; configHash != "" {
|
||||
id = configHash
|
||||
}
|
||||
|
||||
- qosClassPath := ""
|
||||
- switch pod.Status.QOSClass {
|
||||
- case corev1.PodQOSGuaranteed:
|
||||
- case corev1.PodQOSBurstable:
|
||||
- qosClassPath = strings.ToLower(string(corev1.PodQOSBurstable))
|
||||
- case corev1.PodQOSBestEffort:
|
||||
- qosClassPath = strings.ToLower(string(corev1.PodQOSBestEffort))
|
||||
- default:
|
||||
+ qosPrefix, existed := k8sQosClass[pod.Status.QOSClass]
|
||||
+ if !existed {
|
||||
+ fmt.Printf("unsupported qos class: %v", pod.Status.QOSClass)
|
||||
return ""
|
||||
}
|
||||
-
|
||||
- /*
|
||||
- Kubernetes defines three different pods:
|
||||
- 1. Burstable: pod requests are less than the value of limits and not 0;
|
||||
- 2. BestEffort: pod requests and limits are both 0;
|
||||
- 3. Guaranteed: pod requests are equal to the value set by limits;
|
||||
-
|
||||
- When using cgroupfs as cgroup driver:
|
||||
- 1. The Burstable path looks like: kubepods/burstable/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
- 2. The BestEffort path is in the form: kubepods/bestEffort/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
- 3. The Guaranteed path is in the form: kubepods/pod34152897-dbaf-11ea-8cb9-0653660051c3
|
||||
-
|
||||
- When using systemd as cgroup driver:
|
||||
- 1. The Burstable path looks like: kubepods.slice/kubepods-burstable.slice/kubepods-burstable-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice
|
||||
- 2. The BestEffort path is in the form: kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice
|
||||
- 3. The Guaranteed path is in the form: kubepods.slice/kubepods-podb895995a_e7e5_413e_9bc1_3c3895b3f233.slice/
|
||||
- */
|
||||
-
|
||||
- if cgroup.GetCgroupDriver() == constant.CgroupDriverSystemd {
|
||||
- if qosClassPath == "" {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineCrio, constant.ContainerEngineDocker, constant.ContainerEngineIsula:
|
||||
- return filepath.Join(
|
||||
- constant.KubepodsCgroup+".slice",
|
||||
- constant.KubepodsCgroup+"-"+constant.PodCgroupNamePrefix+strings.Replace(id, "-", "_", -1)+".slice",
|
||||
- )
|
||||
- default:
|
||||
- return ""
|
||||
- }
|
||||
- } else {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineContainerd, constant.ContainerEngineCrio, constant.ContainerEngineDocker, constant.ContainerEngineIsula:
|
||||
- return filepath.Join(
|
||||
- constant.KubepodsCgroup+".slice",
|
||||
- constant.KubepodsCgroup+"-"+qosClassPath+".slice",
|
||||
- constant.KubepodsCgroup+"-"+qosClassPath+"-"+constant.PodCgroupNamePrefix+strings.Replace(id, "-", "_", -1)+".slice",
|
||||
- )
|
||||
- default:
|
||||
- return ""
|
||||
- }
|
||||
-
|
||||
- }
|
||||
- } else {
|
||||
- if qosClassPath == "" {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineDocker, constant.ContainerEngineContainerd, constant.ContainerEngineIsula, constant.ContainerEngineCrio:
|
||||
- return filepath.Join(constant.KubepodsCgroup, constant.PodCgroupNamePrefix+id)
|
||||
- default:
|
||||
- return ""
|
||||
- }
|
||||
- } else {
|
||||
- switch containerEngineScopes[currentContainerEngines] {
|
||||
- case constant.ContainerEngineDocker, constant.ContainerEngineContainerd, constant.ContainerEngineIsula, constant.ContainerEngineCrio:
|
||||
- return filepath.Join(constant.KubepodsCgroup, qosClassPath, constant.PodCgroupNamePrefix+id)
|
||||
- default:
|
||||
- return ""
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ return cgroup.ConcatPodCgroupPath(qosPrefix, id)
|
||||
}
|
||||
|
||||
// ListRawContainers returns all RawContainers in the RawPod
|
||||
@@ -221,6 +166,13 @@ func (cont *RawContainer) GetRealContainerID() (string, error) {
|
||||
So we don't consider the case of midway container engine changes
|
||||
`fixContainerEngine` is only executed when `getRealContainerID` is called for the first time
|
||||
*/
|
||||
+ setContainerEnginesOnce.Do(func() {
|
||||
+ getEngineFromCgroup()
|
||||
+ _, exist := supportEnginesPrefixMap[currentContainerEngines]
|
||||
+ if !exist {
|
||||
+ getEngineFromContainerID(cont.status.ContainerID)
|
||||
+ }
|
||||
+ })
|
||||
|
||||
if !currentContainerEngines.Support(cont) {
|
||||
return "", fmt.Errorf("unsupported container engine: %v", cont.status.ContainerID)
|
||||
--
|
||||
2.46.0
|
||||
|
||||
16
rubik.spec
16
rubik.spec
@ -1,6 +1,6 @@
|
||||
Name: rubik
|
||||
Version: 2.0.0
|
||||
Release: 6
|
||||
Release: 8
|
||||
Summary: Hybrid Deployment for Cloud Native
|
||||
License: Mulan PSL V2
|
||||
URL: https://gitee.com/openeuler/rubik
|
||||
@ -59,6 +59,18 @@ install -Dp ./build_rubik_image.sh %{buildroot}%{_sharedstatedir}/%{name}/build_
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%changelog
|
||||
* Fri Sep 20 2024 wujing <wujing50@huawei.com> - 2.0.0-8
|
||||
- Type: bugfix
|
||||
- CVE:NA
|
||||
- SUG:restart
|
||||
- DESC:sync upstream patches
|
||||
|
||||
* Tue Aug 20 2024 vegbir <yangjiaqi16@huawei.com> - 2.0.0-7
|
||||
- Type: bugfix
|
||||
- CVE:NA
|
||||
- SUG:restart
|
||||
- DESC:informer add nri support
|
||||
|
||||
* Tue Jul 02 2024 zhangxianting <zhangxianting@uniontech.com> - 2.0.0-6
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
@ -71,7 +83,7 @@ rm -rf %{buildroot}
|
||||
- SUG:restart
|
||||
- DESC:support crio container engine
|
||||
|
||||
* Fri May 10 2024 weiyucheng <weiyucheng@kylinos.cn> - 2.0.0-4
|
||||
* Thu May 09 2024 weiyucheng <weiyucheng@kylinos.cn> - 2.0.0-4
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:restart
|
||||
|
||||
@ -10,4 +10,7 @@ patch/0009-rubik-optimize-dynamicAdjust-to-be-clear-and-add-log.patch
|
||||
patch/0010-support-isulad-container-engine.patch
|
||||
patch/0011-support-systemd-cgroup-driver.patch
|
||||
patch/0012-support-crio-container-engine.patch
|
||||
patch/0013-informer-add-nri-support.patch
|
||||
patch/0014-update-pkg-podmanager-podmanager.go.patch
|
||||
patch/0015-rubik-set-container-engine-when-getting-container-id.patch
|
||||
#end of file
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user