Skip to content

Commit c0ec18d

Browse files
committed
ft-orchestration use cgroups to controll memory usage of probe processes
1 parent 2940863 commit c0ec18d

6 files changed

Lines changed: 313 additions & 9 deletions

File tree

tools/ft-orchestration/src/probe/cento.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
from lbr_testsuite.executable import (
1717
Executor,
1818
Tool,
19-
Daemon,
2019
ExecutableProcessError,
2120
)
21+
from src.probe.process_group import Daemon
2222
from src.stats.merged import MergedStats
2323
from src.probe.probe_target import ProbeTarget
2424

@@ -109,6 +109,8 @@ def __init__(
109109
mtu: int = 2048,
110110
sudo: bool = False,
111111
cache_size=None,
112+
mem_limit=None,
113+
cpu_limit=None,
112114
**kwargs: dict,
113115
):
114116
interfaces_names = [ifc.name for ifc in interfaces]
@@ -136,6 +138,8 @@ def __init__(
136138
self._settings: CentoSettings = settings
137139
self._mtu = mtu
138140
self._target = target
141+
self._cpu_limit = cpu_limit
142+
self._mem_limit = mem_limit
139143

140144
assert_tool_is_installed("cento", executor)
141145
if self._zero_copy:
@@ -287,7 +291,13 @@ def start(self):
287291

288292
self._before_start()
289293

290-
self._process = Daemon(self._cmd, executor=self._executor, sudo=self._sudo)
294+
self._process = Daemon(
295+
self._cmd,
296+
cpu_limit=self._cpu_limit,
297+
mem_limit=self._mem_limit,
298+
executor=self._executor,
299+
sudo=self._sudo,
300+
)
291301
# stderr is implicitly redirected to stdout
292302
self._process.set_outputs(self._log_file)
293303
self._process.start()

tools/ft-orchestration/src/probe/ipfixprobe.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from typing import Dict, List, Optional, Tuple
1919

2020
from lbr_testsuite.executable import (
21-
Daemon,
2221
Executor,
2322
Tool,
2423
)
24+
from src.probe.process_group import Daemon
2525
from src.common.required_field import required_field
2626
from src.common.tool_is_installed import assert_tool_is_installed
2727
from src.common.typed_dataclass import bool_convertor, typed_dataclass
@@ -353,6 +353,8 @@ def __init__(
353353
verbose: bool = False,
354354
settings: IpfixprobeSettings = None,
355355
sudo: bool = False,
356+
mem_limit=None,
357+
cpu_limit=None,
356358
):
357359
"""Init ipfixprobe connector.
358360
@@ -389,6 +391,8 @@ def __init__(
389391
self._enabled_plugins = []
390392
self._last_run_stats = None
391393
self._timeouts = (settings.active_timeout, settings.inactive_timeout)
394+
self._cpu_limit = cpu_limit
395+
self._mem_limit = mem_limit
392396

393397
assert_tool_is_installed("ipfixprobe", executor)
394398
self._cmd = self._prepare_cmd(target, protocols, settings)
@@ -445,6 +449,8 @@ def start(self) -> None:
445449
executor=self._executor,
446450
sudo=self._sudo,
447451
failure_verbosity="no-exception",
452+
cpu_limit=self._cpu_limit,
453+
mem_limit=self._mem_limit,
448454
)
449455
# stderr is implicitly redirected to stdout
450456
self._process.set_outputs(self._log_file)

tools/ft-orchestration/src/probe/nprobe.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from lbr_testsuite.executable import (
2020
Executor,
2121
Tool,
22-
Daemon,
2322
ExecutableProcessError,
2423
)
24+
from src.probe.process_group import Daemon
2525
from src.stats.merged import MergedStats
2626
from src.probe.probe_target import ProbeTarget
2727

@@ -118,6 +118,8 @@ def __init__(
118118
mtu: int = 2048,
119119
sudo: bool = False,
120120
cache_size=None,
121+
mem_limit=None,
122+
cpu_limit=None,
121123
**kwargs: dict,
122124
):
123125
interfaces_names = [ifc.name for ifc in interfaces]
@@ -145,6 +147,8 @@ def __init__(
145147
self._mtu = mtu
146148
self._target = target
147149
self._protocols = protocols
150+
self._cpu_limit = cpu_limit
151+
self._mem_limit = mem_limit
148152

149153
assert_tool_is_installed("nprobe", executor)
150154
if self._zero_copy:
@@ -304,7 +308,13 @@ def start(self):
304308
if self._settings.rss_queues > 1:
305309
settings.interface = f"{settings.interface}@{i}"
306310
cmd = self._prepare_cmd(self._target, self._protocols, settings)
307-
process = Daemon(cmd, executor=executors[i], sudo=self._sudo)
311+
process = Daemon(
312+
cmd,
313+
executor=executors[i],
314+
sudo=self._sudo,
315+
cpu_limit=self._cpu_limit,
316+
mem_limit=self._mem_limit,
317+
)
308318
self._processes.append(process)
309319
log_file = Path(self._local_workdir, f"nprobe_{i}.log")
310320
self._log_files.append(log_file)

tools/ft-orchestration/src/probe/pmacct.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
from typing import List, Optional
1010

1111
from lbr_testsuite.executable import (
12-
Daemon,
1312
ExecutableProcessError,
1413
Executor,
1514
Rsync,
1615
Tool,
1716
)
17+
from src.probe.process_group import Daemon
1818
from src.common.tool_is_installed import assert_tool_is_installed
1919
from src.common.typed_dataclass import typed_dataclass
2020
from src.common.utils import duplicate_executor
@@ -83,6 +83,8 @@ def __init__(
8383
cache_size=None,
8484
rss_queues: int = 1,
8585
binary: str = "pmacctd",
86+
mem_limit=None,
87+
cpu_limit=None,
8688
**kwargs: dict,
8789
):
8890
# initialize PmacctSettings and map FlowTest values to pmacct values
@@ -143,6 +145,8 @@ def __init__(
143145
self._mtu = mtu
144146
self._sudo = sudo
145147
self._binary = binary
148+
self._cpu_limit = cpu_limit
149+
self._mem_limit = mem_limit
146150

147151
assert_tool_is_installed(self._binary, executor)
148152

@@ -249,7 +253,13 @@ def start(self):
249253
time.sleep(2)
250254
self._before_start()
251255

252-
self._process = Daemon(self._cmd, executor=self._executor, sudo=self._sudo)
256+
self._process = Daemon(
257+
self._cmd,
258+
executor=self._executor,
259+
sudo=self._sudo,
260+
cpu_limit=self._cpu_limit,
261+
mem_limit=self._mem_limit,
262+
)
253263
# stderr is implicitly redirected to stdout
254264
self._process.set_outputs(self._log_file)
255265
self._process.start()

0 commit comments

Comments
 (0)