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 2022/08/23 13:26:01 UTC
[incubator-datalab] branch DATALAB-2648 updated: [DATALAB-2648]: added usage of full image name during image termination on aws and azure instead of notebook image name, now status terminated is returned if image already does not exist when it`s removal is executed
This is an automated email from the ASF dual-hosted git repository.
lfrolov pushed a commit to branch DATALAB-2648
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/DATALAB-2648 by this push:
new 88f9b032e [DATALAB-2648]: added usage of full image name during image termination on aws and azure instead of notebook image name, now status terminated is returned if image already does not exist when it`s removal is executed
88f9b032e is described below
commit 88f9b032e1533c2d480357459e588413b1a77b4f
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Tue Aug 23 16:25:50 2022 +0300
[DATALAB-2648]: added usage of full image name during image termination on aws and azure instead of notebook image name, now status terminated is returned if image already does not exist when it`s removal is executed
---
.../scripts/aws/common_terminate_notebook_image.py | 23 +++++++++++++++-------
.../azure/common_terminate_notebook_image.py | 20 +++++++++++++------
.../scripts/gcp/common_terminate_notebook_image.py | 14 ++++++-------
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py b/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py
index e076c5111..98d6dfa92 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py
@@ -32,17 +32,26 @@ if __name__ == "__main__":
try:
datalab.actions_lib.create_aws_config_files()
image_conf = dict()
- image_conf['full_image_name'] = os.environ['notebook_image_name']
-
+ image_conf['service_base_name'] = os.environ['conf_service_base_name'] = datalab.fab.replace_multi_symbols(
+ os.environ['conf_service_base_name'][:20], '-', True)
+ image_conf['project_name'] = os.environ['project_name']
+ image_conf['endpoint_name'] = os.environ['endpoint_name']
+ image_conf['application'] = os.environ['application']
+ image_conf['image_name'] = os.environ['notebook_image_name']
+ image_conf['full_image_name'] = '{}-{}-{}-{}-{}'.format(image_conf['service_base_name'],
+ image_conf['project_name'],
+ image_conf['endpoint_name'],
+ image_conf['application'],
+ image_conf['image_name'])
image_id = datalab.meta_lib.get_ami_id_by_name(image_conf['full_image_name'], 'available')
if image_id != '':
datalab.actions_lib.deregister_image(image_conf['full_image_name'])
- with open("/root/result.json", 'w') as result:
- res = {"notebook_image_name": image_conf['full_image_name'],
- "status": "terminated",
- "Action": "Delete existing notebook image"}
- result.write(json.dumps(res))
+ with open("/root/result.json", 'w') as result:
+ res = {"notebook_image_name": image_conf['full_image_name'],
+ "status": "terminated",
+ "Action": "Delete existing notebook image"}
+ result.write(json.dumps(res))
except Exception as err:
datalab.fab.append_result("Failed to delete existing notebook image", str(err))
sys.exit(1)
diff --git a/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py b/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py
index 295ecab5c..0ef0d4e54 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py
@@ -35,17 +35,25 @@ if __name__ == "__main__":
image_conf = dict()
image_conf['service_base_name'] = os.environ['conf_service_base_name']
image_conf['resource_group_name'] = os.environ['azure_resource_group_name']
- image_conf['full_image_name'] = os.environ['notebook_image_name']
+ image_conf['project_name'] = os.environ['project_name']
+ image_conf['endpoint_name'] = os.environ['endpoint_name']
+ image_conf['application'] = os.environ['application']
+ image_conf['image_name'] = os.environ['notebook_image_name']
+ image_conf['full_image_name'] = '{}-{}-{}-{}-{}'.format(image_conf['service_base_name'],
+ image_conf['project_name'],
+ image_conf['endpoint_name'],
+ image_conf['application'],
+ image_conf['image_name'])
image = AzureMeta.get_image(image_conf['resource_group_name'], image_conf['full_image_name'])
if image != '':
AzureActions.remove_image(image_conf['resource_group_name'], image_conf['full_image_name'])
- with open("/root/result.json", 'w') as result:
- res = {"notebook_image_name": image_conf['full_image_name'],
- "status": "terminated",
- "Action": "Delete existing notebook image"}
- result.write(json.dumps(res))
+ with open("/root/result.json", 'w') as result:
+ res = {"notebook_image_name": image_conf['full_image_name'],
+ "status": "terminated",
+ "Action": "Delete existing notebook image"}
+ result.write(json.dumps(res))
except Exception as err:
datalab.fab.append_result("Failed to delete existing notebook image", str(err))
sys.exit(1)
diff --git a/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py b/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py
index a448841e8..c1e774838 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py
@@ -48,13 +48,13 @@ if __name__ == "__main__":
os.environ['application'], image_conf['image_name']).lower()
primary_image_id = GCPMeta.get_image_by_name(image_conf['expected_primary_image_name'])
if primary_image_id != '':
- GCPActions.remove_image(notebook_config['expected_primary_image_name'])
- GCPActions.remove_image(notebook_config['expected_secondary_image_name'])
- with open("/root/result.json", 'w') as result:
- res = {"notebook_image_name": image_conf['full_image_name'],
- "status": "terminated",
- "Action": "Delete existing notebook image"}
- result.write(json.dumps(res))
+ GCPActions.remove_image(image_conf['expected_primary_image_name'])
+ GCPActions.remove_image(image_conf['expected_secondary_image_name'])
+ with open("/root/result.json", 'w') as result:
+ res = {"notebook_image_name": image_conf['expected_primary_image_name'],
+ "status": "terminated",
+ "Action": "Delete existing notebook image"}
+ result.write(json.dumps(res))
except Exception as err:
datalab.fab.append_result("Failed to delete existing notebook image", str(err))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org