Skip to content
Merged
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
4 changes: 2 additions & 2 deletions snap/hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ cp /var/lib/snapd/hostfs/etc/os-release $SNAP_COMMON/etc/os-release


# see snap/local/scripts/run_sos.sh for why this uses 'nsenter -t 1 -m'
if ! nsenter -t 1 -m -- snap list sosreport >/dev/null 2>&1; then
nsenter -t 1 -m -- snap install --classic sosreport || true
if ! nsenter -t 1 -m -- /usr/bin/snap list sosreport >/dev/null 2>&1; then
nsenter -t 1 -m -- /usr/bin/snap install --classic sosreport || true
fi
4 changes: 2 additions & 2 deletions snap/local/scripts/run_sos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ if ! nsenter -t 1 -m -- which apt 2>&1 > /dev/null; then
exit 1
fi

if ! nsenter -t 1 -m -- snap list sosreport >/dev/null 2>&1; then
if ! nsenter -t 1 -m -- /usr/bin/snap list sosreport >/dev/null 2>&1; then
echo "sosreport snap not found on host, installing it now..." >&2
nsenter -t 1 -m -- snap install --classic sosreport
nsenter -t 1 -m -- /usr/bin/snap install --classic sosreport
fi

exec nsenter -t 1 -m -- /snap/bin/sosreport.sos "$@"
6 changes: 3 additions & 3 deletions src/bugit_v2/dut_utils/info_getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from collections import Counter

from bugit_v2.checkbox_utils.checkbox_exec import get_checkbox_info
from bugit_v2.utils import is_snap
from bugit_v2.utils.async_subprocess import asp_check_output, asp_run
from bugit_v2.utils.constants import NSENTER_PREFIX


async def get_thinkpad_ec_version(timeout: int | None = 30) -> str | None:
Expand Down Expand Up @@ -165,8 +165,8 @@ async def ec():
try:
nvidia_log = await asp_run(
[
("/var/lib/snapd/hostfs/usr/bin/" if is_snap() else "")
+ "nvidia-smi",
*NSENTER_PREFIX,
"nvidia-smi",
"-q",
],
timeout=command_timeout,
Expand Down
29 changes: 8 additions & 21 deletions src/bugit_v2/dut_utils/log_collectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
from bugit_v2.models.bug_report import BugReport, LogName
from bugit_v2.utils import host_is_ubuntu_core, is_snap
from bugit_v2.utils.async_subprocess import asp_check_call, asp_check_output
from bugit_v2.utils.constants import HOST_FS, MAX_JOB_OUTPUT_LEN
from bugit_v2.utils.constants import (
HOST_FS,
MAX_JOB_OUTPUT_LEN,
NSENTER_PREFIX,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,13 +87,7 @@ async def nvidia_bug_report(
) -> str:
return await asp_check_output(
[
"sudo",
"--non-interactive",
"nsenter",
"--target",
"1",
"--mount",
"--",
*NSENTER_PREFIX,
"nvidia-bug-report.sh",
"--extra-system-data",
"--output-file",
Expand Down Expand Up @@ -260,12 +258,7 @@ async def oem_getlogs(
pass
await asp_check_output(
[
"sudo",
"--non-interactive",
"nsenter",
"--target",
"1",
"--mount",
*(NSENTER_PREFIX[:-1]), # remove the '--' first
# must switch cwd after entering namespace
f"--wdns={target_dir.absolute()}",
"--",
Expand All @@ -285,13 +278,7 @@ async def sosreport(
assert target_dir.exists(), f"Target directory {target_dir} does not exist"
await asp_check_call(
[
"sudo",
"--non-interactive",
"nsenter",
"--target",
"1",
"--mount",
"--",
*NSENTER_PREFIX,
"env",
"HWLOC_COMPONENTS=-gl",
"/snap/bin/sosreport.sos",
Expand Down