Merge "Do not fail when called on an invalid device"

This commit is contained in:
Zuul 2019-03-13 17:31:54 +00:00 committed by Gerrit Code Review
commit 04802babc5
1 changed files with 5 additions and 1 deletions

View File

@ -211,9 +211,13 @@ def should_enable_discard(devices):
if (device.startswith("/dev/nvme") or
device.startswith("/dev/vd")):
continue
try:
sata_3_or_less = is_sata30orless(device)
except subprocess.CalledProcessError:
sata_3_or_less = True
if (device.startswith("/dev/") and
os.path.exists(device) and
is_sata30orless(device)):
sata_3_or_less):
discard_enable = False
log("SSD Discard autodetection: {} is forcing discard off"
"(sata <= 3.0)".format(device), level=WARNING)