You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by my...@apache.org on 2021/03/15 08:50:29 UTC
[incubator-datalab] branch DATALAB-2091-with-dataproc updated:
[DataLab-2091] - [GCP] Jupyter deployment fixed
This is an automated email from the ASF dual-hosted git repository.
mykolabodnar pushed a commit to branch DATALAB-2091-with-dataproc
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
The following commit(s) were added to refs/heads/DATALAB-2091-with-dataproc by this push:
new 390f337 [DataLab-2091] - [GCP] Jupyter deployment fixed
390f337 is described below
commit 390f33777b8b276cfd1e4072d69622ee31f27f64
Author: bodnarmykola <bo...@gmail.com>
AuthorDate: Mon Mar 15 10:49:49 2021 +0200
[DataLab-2091] - [GCP] Jupyter deployment fixed
---
.../src/general/conf/datalab.ini | 10 +++-
.../src/general/lib/gcp/actions_lib.py | 10 ++--
.../src/general/lib/os/debian/notebook_lib.py | 5 +-
.../src/general/lib/os/fab.py | 60 +++++++++++-----------
.../scripts/os/common_configure_reverse_proxy.py | 1 +
.../src/jupyter/scripts/configure_jupyter_node.py | 4 +-
6 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/infrastructure-provisioning/src/general/conf/datalab.ini b/infrastructure-provisioning/src/general/conf/datalab.ini
index 5a506dc..9f042cc 100644
--- a/infrastructure-provisioning/src/general/conf/datalab.ini
+++ b/infrastructure-provisioning/src/general/conf/datalab.ini
@@ -85,6 +85,12 @@ letsencrypt_enabled = false
# letsencrypt_email =
### Prefix of the private subnet
private_subnet_prefix = 24
+### Repository user
+repository_user =
+### Repository password
+repository_pass =
+### Repository url
+repository_address =
#--- [aws] section contains all common parameters related to Amazon ---#
[aws]
@@ -233,7 +239,7 @@ is_nat = true
### Size of the additional volume for notebook instance
disk_size = 30
### Version of Apache Spark to be installed on notebook
-spark_version = 2.4.4
+spark_version = 3.0.1
### Version of Apache Hadoop to be installed on notebook
hadoop_version = 2.7
### Version of Jupyter to be installed on notebook
@@ -302,7 +308,7 @@ superset_version = 0.35.1
### GCS-connector version
gcs_connector_version = 2.0.1
### Setuptools version
-setuptools_version = 54.0.0
+setuptools_version = 54.1.1
#--- [emr] section contains all parameters that are using for emr provisioning ---#
[emr]
diff --git a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
index 58e4f2b..10afde1 100644
--- a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
@@ -1410,12 +1410,12 @@ def configure_local_spark(jars_dir, templates_dir, memory_type='driver'):
if memory_type == 'driver':
spark_memory = datalab.fab.get_spark_memory()
datalab.fab.conn.sudo('sed -i "/spark.*.memory/d" /opt/spark/conf/spark-defaults.conf')
- datalab.fab.conn.sudo('echo "spark.{0}.memory {1}m" >> /opt/spark/conf/spark-defaults.conf'.format(memory_type,
+ datalab.fab.conn.sudo('bash -c "echo \"spark.{0}.memory {1}m\" >> /opt/spark/conf/spark-defaults.conf"'.format(memory_type,
spark_memory))
if not exists(datalab.fab.conn,'/opt/spark/conf/spark-env.sh'):
datalab.fab.conn.sudo('mv /opt/spark/conf/spark-env.sh.template /opt/spark/conf/spark-env.sh')
java_home = datalab.fab.conn.run("update-alternatives --query java | grep -o --color=never \'/.*/java-8.*/jre\'").stdout.replace('\n','').splitlines()[0]
- datalab.fab.conn.sudo("echo 'export JAVA_HOME=\'{}\'' >> /opt/spark/conf/spark-env.sh".format(java_home))
+ datalab.fab.conn.sudo('bash -c "echo \"export JAVA_HOME=\'{}\'\" >> /opt/spark/conf/spark-env.sh"'.format(java_home))
if 'spark_configurations' in os.environ:
datalab_header = datalab.fab.conn.sudo('cat /tmp/notebook_spark-defaults_local.conf | grep "^#"').stdout
spark_configurations = ast.literal_eval(os.environ['spark_configurations'])
@@ -1433,13 +1433,13 @@ def configure_local_spark(jars_dir, templates_dir, memory_type='driver'):
new_spark_defaults.append(property + ' ' + config['Properties'][property])
new_spark_defaults.append(param)
new_spark_defaults = set(new_spark_defaults)
- datalab.fab.conn.sudo("echo '{}' > /opt/spark/conf/spark-defaults.conf".format(datalab_header))
+ datalab.fab.conn.sudo('bash -c "echo \'{}\' > /opt/spark/conf/spark-defaults.conf"'.format(datalab_header))
for prop in new_spark_defaults:
prop = prop.rstrip()
- datalab.fab.conn.sudo('echo "{}" >> /opt/spark/conf/spark-defaults.conf'.format(prop))
+ datalab.fab.conn.sudo('bash -c "echo \"{}\" >> /opt/spark/conf/spark-defaults.conf"'.format(prop))
datalab.fab.conn.sudo('sed -i "/^\s*$/d" /opt/spark/conf/spark-defaults.conf')
if spark_jars_paths:
- datalab.fab.conn.sudo('echo "{}" >> /opt/spark/conf/spark-defaults.conf'.format(spark_jars_paths))
+ datalab.fab.conn.sudo('bash -c "echo \"{}\" >> /opt/spark/conf/spark-defaults.conf"'.format(spark_jars_paths))
except Exception as err:
print('Error:', str(err))
sys.exit(1)
diff --git a/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py b/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py
index ed2fd22..ce76715 100644
--- a/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py
+++ b/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py
@@ -63,10 +63,11 @@ def ensure_r_local_kernel(spark_version, os_user, templates_dir, kernels_dir):
datalab.fab.conn.sudo('\cp -f /tmp/r_template.json {}/ir/kernel.json'.format(kernels_dir))
datalab.fab.conn.sudo('ln -s /opt/spark/ /usr/local/spark')
try:
- datalab.fab.conn.sudo('''bash -c 'cd /usr/local/spark/R/lib/SparkR; R -e "install.packages(\'roxygen2\',repos=\'https://cloud.r-project.org\')" R -e "devtools::check(\'.\')"' ''')
+ datalab.fab.conn.sudo('R -e "install.packages(\'roxygen2\',repos=\'https://cloud.r-project.org\')"')
+ datalab.fab.conn.sudo(''' bash -c 'cd /usr/local/spark/R/lib/SparkR; R -e "devtools::check()"' ''')
except:
pass
- datalab.fab.conn.sudo('''bash -c 'cd /usr/local/spark/R/lib/SparkR; R -e "devtools::install(\'.\')"' ''')
+ datalab.fab.conn.sudo(''' bash -c 'cd /usr/local/spark/R/lib/SparkR; R -e "devtools::install()"' ''')
datalab.fab.conn.sudo('chown -R ' + os_user + ':' + os_user + ' /home/' + os_user + '/.local')
datalab.fab.conn.sudo('touch /home/' + os_user + '/.ensure_dir/r_local_kernel_ensured')
except:
diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py
index 8b9ba88..1e08a4f 100644
--- a/infrastructure-provisioning/src/general/lib/os/fab.py
+++ b/infrastructure-provisioning/src/general/lib/os/fab.py
@@ -666,7 +666,7 @@ def install_inactivity_checker(os_user, ip_address, rstudio=False):
conn.sudo("chmod 755 /opt/inactivity/inactive.sh")
conn.sudo("chown root:root /etc/systemd/system/inactive.service")
conn.sudo("chown root:root /etc/systemd/system/inactive.timer")
- conn.sudo("date +%s > /opt/inactivity/local_inactivity")
+ conn.sudo("bash -c 'date +%s > /opt/inactivity/local_inactivity'")
conn.sudo('systemctl daemon-reload')
conn.sudo('systemctl enable inactive.timer')
conn.sudo('systemctl start inactive.timer')
@@ -729,46 +729,43 @@ def add_breeze_library_local(os_user):
def configure_data_engine_service_pip(hostname, os_user, keyfile, emr=False):
init_datalab_connection(hostname, os_user, keyfile)
- manage_pkg('-y install', 'remote', 'python3-pip')
- if not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.4 -V 2>/dev/null | awk '{print $2}'"):
- conn.sudo('ln -s /usr/bin/pip-3.4 /usr/bin/pip3')
- elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.5 -V 2>/dev/null | awk '{print $2}'"):
- conn.sudo('ln -s /usr/bin/pip-3.5 /usr/bin/pip3')
- elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.6 -V 2>/dev/null | awk '{print $2}'"):
- conn.sudo('ln -s /usr/bin/pip-3.6 /usr/bin/pip3')
- elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.7 -V 2>/dev/null | awk '{print $2}'"):
- conn.sudo('ln -s /usr/bin/pip-3.7 /usr/bin/pip3')
- elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.8 -V 2>/dev/null | awk '{print $2}'"):
+ #datalab.common_lib.manage_pkg('-y install', 'remote', 'python3-pip')
+ if not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.9 -V 2>/dev/null | awk '{print $2}'").stdout:
+ conn.sudo('ln -s /usr/bin/pip-3.9 /usr/bin/pip3')
+ elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.8 -V 2>/dev/null | awk '{print $2}'").stdout:
conn.sudo('ln -s /usr/bin/pip-3.8 /usr/bin/pip3')
+ elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.7 -V 2>/dev/null | awk '{print $2}'").stdout:
+ conn.sudo('ln -s /usr/bin/pip-3.7 /usr/bin/pip3')
+ elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.6 -V 2>/dev/null | awk '{print $2}'").stdout:
+ conn.sudo('ln -s /usr/bin/pip-3.6 /usr/bin/pip3')
+ elif not exists(conn,'/usr/bin/pip3') and conn.sudo("python3.5 -V 2>/dev/null | awk '{print $2}'").stdout:
+ conn.sudo('ln -s /usr/bin/pip-3.5 /usr/bin/pip3')
if emr:
conn.sudo('pip3 install -U pip=={}'.format(os.environ['conf_pip_version']))
conn.sudo('ln -s /usr/local/bin/pip3.7 /bin/pip3.7')
- conn.sudo('echo "export PATH=$PATH:/usr/local/bin" >> /etc/profile')
- conn.sudo('source /etc/profile')
- conn.run('source /etc/profile')
+ conn.sudo('''bash -c -l 'echo "export PATH=$PATH:/usr/local/bin" >> /etc/profile' ''')
+ conn.sudo('bash -c -l "source /etc/profile"')
+ conn.run('bash -c -l "source /etc/profile"')
conn.close()
def configure_data_engine_service_livy(hostname, os_user, keyfile):
- env['connection_attempts'] = 100
- env.key_filename = [keyfile]
- env.host_string = os_user + '@' + hostname
- if exists('/usr/local/lib/livy'):
- sudo('rm -r /usr/local/lib/livy')
- sudo('wget -P /tmp/ --user={} --password={} '
+ init_datalab_connection(hostname, os_user, keyfile)
+ if exists(conn,'/usr/local/lib/livy'):
+ conn.sudo('rm -r /usr/local/lib/livy')
+ conn.sudo('wget -P /tmp/ --user={} --password={} '
'https://{}/repository/packages/livy.tar.gz --no-check-certificate'
.format(os.environ['conf_repository_user'],
os.environ['conf_repository_pass'], os.environ['conf_repository_address']))
- sudo('tar -xzvf /tmp/livy.tar.gz -C /usr/local/lib/')
- sudo('ln -s /usr/local/lib/incubator-livy /usr/local/lib/livy')
- put('/root/templates/dataengine-service_livy-env.sh', '/usr/local/lib/livy/conf/livy-env.sh', use_sudo=True)
- put('/root/templates/dataengine-service_livy.service', '/tmp/livy.service')
- sudo("sed -i 's|OS_USER|{}|' /tmp/livy.service".format(os_user))
- sudo('mv /tmp/livy.service /etc/systemd/system/livy.service')
- sudo('systemctl daemon-reload')
- sudo('systemctl enable livy.service')
- sudo('systemctl start livy.service')
-
-
+ conn.sudo('tar -xzvf /tmp/livy.tar.gz -C /usr/local/lib/')
+ conn.sudo('ln -s /usr/local/lib/incubator-livy /usr/local/lib/livy')
+ conn.put('/root/templates/dataengine-service_livy-env.sh', '/usr/local/lib/livy/conf/livy-env.sh')
+ conn.put('/root/templates/dataengine-service_livy.service', '/tmp/livy.service')
+ conn.sudo("sed -i 's|OS_USER|{}|' /tmp/livy.service".format(os_user))
+ conn.sudo('mv /tmp/livy.service /etc/systemd/system/livy.service')
+ conn.sudo('systemctl daemon-reload')
+ conn.sudo('systemctl enable livy.service')
+ conn.sudo('systemctl start livy.service')
+ conn.close()
def remove_rstudio_dataengines_kernel(cluster_name, os_user):
try:
@@ -1039,6 +1036,7 @@ def init_datalab_connection(hostname, username, keyfile):
conn = Connection(host = hostname, user = username, connect_kwargs={'key_filename': keyfile})
try:
conn.run('ls')
+ conn.config.run.echo = True
return conn
except:
attempt += 1
diff --git a/infrastructure-provisioning/src/general/scripts/os/common_configure_reverse_proxy.py b/infrastructure-provisioning/src/general/scripts/os/common_configure_reverse_proxy.py
index a7fa7a6..29b5ac2 100644
--- a/infrastructure-provisioning/src/general/scripts/os/common_configure_reverse_proxy.py
+++ b/infrastructure-provisioning/src/general/scripts/os/common_configure_reverse_proxy.py
@@ -24,6 +24,7 @@
import argparse
import json
import sys
+from datalab.fab import *
from datalab.meta_lib import get_instance_private_ip_address
from fabric import *
from jinja2 import Environment, FileSystemLoader
diff --git a/infrastructure-provisioning/src/jupyter/scripts/configure_jupyter_node.py b/infrastructure-provisioning/src/jupyter/scripts/configure_jupyter_node.py
index 6f80432..44ac8b5 100644
--- a/infrastructure-provisioning/src/jupyter/scripts/configure_jupyter_node.py
+++ b/infrastructure-provisioning/src/jupyter/scripts/configure_jupyter_node.py
@@ -103,7 +103,9 @@ if __name__ == "__main__":
# INSTALL SPARK AND CLOUD STORAGE JARS FOR SPARK
print("Install local Spark")
ensure_local_spark(args.os_user, spark_link, spark_version, hadoop_version, local_spark_path)
- local_spark_scala_version = conn.sudo('spark-submit --version 2>&1 | grep -o -P "Scala version \K.{0,7}"').stdout.replace('\n','')
+ local_spark_scala_version = conn.run(
+ 'export PATH=$PATH:' + local_spark_path + 'bin/; spark-submit --version 2>&1 | grep -o -P "Scala version \K.{0,7}"').stdout.replace(
+ '\n', '')
print("Install storage jars")
ensure_local_jars(args.os_user, jars_dir)
print("Configure local Spark")
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org