Skip to content

Commit 042d169

Browse files
author
kaiyuechen
committed
fix code about watermark of cpu/mem usage percent
1 parent f388a54 commit 042d169

File tree

12 files changed

+97
-60
lines changed

12 files changed

+97
-60
lines changed

examples/ensurance/evict-on-cpu-usage-percent/elastic-pod-qos.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ metadata:
55
spec:
66
allowedActions:
77
- eviction
8-
resourceQOS:
9-
cpuQOS:
10-
cpuPriority: 7
118
labelSelector:
129
matchLabels:
1310
preemptible_job: "true"

examples/ensurance/evict-on-cpu-usage-percent/pod.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ metadata:
88
spec:
99
containers:
1010
- command:
11-
- stress-nga
11+
- stress-ng
1212
- -c
1313
- "2"
1414
- --cpu-method
1515
- cpuid
16-
image: ccr.ccs.tencentyun.com/tkeimages/stress-ng:v0.12.09.ln
16+
image: docker.io/gocrane/stress-ng:v0.12.09
1717
imagePullPolicy: IfNotPresent
1818
name: low
1919
resources:

examples/ensurance/evict-on-cpu-usage-total/be-rules.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ metadata:
55
spec:
66
allowedActions:
77
- eviction
8-
resourceQOS:
9-
cpuQOS:
10-
cpuPriority: 7
11-
htIsolation:
12-
enable: false
138
scopeSelector:
149
matchExpressions:
1510
- operator: In

examples/ensurance/evict-on-mem-usage-percent/elastic-pod-qos.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ metadata:
55
spec:
66
allowedActions:
77
- eviction
8-
resourceQOS:
9-
cpuQOS:
10-
cpuPriority: 7
118
labelSelector:
129
matchLabels:
1310
preemptible_job: "true"
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
apiVersion: v1
22
kind: Pod
33
metadata:
4-
name: low-pi6
4+
name: low-pi1
55
labels:
66
k8s-app: low
77
preemptible_job: "true"
88
spec:
99
containers:
10-
- image: ccr.ccs.tencentyun.com/tkeimages/stress-ng:v0.12.09
10+
- image: docker.io/gocrane/stress-ng:v0.12.09
1111
command:
1212
- stress-ng
1313
- --vm-hang
@@ -17,14 +17,6 @@ spec:
1717
- --vm-bytes
1818
- "2G"
1919
name: stress
20-
volumeMounts:
21-
- mountPath: /data
22-
name: data
23-
volumes:
24-
- hostPath:
25-
path: /data/dd
26-
type: DirectoryOrCreate
27-
name: data
2820
---
2921
apiVersion: v1
3022
kind: Pod
@@ -35,7 +27,7 @@ metadata:
3527
preemptible_job: "true"
3628
spec:
3729
containers:
38-
- image: ccr.ccs.tencentyun.com/tkeimages/stress-ng:v0.12.09
30+
- image: docker.io/gocrane/stress-ng:v0.12.09
3931
command:
4032
- stress-ng
4133
- --vm-hang
@@ -45,12 +37,4 @@ spec:
4537
- --vm-bytes
4638
- "3.5G"
4739
name: stress
48-
volumeMounts:
49-
- mountPath: /data
50-
name: data
51-
volumes:
52-
- hostPath:
53-
path: /data/dd
54-
type: DirectoryOrCreate
55-
name: data
5640

examples/ensurance/evict-on-mem-usage-percent/watermark.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ spec:
1313
metricRule:
1414
name: memory_total_utilization
1515
value: 50
16-
name: cpu-usage-percent
16+
name: mem-usage-percent
1717
restoreThreshold: 2
1818
strategy: None

examples/ensurance/evict-on-mem-usage-total/elastic-pod-qos.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ metadata:
55
spec:
66
allowedActions:
77
- eviction
8-
resourceQOS:
9-
cpuQOS:
10-
cpuPriority: 7
118
labelSelector:
129
matchLabels:
1310
preemptible_job: "true"
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
apiVersion: v1
22
kind: Pod
33
metadata:
4-
name: low-pi6
4+
name: low-pi1
55
labels:
66
k8s-app: low
77
preemptible_job: "true"
88
spec:
99
containers:
10-
- image: ccr.ccs.tencentyun.com/tkeimages/stress-ng:v0.12.09
10+
- image: docker.io/gocrane/stress-ng:v0.12.09
1111
command:
1212
- stress-ng
1313
- --vm-hang
@@ -17,14 +17,6 @@ spec:
1717
- --vm-bytes
1818
- "2G"
1919
name: stress
20-
volumeMounts:
21-
- mountPath: /data
22-
name: data
23-
volumes:
24-
- hostPath:
25-
path: /data/dd
26-
type: DirectoryOrCreate
27-
name: data
2820
---
2921
apiVersion: v1
3022
kind: Pod
@@ -35,7 +27,7 @@ metadata:
3527
preemptible_job: "true"
3628
spec:
3729
containers:
38-
- image: ccr.ccs.tencentyun.com/tkeimages/stress-ng:v0.12.09
30+
- image: docker.io/gocrane/stress-ng:v0.12.09
3931
command:
4032
- stress-ng
4133
- --vm-hang
@@ -45,12 +37,4 @@ spec:
4537
- --vm-bytes
4638
- "3.5G"
4739
name: stress
48-
volumeMounts:
49-
- mountPath: /data
50-
name: data
51-
volumes:
52-
- hostPath:
53-
path: /data/dd
54-
type: DirectoryOrCreate
55-
name: data
5640

examples/ensurance/evict-on-mem-usage-total/watermark.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ spec:
1212
avoidanceThreshold: 2
1313
metricRule:
1414
name: memory_total_usage
15-
value: 5000000000
16-
name: cpu-usage-percent
15+
value: 5000000000 # means 5Gi
16+
name: mem-usage
1717
restoreThreshold: 2
1818
strategy: None

pkg/ensurance/collector/cadvisor/cadvisor_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ func (c *CadvisorCollector) Collect() (map[string][]common.TimeSeries, error) {
162162
extResMemUse += float64(v.Stats[0].Memory.WorkingSet)
163163
}
164164

165-
var containerLabels = GetContainerLabels(pod, containerId, containerName, hasExtCpuRes)
165+
hasExtRes := hasExtCpuRes || hasExtMemRes
166+
var containerLabels = GetContainerLabels(pod, containerId, containerName, hasExtRes)
166167
addSampleToStateMap(types.MetricNameContainerMemTotalUsage, composeSample(containerLabels, float64(v.Stats[0].Memory.WorkingSet), now), stateMap)
167168
klog.V(6).Infof("Pod: %s, containerName: %s, key %s, container_mem_total_usage %#v", klog.KObj(pod), containerName, key, float64(v.Stats[0].Memory.WorkingSet))
168169

0 commit comments

Comments
 (0)