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

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


The following commit(s) were added to refs/heads/DLAB-1539 by this push:
     new c3a6c49  [DLAB-1539]: added user_tag for dataengine
c3a6c49 is described below

commit c3a6c499ddb8273915c213befb44b86fce289930
Author: leonidfrolov <[email protected]>
AuthorDate: Mon Mar 2 16:31:25 2020 +0200

    [DLAB-1539]: added user_tag for dataengine
---
 .../gcp/common_notebook_configure_dataengine-service.py   | 12 +++++++++++-
 .../src/general/scripts/gcp/dataengine-service_prepare.py | 13 ++++++++++++-
 .../src/general/scripts/gcp/dataengine_prepare.py         | 15 +++++++++++++--
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git 
a/infrastructure-provisioning/src/general/scripts/gcp/common_notebook_configure_dataengine-service.py
 
b/infrastructure-provisioning/src/general/scripts/gcp/common_notebook_configure_dataengine-service.py
index 311a805..010fad9 100644
--- 
a/infrastructure-provisioning/src/general/scripts/gcp/common_notebook_configure_dataengine-service.py
+++ 
b/infrastructure-provisioning/src/general/scripts/gcp/common_notebook_configure_dataengine-service.py
@@ -63,17 +63,27 @@ if __name__ == "__main__":
         application = 'jupyter'
     else:
         application = os.environ['application']
+    additional_tags = json.loads(os.environ['tags'].replace("': u'", "\": 
\"").replace("', u'", "\", \"").replace("{u'", "{\"" ).replace("'}", "\"}"))
+
+    if '@' in additional_tags['user_tag']:
+        notebook_config['user_tag'] = 
additional_tags['user_tag'][:additional_tags['user_tag'].find('@')]
+    else:
+        notebook_config['user_tag'] = additional_tags['user_tag']
+
+    notebook_config['custom_tag'] = additional_tags['custom_tag']
     notebook_config['cluster_labels'] = {
         os.environ['notebook_instance_name']: "configured",
         "name": notebook_config['cluster_name'],
         "sbn": notebook_config['service_base_name'],
-        "user": notebook_config['edge_user_name'],
+        "user": notebook_config['user_tag'],
         "notebook_name": os.environ['notebook_instance_name'],
         "project_tag": notebook_config['project_tag'],
         "endpoint_tag": notebook_config['endpoint_tag'],
         "product": "dlab",
         "computational_name": 
(os.environ['computational_name']).lower().replace('_', '-')
     }
+    if notebook_config['custom_tag'] != '':
+        notebook_config['cluster_labels'].update({'custom_tag': 
notebook_config['custom_tag']})
 
     try:
         logging.info('[INSTALLING KERNELS INTO SPECIFIED NOTEBOOK]')
diff --git 
a/infrastructure-provisioning/src/general/scripts/gcp/dataengine-service_prepare.py
 
b/infrastructure-provisioning/src/general/scripts/gcp/dataengine-service_prepare.py
index 316c9b2..17fc776 100644
--- 
a/infrastructure-provisioning/src/general/scripts/gcp/dataengine-service_prepare.py
+++ 
b/infrastructure-provisioning/src/general/scripts/gcp/dataengine-service_prepare.py
@@ -76,17 +76,28 @@ if __name__ == "__main__":
                                                                
dataproc_conf['project_name'],
                                                                
dataproc_conf['endpoint_name'])
     dataproc_conf['release_label'] = os.environ['dataproc_version']
+    additional_tags = json.loads(os.environ['tags'].replace("': u'", "\": 
\"").replace("', u'", "\", \"").replace("{u'", "{\"" ).replace("'}", "\"}"))
+
+    if '@' in additional_tags['user_tag']:
+        dataproc_conf['user_tag'] = 
additional_tags['user_tag'][:additional_tags['user_tag'].find('@')]
+    else:
+        dataproc_conf['user_tag'] = additional_tags['user_tag']
+
+    dataproc_conf['custom_tag'] = additional_tags['custom_tag']
     dataproc_conf['cluster_labels'] = {
         os.environ['notebook_instance_name']: "not-configured",
         "name": dataproc_conf['cluster_name'],
         "sbn": dataproc_conf['service_base_name'],
-        "user": dataproc_conf['edge_user_name'],
+        "user": dataproc_conf['user_tag'],
         "project_tag": dataproc_conf['project_tag'],
         "endpoint_tag": dataproc_conf['endpoint_tag'],
         "notebook_name": os.environ['notebook_instance_name'],
         "product": "dlab",
         "computational_name": dataproc_conf['computational_name']
     }
+    if dataproc_conf['custom_tag'] != '':
+        dataproc_conf['cluster_labels'].update({'custom_tag': 
dataproc_conf['custom_tag']})
+
     dataproc_conf['dataproc_service_account_name'] = 
'{0}-{1}-ps'.format(dataproc_conf['service_base_name'],
                                                                          
dataproc_conf['project_name'])
     dataproc_conf['dataproc_unique_index'] = 
GCPMeta().get_index_by_service_account_name(dataproc_conf['dataproc_service_account_name'])
diff --git 
a/infrastructure-provisioning/src/general/scripts/gcp/dataengine_prepare.py 
b/infrastructure-provisioning/src/general/scripts/gcp/dataengine_prepare.py
index 2776834..4046abb 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/dataengine_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/dataengine_prepare.py
@@ -143,9 +143,17 @@ if __name__ == "__main__":
         data_engine['gpu_accelerator_type'] = 
os.environ['gcp_gpu_accelerator_type']
     data_engine['network_tag'] = 
'{0}-{1}-ps'.format(data_engine['service_base_name'],
                                                      
data_engine['project_name'])
+    additional_tags = json.loads(os.environ['tags'].replace("': u'", "\": 
\"").replace("', u'", "\", \"").replace("{u'", "{\"" ).replace("'}", "\"}"))
+
+    if '@' in additional_tags['user_tag']:
+        data_engine['user_tag'] = 
additional_tags['user_tag'][:additional_tags['user_tag'].find('@')]
+    else:
+        data_engine['user_tag'] = additional_tags['user_tag']
+
+    data_engine['custom_tag'] = additional_tags['custom_tag']
     data_engine['slave_labels'] = {"name": data_engine['cluster_name'],
                                    "sbn": data_engine['service_base_name'],
-                                   "user": data_engine['edge_user_name'],
+                                   "user": data_engine['user_tag'],
                                    "project_tag": data_engine['project_tag'],
                                    "endpoint_tag": data_engine['endpoint_tag'],
                                    "type": "slave",
@@ -153,12 +161,15 @@ if __name__ == "__main__":
                                    "product": "dlab"}
     data_engine['master_labels'] = {"name": data_engine['cluster_name'],
                                     "sbn": data_engine['service_base_name'],
-                                    "user": data_engine['edge_user_name'],
+                                    "user": data_engine['user_tag'],
                                     "project_tag": data_engine['project_tag'],
                                     "endpoint_tag": 
data_engine['endpoint_tag'],
                                     "type": "master",
                                     "notebook_name": 
data_engine['notebook_name'],
                                     "product": "dlab"}
+    if data_engine['custom_tag'] != '':
+        data_engine['slave_labels'].update({'custom_tag': 
data_engine['custom_tag']})
+        data_engine['master_labels'].update({'custom_tag': 
data_engine['custom_tag']})
 
     try:
         logging.info('[CREATE MASTER NODE]')


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to