diff --git a/lib/bdev.py b/lib/bdev.py index 40c75c31bdb08336e5f0b4bea46f51b6ebb4ab57..f3e5fc155ae706279cb9dc0ed01f56d0cc10e3c1 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -2821,7 +2821,7 @@ def _ExtStorageAction(action, unique_id, ext_params, size=None, grow=None): create_env = _ExtStorageEnvironment(unique_id, ext_params, size, grow) # Do not use log file for action `attach' as we need - # to get the outpout from RunResult + # to get the output from RunResult # TODO: find a way to have a log file for attach too logfile = None if action is not constants.ES_ACTION_ATTACH: @@ -2839,11 +2839,18 @@ def _ExtStorageAction(action, unique_id, ext_params, size=None, grow=None): " error: %s, logfile: %s, output: %s", action, result.cmd, result.fail_reason, logfile, result.output) - lines = [utils.SafeEncode(val) - for val in utils.TailFile(logfile, lines=20)] - _ThrowError("External storage's %s script failed (%s), last" - " lines in the log file:\n%s", - action, result.fail_reason, "\n".join(lines)) + + # If logfile is 'None' (during attach), it breaks TailFile + # TODO: have a log file for attach too + if action is not constants.ES_ACTION_ATTACH: + lines = [utils.SafeEncode(val) + for val in utils.TailFile(logfile, lines=20)] + _ThrowError("External storage's %s script failed (%s), last" + " lines in the log file:\n%s", + action, result.fail_reason, "\n".join(lines)) + else: + _ThrowError("External storage's %s script failed (%s)", + action, result.fail_reason) if action == constants.ES_ACTION_ATTACH: return result.stdout