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/28 12:34:26 UTC

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

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

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


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

This branch includes the following new commits:

     new ed1d12b  [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-1570a
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit ed1d12bebd3826a2ff0865adea1fc7d087dbaa1f
Author: Mykola_Bodnar1 <bo...@gmail.com>
AuthorDate: Fri Feb 28 14:34:12 2020 +0200

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

diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py
index a1e1a16..18c10d5 100644
--- a/infrastructure-provisioning/src/general/lib/os/fab.py
+++ b/infrastructure-provisioning/src/general/lib/os/fab.py
@@ -502,7 +502,7 @@ def ensure_toree_local_kernel(os_user, toree_link, scala_kernel_path, files_dir,
 def install_ungit(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')
@@ -868,3 +868,26 @@ def configure_superset(os_user, keycloak_auth_server_url, keycloak_realm_name, k
     except Exception as err:
         print("Failed configure superset: " + str(err))
         sys.exit(1)
+
+def manage_npm_pkg(command):
+    try:
+        npm_count = 0
+        installed = False
+        npm_registry = ['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[0]))
+                    else:
+                        sudo('npm config set registry {}'.format(npm_registry[1]))
+                    sudo('npm {}'.format(command))
+                    installed = True
+                except:
+                    npm_count += 1
+                    time.sleep(50)
+    except:
+        sys.exit(1)
\ No newline at end of file
diff --git a/infrastructure-provisioning/src/ssn/scripts/configure_ui.py b/infrastructure-provisioning/src/ssn/scripts/configure_ui.py
index ad3b7ed..fdca046 100644
--- a/infrastructure-provisioning/src/ssn/scripts/configure_ui.py
+++ b/infrastructure-provisioning/src/ssn/scripts/configure_ui.py
@@ -149,7 +149,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