By logging with the exception function instead of the error function,
and showing the error content without the stack trace unless explicitly
debugging.
Signed-off-by: Gerard Oskamp <gjo@google.com>
Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
f(self)
except BaseException, e:
msg = "%s failed:\n%s" % (description or f.func_name, e)
- logging.error(msg)
+ logging.exception(msg)
self.config_data = safety
self.errors.append(msg)
return wrapped
if config_revision != 0:
logging.warning("Config revision is %s, not 0", config_revision)
if not self.UpgradeAll():
- raise Error("Upgrade failed:\n%s", '\n'.join(self.errors))
+ raise Error("Upgrade failed:\n%s" % '\n'.join(self.errors))
elif config_major == TARGET_MAJOR and config_minor == TARGET_MINOR:
logging.info("No changes necessary")
"""
-from ganeti.tools.cfgupgrade import CfgUpgrade, ParseOptions
+from ganeti.tools.cfgupgrade import CfgUpgrade, Error, ParseOptions
if __name__ == "__main__":
opts, args = ParseOptions()
- CfgUpgrade(opts, args).Run()
+ try:
+ CfgUpgrade(opts, args).Run()
+ except Error as e:
+ if opts.debug:
+ # If debugging, we want to see the original stack trace.
+ raise
+ else:
+ # Else silence it for the sake of convenience.
+ raise SystemExit(e)