Skip to content

Commit

Permalink
Do not report successful S.M.A.R.T. test starts on SCSI/SAS drives as…
Browse files Browse the repository at this point in the history
… failures
  • Loading branch information
themylogin committed May 10, 2021
1 parent 70a966f commit acd7185
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/middlewared/middlewared/plugins/smart.py
@@ -1,4 +1,4 @@
from datetime import datetime, timezone
from datetime import datetime, timedelta, timezone
import functools
import re
import time
Expand All @@ -18,6 +18,7 @@


RE_TIME = re.compile(r'test will complete after ([a-z]{3} [a-z]{3} [0-9 ]+ \d\d:\d\d:\d\d \d{4})', re.IGNORECASE)
RE_TIME_SCSIPRINT_EXTENDED = re.compile(r'Please wait (\d+) minutes for test to complete')


async def annotate_disk_smart_tests(middleware, devices, disk):
Expand Down Expand Up @@ -435,6 +436,11 @@ async def __manual_test(self, disk):
self.logger.error('Unable to parse expected_result_time: %r', e)
else:
expected_result_time = expected_result_time.astimezone(timezone.utc).replace(tzinfo=None)
elif time_details := re.search(RE_TIME_SCSIPRINT_EXTENDED, result):
expected_result_time = datetime.utcnow() + timedelta(minutes=int(time_details.group(1)))
elif 'Self Test has begun' in result:
# scsiprint.cpp does not always print expected result time
expected_result_time = datetime.utcnow() + timedelta(minutes=1)

if expected_result_time:
output['expected_result_time'] = expected_result_time
Expand Down

0 comments on commit acd7185

Please sign in to comment.