Skip to content

Commit 21aee68

Browse files
NikolaySSarumyan
authored andcommitted
chore: right-size self-cadvisor resource limits
1 parent f6c4455 commit 21aee68

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ services:
306306
self-cadvisor:
307307
image: ghcr.io/google/cadvisor:0.56.2
308308
container_name: self-cadvisor
309-
cpus: 0.15
310-
mem_limit: 192m
309+
cpus: 0.25
310+
mem_limit: 402653184
311311
privileged: true
312312
volumes:
313313
- /:/rootfs:ro

postgres_ai_helm/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ cadvisor:
140140
# registry convention, unlike other images here).
141141
enabled: false
142142
image: ghcr.io/google/cadvisor:0.56.2
143-
resources: {}
143+
resources:
144+
requests:
145+
cpu: 100m
146+
memory: 192Mi
147+
limits:
148+
cpu: 250m
149+
memory: 384Mi
144150

145151
monitoredDatabases:
146152
# Example: Database with default cluster/node from global settings
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Resource contract tests for the self-cadvisor container."""
2+
3+
import os
4+
5+
import yaml
6+
7+
8+
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
9+
EXPECTED_MEMORY_BYTES = 402653184 # 384 MiB
10+
11+
12+
def _load_yaml(*parts):
13+
with open(os.path.join(PROJECT_ROOT, *parts)) as f:
14+
return yaml.safe_load(f)
15+
16+
17+
def test_docker_compose_cadvisor_resources_match_expected_limits():
18+
compose = _load_yaml('docker-compose.yml')
19+
cadvisor = compose['services']['self-cadvisor']
20+
21+
assert cadvisor['cpus'] == 0.25
22+
assert cadvisor['mem_limit'] == EXPECTED_MEMORY_BYTES
23+
24+
25+
def test_helm_cadvisor_resources_match_expected_requests_and_limits():
26+
values = _load_yaml('postgres_ai_helm', 'values.yaml')
27+
resources = values['cadvisor']['resources']
28+
29+
assert resources['requests'] == {
30+
'cpu': '100m',
31+
'memory': '192Mi',
32+
}
33+
assert resources['limits'] == {
34+
'cpu': '250m',
35+
'memory': '384Mi',
36+
}

0 commit comments

Comments
 (0)