diff --git a/lib/backend.py b/lib/backend.py index 389d4ed35f0b7769144d2407519358663b9d1eb8..709f1c9faddd0eca78d3e09a785b0aaf1dc851d0 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -723,9 +723,12 @@ def RunRenameInstance(instance, old_name): if result.failed: logging.error("os create command '%s' returned error: %s output: %s", result.cmd, result.fail_reason, result.output) - return False + lines = [val.encode("string_escape") + for val in utils.TailFile(logfile, lines=20)] + return (False, "OS rename script failed (%s), last lines in the" + " log file:\n%s" % (result.fail_reason, "\n".join(lines))) - return True + return (True, "Rename successful") def _GetVGInfo(vg_name): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index dc092a5eeab2d8a6ab827c02e48603b07ac6893b..f1b4ab226e4885ac565228ec26bb7886ca203ae0 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2973,10 +2973,11 @@ class LURenameInstance(LogicalUnit): try: result = self.rpc.call_instance_run_rename(inst.primary_node, inst, old_name) - if result.failed or not result.data: + msg = result.RemoteFailMsg() + if msg: msg = ("Could not run OS rename script for instance %s on node %s" - " (but the instance has been renamed in Ganeti)" % - (inst.name, inst.primary_node)) + " (but the instance has been renamed in Ganeti): %s" % + (inst.name, inst.primary_node, msg)) self.proc.LogWarning(msg) finally: _ShutdownInstanceDisks(self, inst)