Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hugepages: use tee when writing with sudo #3595

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lisa/tools/hugepages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from assertpy import assert_that

from lisa.executable import Tool
from lisa.tools.echo import Echo
from lisa.tools.free import Free
from lisa.tools.ls import Ls
from lisa.tools.lscpu import Lscpu
from lisa.tools.mkfs import FileSystem
from lisa.tools.mount import Mount
from lisa.tools.tee import Tee
from lisa.util import NotEnoughMemoryException, UnsupportedOperationException

PATTERN_HUGEPAGE = re.compile(
Expand Down Expand Up @@ -68,7 +68,7 @@ def get_hugepage_sizes_in_kb(self) -> Set[int]:
def _enable_hugepages(
self, hugepage_size_kb: HugePageSize, request_space_kb: int
) -> None:
echo = self.node.tools[Echo]
tee = self.node.tools[Tee]
meminfo = self.node.tools[Free]
numa_nodes = self.node.tools[Lscpu].get_numa_node_count()
# ask for enough space, note that we enable pages per numa node
Expand All @@ -92,7 +92,7 @@ def _enable_hugepages(
# nr_hugepages will be written with the number calculated
# based on 2MB hugepages if not specified, subject to change
# this based on further discussion
echo.write_to_file(
tee.write_to_file(
f"{pages_per_numa_node}",
self.node.get_pure_path(
f"/sys/devices/system/node/node{i}/hugepages/"
Expand Down
9 changes: 8 additions & 1 deletion lisa/tools/tee.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ def write_to_file(
if sudo:
cmd = f"sudo {cmd}"
cmd = f"{cmd} {str(file)}"
self.node.execute(f"echo '{value}' | {cmd}", shell=True)
self.node.execute(
f"echo '{value}' | {cmd}",
shell=True,
expected_exit_code=0,
expected_exit_code_failure_message=(
f"Could not write {value} to file {str(file)}"
),
)
Loading