Skip to content

Commit

Permalink
add PWB_VERSION and config-login.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmayer2 committed Dec 4, 2024
1 parent 98e383e commit bc1cb06
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 52 deletions.
6 changes: 6 additions & 0 deletions parallelcluster/config/cluster-config-wb.benchmark.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ HeadNode:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/install-pwb-config.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down Expand Up @@ -44,6 +46,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand All @@ -64,6 +68,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
CustomSlurmSettings:
OverSubscribe: FORCE:2
Iam:
Expand Down
8 changes: 8 additions & 0 deletions parallelcluster/config/cluster-config-wb.default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ HeadNode:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/install-pwb-config.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down Expand Up @@ -47,6 +49,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
CustomSlurmSettings:
OverSubscribe: FORCE
Iam:
Expand All @@ -69,6 +73,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand All @@ -89,6 +95,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down
8 changes: 8 additions & 0 deletions parallelcluster/config/cluster-config-wb.easybuild.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ HeadNode:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/install-pwb-config.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down Expand Up @@ -47,6 +49,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand All @@ -67,6 +71,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand All @@ -87,6 +93,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down
7 changes: 6 additions & 1 deletion parallelcluster/config/cluster-config-wb.ide-team.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ HeadNode:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/install-pwb-config.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down Expand Up @@ -45,7 +47,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Iam:
Args:
- "PWB_VERSION"am:
S3Access:
- BucketName: S3_BUCKETNAME
Networking:
Expand All @@ -65,6 +68,8 @@ Scheduling:
CustomActions:
OnNodeConfigured:
Script: "s3://S3_BUCKETNAME/config-compute.sh"
Args:
- "PWB_VERSION"
Iam:
S3Access:
- BucketName: S3_BUCKETNAME
Expand Down
18 changes: 6 additions & 12 deletions parallelcluster/scripts/config-compute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,13 @@ fi

echo "posit0001 ALL=NOPASSWD: ALL" >> /etc/sudoers

if (BENCHMARK_SUPPORT); then
# Perform the initial population of /opt/rstudio/rstudio-server if it doesn't exist. This lets the first deployed
# compute work right away
if [ ! -d "/opt/rstudio/rstudio-server" ]; then
cp -R /usr/lib/rstudio-server /opt/rstudio/
fi
# symlink /opt/rstudio/rstudio-server into /usr/lib/rstudio-server
rm -rf /usr/lib/rstudio-server
ln -s /opt/rstudio/rstudio-server /usr/lib

fi
# Session components
apt-get update -y
apt-get install -y curl libcurl4-gnutls-dev libssl-dev libpq5 rrdtool
mkdir -p /usr/lib/rstudio-server
tar xf /opt/rstudio/scripts/rsp-session-jammy-$1-amd64.tar.gz -C /usr/lib/rstudio-server --strip-components=1

# create scratch folder as part of EFS fs
mkdir -p /scratch /opt/rstudio/scratch
efsmount=`cat /etc/fstab | grep rstudio | awk '{print $1}'`
mount ${efsmount}scratch /scratch
mount ${efsmount}scratch /scratch
110 changes: 110 additions & 0 deletions parallelcluster/scripts/config-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# Grant posit0001 sudo rights
echo "posit0001 ALL=NOPASSWD: ALL" >> /etc/sudoers

# Install Posit Workbench

PWB_CONFIG_DIR=$1

PWB_VERSION=$2

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

# Add rstudio-server user and group
groupadd --system --gid 900 rstudio-server
useradd -s /bin/bash -m --system --gid rstudio-server --uid 900 rstudio-server

# Install software

if ( ! dpkg -l gdebi-core >& /dev/null); then
apt-get update
apt-get install -y gdebi
fi

while true
do
if [ -d /opt/rstudio/scripts ]; then
pushd /opt/rstudio/scripts
gdebi -n rstudio-workbench-${PWB_VERSION}-amd64.deb
popd
break
fi
done


VSCODE_EXTDIR=/usr/local/rstudio/code-server

mkdir -p /usr/local/rstudio/code-server
chmod a+rx /usr/local/rstudio/code-server

for extension in quarto.quarto \
[email protected] \
[email protected]
do
/usr/lib/rstudio-server/bin/pwb-code-server/bin/code-server --extensions-dir=$VSCODE_EXTDIR \
--install-extension $extension
done

chmod a+rx /usr/local/rstudio/code-server


# wait until the workbench config files are there (deployed by head-node)
while true ; do if [ -f $PWB_CONFIG_DIR/rserver.conf ]; then break; fi; sleep 1; done ; echo "PWB config files found !"

for i in server launcher
do
mkdir -p /etc/systemd/system/rstudio-$i.service.d
echo -e "[Service]\nEnvironment=\"RSTUDIO_CONFIG_DIR=$PWB_CONFIG_DIR\"" > /etc/systemd/system/rstudio-$i.service.d/override.conf
done
# We are on a login node and hence will need to enable rstudio-server and rstudio-launcher

# scalability
sysctl -w net.unix.max_dgram_qlen=8192
sysctl -w net.core.netdev_max_backlog=65535

systemctl daemon-reload
systemctl stop rstudio-server
systemctl stop rstudio-launcher
killall apache2
rm -rf /var/log/rstudio
systemctl start rstudio-launcher
systemctl start rstudio-server

# Touch a file in /opt/rstudio to signal that workbench is running on this server
touch /opt/rstudio/workbench-`hostname`.state

