Return the correct error code in the post-upgrade script
authorHrvoje Ribicic <riba@google.com>
Mon, 2 Nov 2015 17:19:22 +0000 (17:19 +0000)
committerHrvoje Ribicic <riba@google.com>
Mon, 2 Nov 2015 17:26:36 +0000 (18:26 +0100)
While we want all the post-upgrade actions to be undertaken, should one
of these fail, the correct error code should be returned so that the
upgrade script can report issues.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Oleg Ponomarev <oponomarev@google.com>

tools/post-upgrade

index 4ab460d..d625360 100644 (file)
@@ -51,13 +51,17 @@ def main():
 
   version = utils.version.ParseVersion(versionstring)
 
+  error_code = 0
+
   if utils.version.IsBefore(version, 2, 12, 5):
     result = utils.RunCmd(["gnt-cluster", "renew-crypto",
                            "--new-node-certificates", "-f"])
     if result.failed:
       cli.ToStderr("Failed to create node certificates: %s; Output %s" %
                    (result.fail_reason, result.output))
-  return 0
+      error_code = 1
+
+  return error_code
 
 if __name__ == "__main__":
   exit(main())