You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dm...@apache.org on 2019/12/02 13:24:26 UTC

[incubator-dlab] branch DLAB-1326 updated: [DLAB-1326] Implemented proxy configuration for docker

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

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


The following commit(s) were added to refs/heads/DLAB-1326 by this push:
     new 1df52e1  [DLAB-1326] Implemented proxy configuration for docker
     new 35247bb  Merge remote-tracking branch 'origin/DLAB-1326' into DLAB-1326
1df52e1 is described below

commit 1df52e1c4de259d55b8ee62a91383f5966922bc3
Author: Demyan Mysakovets <de...@gmail.com>
AuthorDate: Mon Dec 2 15:23:47 2019 +0200

    [DLAB-1326] Implemented proxy configuration for docker
---
 infrastructure-provisioning/src/general/lib/os/fab.py            | 2 +-
 .../src/general/scripts/aws/jupyterlab_configure.py              | 7 ++++++-
 .../src/general/scripts/gcp/jupyterlab_configure.py              | 7 ++++++-
 .../src/general/scripts/os/configure_proxy_for_docker.py         | 9 ++++++---
 .../src/jupyterlab/scripts/configure_jupyterlab_node.py          | 2 +-
 5 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py
index 8447a41..751ce5c 100644
--- a/infrastructure-provisioning/src/general/lib/os/fab.py
+++ b/infrastructure-provisioning/src/general/lib/os/fab.py
@@ -193,7 +193,7 @@ def configure_jupyter(os_user, jupyter_conf_file, templates_dir, jupyter_version
             print('Error:', str(err))
             sys.exit(1)
 
-def configure_docker(os_user, ):
+def configure_docker(os_user):
     try:
         if not exists('/home/' + os_user + '/.ensure_dir/docker_ensured'):
             docker_version = os.environ['ssn_docker_version']
diff --git a/infrastructure-provisioning/src/general/scripts/aws/jupyterlab_configure.py b/infrastructure-provisioning/src/general/scripts/aws/jupyterlab_configure.py
index 157e140..85d7243 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/jupyterlab_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/jupyterlab_configure.py
@@ -292,7 +292,12 @@ if __name__ == "__main__":
     try:
         print('[CONFIGURING PROXY FOR DOCKER]')
         logging.info('[CONFIGURING PROXY FOR DOCKER]')
-        params = "--os_user {} ".format(notebook_config['dlab_ssh_user'])
+        params = "--hostname {} " \
+                 "--keyfile {} " \
+                 "--os_user {} ". \
+            format(instance_hostname,
+                   keyfile_name,
+                   notebook_config['dlab_ssh_user'])
         try:
             local("~/scripts/configure_proxy_for_docker.py {}".format(params))
         except:
diff --git a/infrastructure-provisioning/src/general/scripts/gcp/jupyterlab_configure.py b/infrastructure-provisioning/src/general/scripts/gcp/jupyterlab_configure.py
index 0bf279c..f8110d4 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/jupyterlab_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/jupyterlab_configure.py
@@ -282,7 +282,12 @@ if __name__ == "__main__":
     try:
         print('[CONFIGURING PROXY FOR DOCKER]')
         logging.info('[CONFIGURING PROXY FOR DOCKER]')
-        params = "--os_user {} ".format(notebook_config['dlab_ssh_user'])
+        params = "--hostname {} " \
+                 "--keyfile {} " \
+                 "--os_user {} ". \
+            format(instance_hostname,
+                   keyfile_name,
+                   notebook_config['dlab_ssh_user'])
         try:
             local("~/scripts/configure_proxy_for_docker.py {}".format(params))
         except:
diff --git a/infrastructure-provisioning/src/general/scripts/os/configure_proxy_for_docker.py b/infrastructure-provisioning/src/general/scripts/os/configure_proxy_for_docker.py
index 18791a2..6b4b79f 100644
--- a/infrastructure-provisioning/src/general/scripts/os/configure_proxy_for_docker.py
+++ b/infrastructure-provisioning/src/general/scripts/os/configure_proxy_for_docker.py
@@ -26,6 +26,8 @@ import sys
 
 
 parser = argparse.ArgumentParser()
+parser.add_argument('--hostname', type=str, default='')
+parser.add_argument('--keyfile', type=str, default='')
 parser.add_argument('--os_user', type=str, default='')
 args = parser.parse_args()
 
@@ -44,13 +46,14 @@ if __name__ == "__main__":
         sudo('echo -e \'[Service] \nEnvironment=\"HTTP_PROXY=\'$http_proxy\'\"\' > {}'.format(http_file))
         sudo('touch {}'.format(https_file))
         sudo('echo -e \'[Service] \nEnvironment=\"HTTPS_PROXY=\'$http_proxy\'\"\' > {}'.format(https_file))
-        sudo('mkdir /home/{}/.docker'.format(os_user))
-        sudo('touch /home/{}/.docker/config.json'.format(os_user))
+        sudo('mkdir /home/{}/.docker'.format(args.os_user))
+        sudo('touch /home/{}/.docker/config.json'.format(args.os_user))
         sudo(
             'echo -e \'{\n "proxies":\n {\n   "default":\n   {\n     "httpProxy":"\'$http_proxy\'",\n     "httpsProxy":"\'$http_proxy\'"\n   }\n }\n}\' > /home/dlab-user/.docker/config.json')
-        sudo('usermod -a -G docker ' + os_user)
+        sudo('usermod -a -G docker ' + args.os_user)
         sudo('update-rc.d docker defaults')
         sudo('update-rc.d docker enable')
+        sudo('systemctl restart docker')
     except Exception as err:
         print('Error: {0}'.format(err))
         sys.exit(1)
diff --git a/infrastructure-provisioning/src/jupyterlab/scripts/configure_jupyterlab_node.py b/infrastructure-provisioning/src/jupyterlab/scripts/configure_jupyterlab_node.py
index 4bee9af..7872b5c 100644
--- a/infrastructure-provisioning/src/jupyterlab/scripts/configure_jupyterlab_node.py
+++ b/infrastructure-provisioning/src/jupyterlab/scripts/configure_jupyterlab_node.py
@@ -104,7 +104,7 @@ if __name__ == "__main__":
 
     # INSTALL DOCKER
     print ("Install Docker")
-    configure_docker(args.os_user, http_file, https_file)
+    configure_docker(args.os_user)
 
     # CONFIGURE JUPYTER FILES
     print("Configure jupyter files")


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