try and cleanup failed deployment before exiting
@@ -102,9 +102,16 @@ def deploy_app_gae(yaml):
logging.info(yaml)
deploy_command.append(yaml)
+ try:
test_util.execute_command(deploy_command, True)
return (deployed_version,
test_util.retrieve_url_for_version(deployed_version))
+ except subprocess.CalledProcessError as e:
+ try:
+ stop_version(deployed_version)
+ except Exception:
+ pass
+ raise e
def deploy_app_gke(yaml):
@@ -131,6 +138,8 @@ def deploy_app_gke(yaml):
deploy_command = ['kubectl', 'apply', '-f', '-',
'--namespace', namespace]
+
+ try:
test_util.execute_command(deploy_command, True,
template.GKE_TEMPLATE.format(
service_name=service_name,
@@ -138,6 +147,12 @@ def deploy_app_gke(yaml):
return namespace, test_util.get_external_ip_for_cluster(service_name,
namespace)
+ except subprocess.CalledProcessError as e:
+ try:
+ stop_deployment(namespace)
+ except Exception:
+ pass
+ raise e
def deploy_app(appdir, environment, base_image=None,
