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

mykolabodnar pushed a commit to branch DATALAB-2409
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git


The following commit(s) were added to refs/heads/DATALAB-2409 by this push:
     new f043904  [DATALAB-2409] - logging refactored
f043904 is described below

commit f0439040432bc92b961b42f2c980e8828942a5ce
Author: bodnarmykola <[email protected]>
AuthorDate: Tue Aug 3 12:42:08 2021 +0300

    [DATALAB-2409] - logging refactored
---
 infrastructure-provisioning/scripts/deploy_datalab.py            | 1 +
 infrastructure-provisioning/src/general/lib/os/logger.py         | 2 +-
 .../src/general/scripts/aws/ssn_configure.py                     | 2 ++
 .../src/general/scripts/aws/ssn_create_vpc.py                    | 9 +++++----
 .../src/general/scripts/aws/ssn_prepare.py                       | 4 ++--
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/infrastructure-provisioning/scripts/deploy_datalab.py 
b/infrastructure-provisioning/scripts/deploy_datalab.py
index 42ad605..5932d34 100644
--- a/infrastructure-provisioning/scripts/deploy_datalab.py
+++ b/infrastructure-provisioning/scripts/deploy_datalab.py
@@ -296,6 +296,7 @@ def build_docker_images(args):
 def deploy_datalab(args):
     # Creating SSN node
     docker_command = generate_docker_command()
+    print('Docker command: {}'.format(docker_command ))
     subprocess.run(docker_command, shell=True, check=True)
 
 
diff --git a/infrastructure-provisioning/src/general/lib/os/logger.py 
b/infrastructure-provisioning/src/general/lib/os/logger.py
index de07945..1f5f1a6 100644
--- a/infrastructure-provisioning/src/general/lib/os/logger.py
+++ b/infrastructure-provisioning/src/general/lib/os/logger.py
@@ -27,7 +27,7 @@ local_log_filepath = "/logs/" + os.environ['conf_resource'] + 
"/" + local_log_fi
 logging.basicConfig(format='%(levelname)-8s [%(asctime)s]  %(message)s',
                     level=logging.DEBUG,
                     filename='{}'.format(local_log_filepath),
-                    filemode='w')
+                    filemode='a')
 console = logging.StreamHandler()
 console.setLevel(logging.INFO)
 logging.getLogger('').addHandler(console)
\ No newline at end of file
diff --git 
a/infrastructure-provisioning/src/general/scripts/aws/ssn_configure.py 
b/infrastructure-provisioning/src/general/scripts/aws/ssn_configure.py
index 218c033..a8e7ce1 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/ssn_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/ssn_configure.py
@@ -602,6 +602,8 @@ if __name__ == "__main__":
             f.write(json.dumps(res))
 
         logging.info('Upload response file')
+        local_log_filepath = "/logs/{}/{}_{}.log".format(+ 
os.environ['conf_resource'], os.environ['conf_resource'],
+                                                         
os.environ['request_id'])
         params = "--instance_name {} --local_log_filepath {} --os_user {} 
--instance_hostname {}". \
             format(ssn_conf['instance_name'], local_log_filepath, 
ssn_conf['datalab_ssh_user'],
                    ssn_conf['instance_hostname'])
diff --git 
a/infrastructure-provisioning/src/general/scripts/aws/ssn_create_vpc.py 
b/infrastructure-provisioning/src/general/scripts/aws/ssn_create_vpc.py
index afaea63..9d6e77b 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/ssn_create_vpc.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/ssn_create_vpc.py
@@ -24,6 +24,7 @@
 import argparse
 from datalab.actions_lib import *
 from datalab.meta_lib import *
+from datalab.logger import logging
 
 parser = argparse.ArgumentParser()
 parser.add_argument('--vpc', type=str, default='')
@@ -48,18 +49,18 @@ if __name__ == "__main__":
         try:
             vpc_id = get_vpc_by_tag(args.infra_tag_name, args.infra_tag_value)
             if vpc_id == '':
-                print("Creating {3}vpc {0} in region {1} with tag 
{2}".format(args.vpc, args.region, json.dumps(tag), sec_str))
+                logging.info("Creating {3}vpc {0} in region {1} with tag 
{2}".format(args.vpc, args.region, json.dumps(tag), sec_str))
                 vpc_id = create_vpc(args.vpc, tag)
                 create_tag(vpc_id, vpc_tag_name)
                 enable_vpc_dns(vpc_id)
                 rt_id = create_rt(vpc_id, args.infra_tag_name, 
args.infra_tag_value, args.secondary)
                 create_tag(rt_id, rt_tag_name)
             else:
-                print("REQUESTED {}VPC ALREADY EXISTS".format(sec_str))
-            print("{0}VPC_ID: {1}".format(sec_str, vpc_id))
+                logging.info("REQUESTED {}VPC ALREADY EXISTS".format(sec_str))
+            logging.info("{0}VPC_ID: {1}".format(sec_str, vpc_id))
             args.vpc_id = vpc_id
         except Exception as err:
-            print('Error: {0}'.format(err))
+            logging.error('Error: {0}'.format(err))
             sys.exit(1)
     else:
         parser.print_help()
diff --git a/infrastructure-provisioning/src/general/scripts/aws/ssn_prepare.py 
b/infrastructure-provisioning/src/general/scripts/aws/ssn_prepare.py
index a568e7c..61bcf72 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/ssn_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/ssn_prepare.py
@@ -24,8 +24,8 @@
 import datalab.fab
 import datalab.actions_lib
 import datalab.meta_lib
-import json
 from datalab.logger import logging
+import json
 import os
 import sys
 import traceback
@@ -49,7 +49,7 @@ if __name__ == "__main__":
         else:
             datalab.actions_lib.create_aws_config_files()
     except Exception as err:
-        logging.info('Unable to create configuration')
+        logging.error('Unable to create configuration')
         datalab.fab.append_result("Unable to create configuration", err)
         traceback.print_exc()
         sys.exit(1)

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

Reply via email to