You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by lf...@apache.org on 2021/04/21 13:27:53 UTC
[incubator-datalab] 01/01: [DATALAB-1724]: added removal of project
route tables during project termination and in case of failure during
project creation
This is an automated email from the ASF dual-hosted git repository.
lfrolov pushed a commit to branch DATALAB-1724
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit a1eb2bcdc65627f85ff9f39d52c0af51ddc0390b
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Wed Apr 21 16:27:38 2021 +0300
[DATALAB-1724]: added removal of project route tables during project termination and in case of failure during project creation
---
infrastructure-provisioning/src/general/lib/aws/actions_lib.py | 8 ++++++--
.../src/general/scripts/aws/project_prepare.py | 3 +++
.../src/general/scripts/aws/project_terminate.py | 7 +++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/infrastructure-provisioning/src/general/lib/aws/actions_lib.py b/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
index 2f6725b..98837c3 100644
--- a/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
@@ -1323,10 +1323,14 @@ def remove_kernels(emr_name, tag_name, nb_tag_value, ssh_user, key_path, emr_ver
traceback.print_exc(file=sys.stdout)
-def remove_route_tables(tag_name, ssn=False):
+def remove_route_tables(tag_name, ssn=False, tag_value=''):
try:
client = boto3.client('ec2')
- rtables = client.describe_route_tables(Filters=[{'Name': 'tag-key', 'Values': [tag_name]}]).get('RouteTables')
+ if tag_value == '':
+ rtables = client.describe_route_tables(Filters=[{'Name': 'tag-key', 'Values': [tag_name]}]).get('RouteTables')
+ else:
+ rtables = client.describe_route_tables(Filters=[{'Name': 'tag-key', 'Values': [tag_name]},
+ {'Name': 'tag-value', 'Values': [tag_value]}]).get('RouteTables')
for rtable in rtables:
if rtable:
rtable_associations = rtable.get('Associations')
diff --git a/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py b/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py
index 78d497e..3dd3797 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py
@@ -723,4 +723,7 @@ if __name__ == "__main__":
datalab.actions_lib.remove_sgroups(project_conf['notebook_instance_name'])
datalab.actions_lib.remove_sgroups(project_conf['edge_instance_name'])
datalab.actions_lib.remove_s3('edge', project_conf['project_name'])
+ datalab.actions_lib.remove_route_tables("Name", False,
+ '{}-{}-{}-nat-rt'.format(service_base_name, project_name,
+ endpoint_name))
sys.exit(1)
diff --git a/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py b/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py
index 6db396e..01ca47a 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/project_terminate.py
@@ -82,6 +82,13 @@ def terminate_edge_node(tag_name, project_name, tag_value, nb_sg, edge_sg, de_sg
datalab.fab.append_result("Failed to deregister images.", str(err))
sys.exit(1)
+ print("Removing project route tables")
+ try:
+ datalab.actions_lib.remove_route_tables("Name", False, '{}-{}-{}-nat-rt'.format(service_base_name, project_name, endpoint_name))
+ except Exception as err:
+ datalab.fab.append_result("Failed to remove project route table.", str(err))
+ sys.exit(1)
+
print("Removing security groups")
try:
datalab.actions_lib.remove_sgroups(emr_sg)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org