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/03/19 14:11:45 UTC

[incubator-dlab] 01/02: [DLAB-1643]: changed SA and roles termination during project termination

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

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

commit a8c09c6b45dc3ae5347027a3a5c31a6bc51bdfdb
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Thu Mar 19 12:26:25 2020 +0200

    [DLAB-1643]: changed SA and roles termination during project termination
---
 .../src/general/scripts/gcp/project_terminate.py               | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py b/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py
index 0f5b5bf..49d0767 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/project_terminate.py
@@ -53,7 +53,7 @@ def terminate_edge_node(endpoint_name, project_name, service_base_name, region,
 
     print("Terminating EDGE and notebook instances")
     base = '{}-{}-{}'.format(service_base_name, project_name, endpoint_name)
-    keys = ['edge', 'ps', 'static-ip', 'bucket', 'subnet']
+    keys = ['edge', 'ps', 'static-ip', 'bucket', 'subnet', 'edge-sa', 'ps-sa', 'edge-role', 'ps-role']
     targets = ['{}-{}'.format(base, k) for k in keys]
     try:
         instances = GCPMeta.get_list_instances(zone, base)
@@ -104,14 +104,10 @@ def terminate_edge_node(endpoint_name, project_name, service_base_name, region,
         role_targets = ['{}-{}-{}'.format(base, GCPMeta.get_index_by_service_account_name(
             '{}-{}'.format(base, k)), k) for k in keys]
         for service_account in (set(targets) & set(list_service_accounts)):
-            if service_account.startswith(service_base_name) and service_account.endswith('-edge-sa'):
-                GCPActions.remove_service_account(service_account, service_base_name)
-            elif service_account.startswith(service_base_name) and service_account.endswith('-ps-sa'):
-                GCPActions.remove_service_account(service_account, service_base_name)
+            GCPActions.remove_service_account(service_account, service_base_name)
         list_roles_names = GCPMeta.get_list_roles()
         for role in (set(role_targets) & set(list_roles_names)):
-            if role.startswith(service_base_name):
-                GCPActions.remove_role(role)
+            GCPActions.remove_role(role)
     except Exception as err:
         dlab.fab.append_result("Failed to remove service accounts and roles", str(err))
         sys.exit(1)


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