You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by my...@apache.org on 2020/02/27 14:38:36 UTC

[incubator-dlab] branch DLAB-1570 created (now b214927)

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

mykolabodnar pushed a change to branch DLAB-1570
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.


      at b214927  [DLAB-1570]: Rarely notebook creation fails on stage of 'npm' installation fixed

This branch includes the following new commits:

     new b214927  [DLAB-1570]: Rarely notebook creation fails on stage of 'npm' installation fixed

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-dlab] 01/01: [DLAB-1570]: Rarely notebook creation fails on stage of 'npm' installation fixed

Posted by my...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b21492767c1578bdc2f6b20019e91f6b665f108e
Author: Mykola_Bodnar1 <bo...@gmail.com>
AuthorDate: Thu Feb 27 16:34:43 2020 +0200

    [DLAB-1570]: Rarely notebook creation fails on stage of 'npm' installation fixed
---
 .../src/general/lib/os/debian/common_lib.py        | 24 ++++++++++++++++++++++
 .../src/general/lib/os/fab.py                      |  6 +++---
 .../src/ssn/scripts/configure_ui.py                |  3 ++-
 3 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py b/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
index c4f8ff4..ff8018f 100644
--- a/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
+++ b/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
@@ -27,6 +27,30 @@ import sys
 import os
 import time
 
+def manage_npm_pkg(command):
+    try:
+        npm_count = 0
+        installed = False
+        npm_registry_first = ['https://registry.npmjs.org/', 'https://registry.npmjs.com/']
+        while not installed:
+            if npm_count > 60:
+                print("NPM registry is not available, please try later")
+                sys.exit(1)
+            else:
+                try:
+                    if npm_count % 2 == 0:
+                        sudo('npm config set registry {}'.format(npm_registry_first[0]))
+                    else:
+                        sudo('npm config set registry {}'.format(npm_registry_first[1]))
+                    sudo('npm {}'.format(command))
+                    installed = True
+                except:
+                    npm_count += 1
+                    time.sleep(50)
+    except:
+        sys.exit(1)
+
+
 def manage_pkg(command, environment, requisites):
     try:
         allow = False
diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py
index a1e1a16..a13daa7 100644
--- a/infrastructure-provisioning/src/general/lib/os/fab.py
+++ b/infrastructure-provisioning/src/general/lib/os/fab.py
@@ -32,7 +32,7 @@ from dlab.actions_lib import *
 import dlab.actions_lib
 import re
 import traceback
-from dlab.common_lib import manage_pkg
+from dlab.common_lib import *
 
 
 def ensure_pip(requisites):
@@ -499,10 +499,10 @@ def ensure_toree_local_kernel(os_user, toree_link, scala_kernel_path, files_dir,
             sys.exit(1)
 
 
-def install_ungit(os_user, notebook_name, edge_ip):
+def (os_user, notebook_name, edge_ip):
     if not exists('/home/{}/.ensure_dir/ungit_ensured'.format(os_user)):
         try:
-            sudo('npm -g install ungit@{}'.format(os.environ['notebook_ungit_version']))
+            manage_npm_pkg('-g install ungit@{}'.format(os.environ['notebook_ungit_version']))
             put('/root/templates/ungit.service', '/tmp/ungit.service')
             sudo("sed -i 's|OS_USR|{}|' /tmp/ungit.service".format(os_user))
             http_proxy = run('echo $http_proxy')
diff --git a/infrastructure-provisioning/src/ssn/scripts/configure_ui.py b/infrastructure-provisioning/src/ssn/scripts/configure_ui.py
index ad3b7ed..e38adda 100644
--- a/infrastructure-provisioning/src/ssn/scripts/configure_ui.py
+++ b/infrastructure-provisioning/src/ssn/scripts/configure_ui.py
@@ -31,6 +31,7 @@ import os
 import traceback
 from dlab.ssn_lib import *
 from dlab.fab import *
+from common_lib.py import *
 
 parser = argparse.ArgumentParser()
 parser.add_argument('--hostname', type=str, default='')
@@ -149,7 +150,7 @@ def build_ui():
                      '\'use_ldap\': false'))
 
             sudo('echo "N" | npm install')
-            sudo('npm run build.prod')
+            manage_npm_pkg('run build.prod')
             sudo('sudo chown -R {} {}/*'.format(args.os_user, args.dlab_path))
 
         # Building Back-end


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