Skip to content

Commit 705a61e

Browse files
committed
Logging warning when user is missing group so its not an error
1 parent 555aba8 commit 705a61e

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

nodescraper/plugins/inband/amdsmi/amdsmi_collector.py

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,58 @@ def _run_amd_smi(self, cmd: str) -> Optional[str]:
9999
Optional[str]: stdout from command or None on error
100100
"""
101101
cmd_ret = self._run_sut_cmd(f"{self.AMD_SMI_EXE} {cmd}")
102+
103+
# Check for known warnings that can be ignored
104+
is_group_warning = (
105+
"User is missing the following required groups" in cmd_ret.stderr
106+
or "User is missing the following required groups" in cmd_ret.stdout
107+
)
108+
109+
# Log warning if user is missing group
102110
if cmd_ret.stderr != "" or cmd_ret.exit_code != 0:
103-
self._log_event(
104-
category=EventCategory.APPLICATION,
105-
description="Error running amd-smi command",
106-
data={
107-
"command": cmd,
108-
"exit_code": cmd_ret.exit_code,
109-
"stderr": cmd_ret.stderr,
110-
},
111-
priority=EventPriority.ERROR,
112-
console_log=True,
113-
)
114-
return None
115-
return cmd_ret.stdout
111+
if not is_group_warning:
112+
self._log_event(
113+
category=EventCategory.APPLICATION,
114+
description="Error running amd-smi command",
115+
data={
116+
"command": cmd,
117+
"exit_code": cmd_ret.exit_code,
118+
"stderr": cmd_ret.stderr,
119+
},
120+
priority=EventPriority.ERROR,
121+
console_log=True,
122+
)
123+
return None
124+
else:
125+
self._log_event(
126+
category=EventCategory.APPLICATION,
127+
description="amd-smi warning (continuing): User missing required groups",
128+
data={
129+
"command": cmd,
130+
"warning": cmd_ret.stderr or cmd_ret.stdout,
131+
},
132+
priority=EventPriority.WARNING,
133+
console_log=False,
134+
)
135+
136+
stdout = cmd_ret.stdout
137+
if is_group_warning and stdout:
138+
lines = stdout.split("\n")
139+
cleaned_lines = [
140+
line
141+
for line in lines
142+
if not any(
143+
warn in line
144+
for warn in [
145+
"RuntimeError:",
146+
"WARNING: User is missing",
147+
"Please add user to these groups",
148+
]
149+
)
150+
]
151+
stdout = "\n".join(cleaned_lines).strip()
152+
153+
return stdout
116154

117155
def _run_amd_smi_dict(self, cmd: str) -> Optional[Union[dict, list[dict]]]:
118156
"""Run amd-smi command with json output
@@ -132,7 +170,10 @@ def _run_amd_smi_dict(self, cmd: str) -> Optional[Union[dict, list[dict]]]:
132170
self._log_event(
133171
category=EventCategory.APPLICATION,
134172
description=f"Error parsing command: `{cmd}` json data",
135-
data={"cmd": cmd, "exception": get_exception_traceback(e)},
173+
data={
174+
"cmd": cmd,
175+
"exception": get_exception_traceback(e),
176+
},
136177
priority=EventPriority.ERROR,
137178
console_log=True,
138179
)

0 commit comments

Comments
 (0)