Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
2Shirt 2021-04-09 03:08:19 -06:00
commit a42d5e06f4
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -172,7 +172,7 @@ class State():
self.panes.pop(key)
def disk_safety_checks(self, prep=False, wait_for_self_tests=True):
# pylint: disable=too-many-branches
# pylint: disable=too-many-branches,too-many-statements
"""Run disk safety checks."""
self_tests_in_progress = False
for disk in self.disks:
@ -190,6 +190,13 @@ class State():
if 'Disk Attributes' in disk.tests:
disk.tests['Disk Attributes'].failed = True
disk.tests['Disk Attributes'].set_status('Failed')
if not prep:
# Mid-diag failure detected
LOG.warning('Critical hardware error detected during diagnostics')
disk.add_note(
'Critical hardware error detected during diagnostics',
'YELLOW',
)
except hw_obj.SMARTSelfTestInProgressError as err:
if prep:
std.print_warning(f'SMART self-test(s) in progress for {disk.path}')
@ -212,15 +219,32 @@ class State():
std.color_string('Please manually review SMART data', 'YELLOW'),
)
else:
# No blocking errors encountered, check for minor attribute failures
if ('Disk Attributes' in disk.tests
if (
'Disk Attributes' in disk.tests
and not disk.tests['Disk Attributes'].failed
and not disk.check_attributes(only_blocking=False)):
# Mid-diag failure detected
LOG.warning('Disk attributes failure detected during diagnostics')
and not disk.check_attributes(only_blocking=False)
):
# No blocking errors encountered, but found minor attribute failures
if not prep:
# Mid-diag failure detected
LOG.warning('Attribute(s) failure detected during diagnostics')
disk.add_note(
'Attribute(s) failure detected during diagnostics',
'YELLOW',
)
disk.tests['Disk Attributes'].failed = True
disk.tests['Disk Attributes'].set_status('Failed')
# Check Surface Scan
if (
'Disk Surface Scan' in disk.tests
and disk.tests['Disk Surface Scan'].failed
and 'Disk I/O Benchmark' in disk.tests
):
# Disable I/O Benchmark test
disk.tests['Disk I/O Benchmark'].set_status('Skipped')
disk.tests['Disk I/O Benchmark'].disabled = True
# Disable tests if necessary
if disable_tests:
disk.disable_disk_tests()
@ -1072,7 +1096,7 @@ def disk_self_test(state, test_objects):
def disk_surface_scan(state, test_objects):
# pylint: disable=too-many-statements
# pylint: disable=too-many-branches,too-many-statements
"""Read-only disk surface scan using badblocks."""
LOG.info('Disk Surface Scan (badblocks)')
aborted = False
@ -1138,13 +1162,29 @@ def disk_surface_scan(state, test_objects):
if not (test_obj.passed or test_obj.failed):
test_obj.set_status('Unknown')
# Run surface scans
# Update panes
state.update_top_pane(
f'Disk Surface Scan{"s" if len(test_objects) > 1 else ""}',
)
std.print_info(
f'Starting disk surface scan{"s" if len(test_objects) > 1 else ""}',
)
for disk in state.disks:
failed_attributes = [
line for line in disk.generate_attribute_report() if 'failed' in line
]
if failed_attributes:
size_str = std.bytes_to_string(disk.details["size"], use_binary=False)
std.print_colored(
['[', disk.path.name, ' ', size_str, ']'],
[None, 'BLUE', None, 'CYAN', None],
sep='',
)
#std.print_colored([disk.path.name, disk.description], [None, 'BLUE'])
std.print_report(failed_attributes)
std.print_standard('')
# Run surface scans
for test in reversed(test_objects):
if test.disabled:
# Skip