Skip to content

Commit 994200e

Browse files
authored
Merge pull request #7 from amd/bugfix/dkms_analyzer
Bugfix: DKMS analysis args
2 parents 66d7d58 + ccdfeb0 commit 994200e

File tree

18 files changed

+50
-9
lines changed

18 files changed

+50
-9
lines changed

nodescraper/cli/inputargtypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def process_file_arg(self, file_path: str) -> TModelType:
104104
return self.model(**data)
105105
except ValidationError as e:
106106
raise argparse.ArgumentTypeError(
107-
f"Validation errors when processing {file_path}: {e.errors()}"
107+
f"Validation errors when processing {file_path}: {e.errors(include_url=False)}"
108108
) from e
109109

110110

nodescraper/interfaces/dataanalyzertask.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ def wrapper(
7676
if not analyze_arg_model:
7777
raise ValueError("No model defined for analysis args")
7878
args = analyze_arg_model(**args) # type: ignore
79-
8079
func(analyzer, data, args)
8180
except ValidationError as exception:
8281
analyzer._log_event(
8382
category=EventCategory.RUNTIME,
8483
description="Validation error during analysis",
85-
data=get_exception_traceback(exception),
84+
data={"errors": exception.errors(include_url=False)},
8685
priority=EventPriority.CRITICAL,
8786
console_log=True,
8887
)

nodescraper/interfaces/datacollectortask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from nodescraper.interfaces.task import SystemCompatibilityError, Task
4242
from nodescraper.models import DataModel, SystemInfo, TaskResult
4343
from nodescraper.typeutils import TypeUtils
44-
from nodescraper.utils import get_exception_details, get_exception_traceback
44+
from nodescraper.utils import get_exception_traceback
4545

4646
from .connectionmanager import TConnection
4747
from .taskresulthook import TaskResultHook
@@ -76,7 +76,7 @@ def wrapper(
7676
collector._log_event(
7777
category=EventCategory.RUNTIME,
7878
description="Pydantic validation error",
79-
data=get_exception_details(exception),
79+
data={"errors": exception.errors(include_url=False)},
8080
priority=EventPriority.CRITICAL,
8181
console_log=True,
8282
)

nodescraper/models/taskresult.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333

3434
from .event import Event
3535

36+
STATUS_LOG_LEVEL_MAP = {
37+
ExecutionStatus.UNSET: logging.INFO,
38+
ExecutionStatus.NOT_RAN: logging.INFO,
39+
ExecutionStatus.OK: logging.INFO,
40+
ExecutionStatus.WARNING: logging.WARNING,
41+
ExecutionStatus.ERROR: logging.ERROR,
42+
ExecutionStatus.EXECUTION_FAILURE: logging.CRITICAL,
43+
}
44+
3645

3746
class TaskResult(BaseModel):
3847
"""Object for result of a task"""
@@ -133,4 +142,9 @@ def finalize(self, logger: Optional[logging.Logger] = None) -> None:
133142
self.message += f" ({event_summary})"
134143

135144
if logger:
136-
logger.log(self.status.value, "(%s) %s", self.__class__.__name__, self.message)
145+
logger.log(
146+
STATUS_LOG_LEVEL_MAP.get(self.status, logging.INFO),
147+
"(%s) %s",
148+
self.parent,
149+
self.message,
150+
)

nodescraper/plugins/inband/bios/analyzer_args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class BiosAnalyzerArgs(BaseModel):
3030
exp_bios_version: list[str] = Field(default_factory=list)
3131
regex_match: bool = False
3232

33+
model_config = {"extra": "forbid"}
34+
3335
@field_validator("exp_bios_version", mode="before")
3436
@classmethod
3537
def validate_exp_bios_version(cls, exp_bios_version: str | list) -> list:

nodescraper/plugins/inband/cmdline/analyzer_args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class CmdlineAnalyzerArgs(BaseModel):
3030
required_cmdline: str | list = Field(default_factory=list)
3131
banned_cmdline: str | list = Field(default_factory=list)
3232

33+
model_config = {"extra": "forbid"}
34+
3335
@field_validator("required_cmdline", mode="before")
3436
@classmethod
3537
def validate_required_cmdline(cls, required_cmdline: str | list) -> list:

nodescraper/plugins/inband/dkms/analyzer_args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26+
from typing import Any
27+
2628
from pydantic import BaseModel, Field, field_validator
2729

2830

@@ -31,6 +33,12 @@ class DkmsAnalyzerArgs(BaseModel):
3133
dkms_version: str | list = Field(default_factory=list)
3234
regex_match: bool = False
3335

36+
model_config = {"extra": "forbid"}
37+
38+
def model_post_init(self, __context: Any) -> None:
39+
if not self.dkms_status and not self.dkms_version:
40+
raise ValueError("At least one of dkms_status or dkms_version must be provided")
41+
3442
@field_validator("dkms_status", mode="before")
3543
@classmethod
3644
def validate_dkms_status(cls, dkms_status: str | list) -> list:

nodescraper/plugins/inband/dkms/dkms_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def analyze_data(
6767
error_state = False
6868

6969
for check, accepted_values in check_map.items():
70+
actual_value = getattr(data, check)
7071
for accepted_value in accepted_values:
71-
actual_value = getattr(data, check)
7272
if args.regex_match:
7373
try:
7474
regex_data = re.compile(accepted_value)

nodescraper/plugins/inband/dmesg/analyzer_args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@
3131
class DmesgAnalyzerArgs(TimeRangeAnalyisArgs):
3232
check_unknown_dmesg_errors: Optional[bool] = True
3333
exclude_category: Optional[set[str]] = None
34+
35+
model_config = {"extra": "forbid"}

nodescraper/plugins/inband/kernel/analyzer_args.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class KernelAnalyzerArgs(BaseModel):
3030
exp_kernel: str | list = Field(default_factory=list)
3131
regex_match: bool = False
3232

33+
model_config = {"extra": "forbid"}
34+
3335
@field_validator("exp_kernel", mode="before")
3436
@classmethod
3537
def validate_exp_kernel(cls, exp_kernel: str | list) -> list:

0 commit comments

Comments
 (0)