Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Fix: AZTK_IS_MASTER not set on worker and failing #506

Merged
merged 4 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions aztk/node_scripts/install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ def setup_host(docker_repo: str):
master_node = config.batch_client.compute_node.get(config.pool_id, master_node_id)

if is_master:
os.environ["AZTK_IS_MASTER"] = "1"
os.environ["AZTK_IS_MASTER"] = "true"
else:
os.environ["AZTK_IS_MASTER"] = "false"
if is_worker:
os.environ["AZTK_IS_WORKER"] = "1"
os.environ["AZTK_IS_WORKER"] = "true"
else:
os.environ["AZTK_IS_WORKER"] = "false"

os.environ["AZTK_MASTER_IP"] = master_node.ip_address

Expand All @@ -49,8 +53,8 @@ def setup_spark_container():
"""
Code run in the main spark container
"""
is_master = os.environ["AZTK_IS_MASTER"]
is_worker = os.environ["AZTK_IS_WORKER"]
is_master = os.environ.get("AZTK_IS_MASTER") == "true"
is_worker = os.environ.get("AZTK_IS_WORKER") == "true"
print("Setting spark container. Master: ", is_master, ", Worker: ", is_worker)

print("Copying spark setup config")
Expand Down
2 changes: 1 addition & 1 deletion aztk/spark/models/plugins/hdfs/hdfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>
</configuration>' > $HADOOP_HOME/etc/hadoop/hdfs-site.xml

# run HDFS
if [ "$AZTK_IS_MASTER" -eq "1" ]; then
if [ "$AZTK_IS_MASTER" -eq "true" ]; then
echo 'starting namenode and datanode'
hdfs namenode -format
$HADOOP_HOME/sbin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script hdfs start namenode
Expand Down
2 changes: 1 addition & 1 deletion aztk/spark/models/plugins/jupyter/jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

echo "Is master: $AZTK_IS_MASTER"

if [ "$AZTK_IS_MASTER" = "1" ]; then
if [ "$AZTK_IS_MASTER" = "true" ]; then
pip install jupyter --upgrade
pip install notebook --upgrade

Expand Down
2 changes: 1 addition & 1 deletion aztk/spark/models/plugins/jupyter_lab/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self):
public=True,
),
],
run_on=PluginTargetRole.All,
target_role=PluginTargetRole.All,
execute="jupyter_lab.sh",
files=[
PluginFile("jupyter_lab.sh", os.path.join(dir_path, "jupyter_lab.sh")),
Expand Down
2 changes: 1 addition & 1 deletion aztk/spark/models/plugins/jupyter_lab/jupyter_lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - aztk/python:spark2.1.0-python3.6.2-base
# - aztk/python:spark2.1.0-python3.6.2-gpu

if [ "$IS_MASTER" = "1" ]; then
if [ "$AZTK_IS_MASTER" = "true" ]; then
conda install -c conda-force jupyterlab

PYSPARK_DRIVER_PYTHON="/.pyenv/versions/${USER_PYTHON_VERSION}/bin/jupyter"
Expand Down
2 changes: 1 addition & 1 deletion aztk/spark/models/plugins/rstudio_server/rstudio_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# - jiata/aztk-r:0.1.0-spark2.1.0-r3.4.1
# - jiata/aztk-r:0.1.0-spark1.6.3-r3.4.1

if [ "$AZTK_IS_MASTER" = "1" ]; then
if [ "$AZTK_IS_MASTER" = "true" ]; then

## Download and install Rstudio Server
wget https://download2.rstudio.org/rstudio-server-$RSTUDIO_SERVER_VERSION-amd64.deb
Expand Down
2 changes: 1 addition & 1 deletion custom-scripts/hdfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ echo '<?xml version="1.0" encoding="UTF-8"?>
</configuration>' > $HADOOP_HOME/etc/hadoop/hdfs-site.xml

# run HDFS
if [ "$AZTK_IS_MASTER" -eq "1" ]; then
if [ "$AZTK_IS_MASTER" -eq "true" ]; then
echo 'starting namenode and datanode'
hdfs namenode -format
$HADOOP_HOME/sbin/hadoop-daemon.sh --config $HADOOP_CONF_DIR --script hdfs start namenode
Expand Down
2 changes: 1 addition & 1 deletion custom-scripts/jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# - aztk/python:spark2.1.0-python3.6.2-base
# - aztk/python:spark2.1.0-python3.6.2-gpu

if [ "$AZTK_IS_MASTER" = "1" ]; then
if [ "$AZTK_IS_MASTER" = "true" ]; then
pip install jupyter --upgrade
pip install notebook --upgrade

Expand Down
6 changes: 3 additions & 3 deletions custom-scripts/rstudio_server.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

# This custom script only works on images where rstudio server is pre-installed on the Docker image
#
#
# This custom script has been tested to work on the following docker images:
# - jiata/aztk-r:0.1.0-spark2.2.0-r3.4.1
# - jiata/aztk-r:0.1.0-spark2.1.0-r3.4.1
# - jiata/aztk-r:0.1.0-spark1.6.3-r3.4.1

if [ "$AZTK_IS_MASTER" = "1" ]; then
if [ "$AZTK_IS_MASTER" = "true" ]; then

## Download and install Rstudio Server
wget https://download2.rstudio.org/rstudio-server-$RSTUDIO_SERVER_VERSION-amd64.deb
Expand All @@ -19,7 +19,7 @@ if [ "$AZTK_IS_MASTER" = "1" ]; then
set -e
useradd -m -d /home/rstudio rstudio -g staff
echo rstudio:rstudio | chpasswd

rstudio-server start

fi
4 changes: 2 additions & 2 deletions custom-scripts/simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# Demo plugin. Not actually meant to be used.

if [ "$AZTK_IS_MASTER" = "1" ]; then
if [ "$AZTK_IS_MASTER" = "true" ]; then
echo "This is a custom script running on just the master!"
fi

if [ "$AZTK_IS_WORKER" = "1" ]; then
if [ "$AZTK_IS_WORKER" = "true" ]; then
echo "This is a custom script running on just the workers!"
fi

Expand Down
4 changes: 2 additions & 2 deletions docs/51-define-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ cluster_config = ClusterConfiguration(

AZTK provide a few environment variables that can be used in your plugin script

* `AZTK_IS_MASTER`: Is the plugin running on the master node
* `AZTK_IS_WORKER`: Is a worker setup on the current node(This might also be a master if you have `worker_on_master` set to true)
* `AZTK_IS_MASTER`: Is the plugin running on the master node. Can be either `true` or `false`
* `AZTK_IS_WORKER`: Is a worker setup on the current node(This might also be a master if you have `worker_on_master` set to true) Can be either `true` or `false`
* `AZTK_MASTER_IP`: Internal ip of the master

## Debug your plugin
Expand Down