#if ( ! crontab -l | grep rstudio ); then
# (crontab -l ; echo "0-59/1 * * * * /opt/rstudio/scripts/rc.pwb")| crontab -
#fi

if (EASYBUILD_SUPPORT); then
apt-get update && apt-get install -y lmod
cat << EOF > /etc/profile.d/modulepath.sh
#!/bin/bash
export MODULEPATH=/opt/apps/easybuild/modules/all
EOF
fi

if ( ! grep AD_DNS /etc/hosts >& /dev/null ); then
echo "AD_DNS pwb.posit.co" >> /etc/hosts
fi

if ( ! grep posit0001 /etc/sudoers >& /dev/null ); then
echo "posit0001 ALL=NOPASSWD: ALL" >> /etc/sudoers
fi


if ( ! grep rstudio-server /etc/security/limits.conf ); then
echo "rstudio-server soft nofile 32768" >> /etc/security/limits.conf
echo "rstudio-server hard nofile 32768" >> /etc/security/limits.conf
fi

if ( ! mount | grep /scratch ); then
# create scratch folder as part of EFS fs
mkdir -p /scratch /opt/rstudio/scratch
efsmount=`cat /etc/fstab | grep rstudio | awk '{print $1}'`
mount -t efs ${efsmount}scratch /scratch
fi

66 changes: 27 additions & 39 deletions parallelcluster/scripts/install-pwb-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ mkdir -p /home/rstudio/shared-storage

SHARED_DATA="/home/rstudio/shared-storage"

PWB_VERSION=$1

# Label this node as head-node so we can detect it later
touch /etc/head-node

# Download session components and store them in $PWB_BASE_DIR/scripts

pushd $PWB_BASE_DIR/scripts
curl -O https://s3.amazonaws.com/rstudio-ide-build/session/jammy/amd64/rsp-session-jammy-${PWB_VERSION}-amd64.tar.gz
curl -O https://s3.amazonaws.com/rstudio-ide-build/server/jammy/amd64/rstudio-workbench-${PWB_VERSION}-amd64.deb
popd

# Add SLURM integration

# wait until ELB is available and then set this to make sure workbench jobs are working
Expand Down Expand Up @@ -370,45 +379,24 @@ if [ \$pwb_version -lt 2023120 ] && \
sed -i '/events.*/i worker_rlimit_nofile 4096;' /usr/lib/rstudio-server/conf/rserver-http.conf
fi
if (mount | grep login_nodes >&/dev/null) && [ ! -f /etc/head-node ]; then
# we are on a login node and need to start the workbench processes
# but we need to make sure the config files are all there
while true ; do if [ -f /opt/rstudio/etc/rstudio/rserver.conf ]; then break; fi; sleep 1; done ; echo "PWB config files found !"
if [ ! -f /etc/systemd/system/rstudio-server.service.d/override.conf ]; then
# systemctl overrides
for i in server launcher
do
mkdir -p /etc/systemd/system/rstudio-\$i.service.d
echo -e "[Service]\nEnvironment=\"RSTUDIO_CONFIG_DIR=/opt/rstudio/etc/rstudio\"" > /etc/systemd/system/rstudio-\$i.service.d/override.conf
done
# We are on a login node and hence will need to enable rstudio-server and rstudio-launcher
# scalability
sysctl -w net.unix.max_dgram_qlen=8192
sysctl -w net.core.netdev_max_backlog=65535
systemctl daemon-reload
systemctl enable rstudio-server
systemctl enable rstudio-launcher
#rm -f /var/lib/rstudio-server/secure-cookie-key
#rm -f /opt/rstudio/etc/rstudio/launcher.pub
#rm -f /opt/rstudio/etc/rstudio/launcher.pem
systemctl start rstudio-launcher
systemctl start rstudio-server
#rm -f /var/lib/rstudio-server/secure-cookie-key
#systemctl restart rstudio-server
# Touch a file in /opt/rstudio to signal that workbench is running on this server
touch /opt/rstudio/workbench-\`hostname\`.state
fi
if [ -f /opt/rstudio/etc/rstudio/rserver.conf ] && [ ! -f /opt/rstudio/workbench-\`hostname\`.state ]; then
systemctl stop rstudio-server
systemctl stop rstudio-launcher
systemctl start rstudio-launcher
systemctl start rstudio-server
touch /opt/rstudio/workbench-\`hostname\`.state
fi
if (mount | grep login_nodes >&/dev/null) && [ ! -f /etc/head-node ]; then
# yay - we are on a login node
if [ ! -f /etc/login-node-is-setup ]; then
# we have not set up workbench so let's do it
touch /etc/login-node-is-setup
$PWB_BASE_DIR/scripts/config-login.sh $PWB_CONFIG_DIR $PWB_VERSION
fi
if [ -f /opt/rstudio/etc/rstudio/rserver.conf ] && [ ! -f /opt/rstudio/workbench-\`hostname\`.state ]; then
# Something wants us to restart so let's do it
systemctl stop rstudio-server
systemctl stop rstudio-launcher
killall apache2
rm -rf /var/log/rstudio
systemctl start rstudio-launcher
systemctl start rstudio-server
touch /opt/rstudio/workbench-\`hostname\`.state
fi
fi
if ( ! grep AD_DNS /etc/hosts >& /dev/null ); then
Expand Down

0 comments on commit bc1cb06

Please sign in to comment.