You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by lf...@apache.org on 2020/07/13 16:18:35 UTC

[incubator-dlab] 01/01: [DLAB-1940]: added check of endpoint name during AMI deregistering

This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a commit to branch DLAB-1940
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 6c7a0cfa0b49b6f0ff1ed70a58ed1470c4725008
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Mon Jul 13 19:14:57 2020 +0300

    [DLAB-1940]: added check of endpoint name during AMI deregistering
---
 .../src/general/scripts/aws/project_terminate.py                  | 6 +++---
 .../src/general/scripts/azure/project_terminate.py                | 8 ++++----
 .../src/general/scripts/gcp/project_terminate.py                  | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py b/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py
index 3495b13..9243ff5 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py
@@ -34,7 +34,7 @@ import boto3
 import requests
 
 
-def terminate_edge_node(tag_name, project_name, tag_value, nb_sg, edge_sg, de_sg, emr_sg, endpoint_name):
+def terminate_edge_node(tag_name, project_name, tag_value, nb_sg, edge_sg, de_sg, emr_sg, endpoint_name, service_base_name):
     print('Terminating EMR cluster')
     try:
         clusters_list = dlab.meta_lib.get_emr_list(tag_name)
@@ -77,7 +77,7 @@ def terminate_edge_node(tag_name, project_name, tag_value, nb_sg, edge_sg, de_sg
 
     print("Deregistering project specific notebook's AMI")
     try:
-        dlab.actions_lib.deregister_image(project_name)
+        dlab.actions_lib.deregister_image('{}-{}-{}-*'.format(service_base_name, project_name, endpoint_name))
     except Exception as err:
         dlab.fab.append_result("Failed to deregister images.", str(err))
         sys.exit(1)
@@ -140,7 +140,7 @@ if __name__ == "__main__":
         try:
             terminate_edge_node(project_conf['tag_name'], project_conf['project_name'], project_conf['tag_value'],
                                 project_conf['nb_sg'], project_conf['edge_sg'], project_conf['de_sg'],
-                                project_conf['emr_sg'], project_conf['endpoint_name'])
+                                project_conf['emr_sg'], project_conf['endpoint_name'], project_conf['service_base_name'])
         except Exception as err:
             traceback.print_exc()
             dlab.fab.append_result("Failed to terminate project.", str(err))
diff --git a/infrastructure-provisioning/src/general/scripts/azure/project_terminate.py b/infrastructure-provisioning/src/general/scripts/azure/project_terminate.py
index 765959f..a78480c 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/project_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/project_terminate.py
@@ -33,7 +33,7 @@ import requests
 import traceback
 
 
-def terminate_edge_node(resource_group_name, service_base_name, project_tag, subnet_name, vpc_name):
+def terminate_edge_node(resource_group_name, service_base_name, project_tag, subnet_name, vpc_name, endpoint_name):
     print("Terminating EDGE, notebook and dataengine virtual machines")
     try:
         for vm in AzureMeta.compute_client.virtual_machines.list(resource_group_name):
@@ -115,8 +115,8 @@ def terminate_edge_node(resource_group_name, service_base_name, project_tag, sub
     print("Removing project specific images")
     try:
         for image in AzureMeta.list_images():
-            if service_base_name == image.tags["SBN"] and 'project_tag' in image.tags \
-                    and project_tag == image.tags["project_tag"]:
+            if service_base_name == image.tags["SBN"] and project_tag == image.tags["project_tag"] \
+                    and endpoint_name == image.tags["endpoint_tag"]:
                 AzureActions.remove_image(resource_group_name, image.name)
                 print("Image {} has been removed".format(image.name))
     except Exception as err:
@@ -174,7 +174,7 @@ if __name__ == "__main__":
         try:
             terminate_edge_node(project_conf['resource_group_name'], project_conf['service_base_name'],
                                 project_conf['project_tag'], project_conf['private_subnet_name'],
-                                project_conf['vpc_name'])
+                                project_conf['vpc_name'], project_conf['endpoint_name'])
         except Exception as err:
             traceback.print_exc()
             dlab.fab.append_result("Failed to terminate edge.", str(err))
diff --git a/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py b/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py
index 96c021d..3d795e0 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py
@@ -89,7 +89,7 @@ def terminate_edge_node(endpoint_name, project_name, service_base_name, region,
 
     print("Removing project specific images")
     try:
-        project_image_name_beginning = '{}-{}'.format(service_base_name, project_name)
+        project_image_name_beginning = '{}-{}-{}'.format(service_base_name, project_name, endpoint_name)
         images = GCPMeta.get_list_images(project_image_name_beginning)
         if 'items' in images:
             for i in images['items']:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org