Skip to content

Commit b089cff

Browse files
committed
bug fix
1 parent 9a59409 commit b089cff

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

nodescraper/plugins/inband/storage/storage_analyzer.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@ def analyze_data(
8282
Returns:
8383
TaskResult: Result of the storage analysis containing the status and message.
8484
"""
85-
if args and (
86-
args.min_required_free_space_abs is None and args.min_required_free_space_prct is None
87-
):
85+
if args is None:
86+
args = StorageAnalyzerArgs(min_required_free_space_prct=10)
87+
elif args.min_required_free_space_abs is None and args.min_required_free_space_prct is None:
8888
args.min_required_free_space_prct = 10
8989
self.logger.warning(
90-
"No defaults provided for storage analyzer arguments. Setting min_required_free_space_prct=10"
90+
"No thresholds provided for storage analyzer arguments; defaulting to 10% free"
9191
)
92-
else:
93-
args = StorageAnalyzerArgs(min_required_free_space_prct=10)
9492

9593
if not data.storage_data:
9694
self.result.message = "No storage data available"

test/unit/plugin/test_storage_analyzer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_both_abs_and_prct_fail(system_info):
8989
args = StorageAnalyzerArgs(min_required_free_space_abs="10GB", min_required_free_space_prct=96)
9090
result = analyzer.analyze_data(model, args)
9191
assert result.status == ExecutionStatus.ERROR
92-
assert "Not enough disk storage!" in result.message
92+
assert "Insufficient disk space" in result.message
9393
assert len(result.events) == 1
9494
assert any(e.category == EventCategory.STORAGE.value for e in result.events)
9595
assert any(e.priority == EventPriority.CRITICAL for e in result.events)
@@ -109,6 +109,8 @@ def test_device_filter(analyzer, model_obj):
109109
assert result.status == ExecutionStatus.ERROR
110110
assert len(result.events) == 1
111111

112-
args2 = StorageAnalyzerArgs(min_required_free_space_prct="20", ignore_devices=["some_device"])
112+
args2 = StorageAnalyzerArgs(
113+
min_required_free_space_prct="20", ignore_devices=["some_device"], regex_match=True
114+
)
113115
result2 = analyzer.analyze_data(model_obj, args2)
114116
assert result2.status == ExecutionStatus.OK

0 commit comments

Comments
 (0)