summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authortmartins <thigm85@gmail.com>2020-09-01 11:06:54 +0200
committertmartins <thigm85@gmail.com>2020-09-01 11:06:54 +0200
commit9891a14ba87f40e2593a619468a372727f9f9e4a (patch)
tree24481e2c59bcf30e8cd262f3af516cb98bc45a6f /python
parent76f9207ca0595a29e60b5e2ae7eaac571d8d9319 (diff)
simplify if block with status_message dict
Diffstat (limited to 'python')
-rw-r--r--python/vespa/vespa/package.py43
1 files changed, 15 insertions, 28 deletions
diff --git a/python/vespa/vespa/package.py b/python/vespa/vespa/package.py
index 4ee74178280..3586ce073b9 100644
--- a/python/vespa/vespa/package.py
+++ b/python/vespa/vespa/package.py
@@ -687,40 +687,27 @@ class VespaCloud(object):
self._print_log_entry(step, entry)
last = update.get("lastId", last)
+ fail_status_message = {
+ "error": "Unexpected error during deployment; see log for details",
+ "aborted": "Deployment was aborted, probably by a newer deployment",
+ "outOfCapacity": "No capacity left in zone; please contact the Vespa team",
+ "deploymentFailed": "Deployment failed; see log for details",
+ "installationFailed": "Installation failed; see Vespa log for details",
+ "running": "Deployment not completed",
+ "endpointCertificateTimeout": "Endpoint certificate not ready in time; please contact Vespa team",
+ "testFailure": "Unexpected status; tests are not run for manual deployments",
+ }
+
if update["active"]:
return "active", last
else:
status = update["status"]
if status == "success":
return "success", last
- elif status == "error":
- raise RuntimeError(
- "Unexpected error during deployment; see log for details"
- )
- elif status == "aborted":
- raise RuntimeError(
- "Deployment was aborted, probably by a newer deployment"
- )
- elif status == "outOfCapacity":
- raise RuntimeError(
- "No capacity left in zone; please contact the Vespa team"
- )
- elif status == "deploymentFailed":
- raise RuntimeError("Deployment failed; see log for details")
- elif status == "installationFailed":
- raise RuntimeError("Installation failed; see Vespa log for details")
- elif status == "running":
- raise RuntimeError("Deployment not completed")
- elif status == "endpointCertificateTimeout":
- raise RuntimeError(
- "Endpoint certificate not ready in time; please contact Vespa team"
- )
- elif status == "testFailure":
- raise RuntimeError(
- "Unexpected status; tests are not run for manual deployments"
- )
+ elif status in fail_status_message.keys():
+ raise RuntimeError(fail_status_message[status])
else:
- raise RuntimeError("Unexpected status '" + status + "'")
+ raise RuntimeError("Unexpected status: {}".format(status))
def _follow_deployment(self, instance: str, job: str, run: int) -> None:
last = -1
@@ -735,7 +722,7 @@ class VespaCloud(object):
elif status == "success":
return
else:
- raise NotImplementedError
+ raise RuntimeError("Unexpected status: {}".format(status))
@staticmethod
def _print_log_entry(step: str, entry: dict):