Skip to content

Commit

Permalink
Issue #3326. Introduce new "CP_CAP_MAIL" launch parameter, enable it …
Browse files Browse the repository at this point in the history
…when CP_CAP_SGE with notifications are configured
  • Loading branch information
SilinPavel committed Aug 14, 2023
1 parent 514eac7 commit 5362e08
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,15 @@
{
"name": "CP_CAP_GRID_ENGINE_NOTIFICATIONS",
"type": "boolean",
"defaultValue": "false",
"defaultValue": "true",
"description": "Enables notifications for Slurm and SGE engines.",
"passToWorkers": true
},
{
"name": "CP_CAP_MAIL",
"type": "boolean",
"defaultValue": "true",
"description": "Changes default mail client if favor to pipe_mail script.",
"passToWorkers": true
}
]
23 changes: 23 additions & 0 deletions scripts/pipeline-launch/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ function cp_cap_publish {

sed -i "/$_SGE_WORKER_INIT/d" $_WORKER_CAP_INIT_PATH
echo "$_SGE_WORKER_INIT" >> $_WORKER_CAP_INIT_PATH

# Due to strange behavior of sge_execd with updating global config values,
# we need to change default mail client if favor to our custom
if check_cp_cap "CP_CAP_GRID_ENGINE_NOTIFICATIONS"
then
_PIPE_MAIL_ENABLER_SCRIPT="pipe_mail_enabler"

sed -i "/$_PIPE_MAIL_ENABLER_SCRIPT/d" $_MASTER_CAP_INIT_PATH
echo "$_PIPE_MAIL_ENABLER_SCRIPT" >> $_MASTER_CAP_INIT_PATH

sed -i "/$_PIPE_MAIL_ENABLER_SCRIPT/d" $_WORKER_CAP_INIT_PATH
echo "$_PIPE_MAIL_ENABLER_SCRIPT" >> $_WORKER_CAP_INIT_PATH
fi
fi

if check_cp_cap "CP_CAP_SLURM"
Expand Down Expand Up @@ -1807,6 +1820,16 @@ echo
######################################################


######################################################
echo "Configure custom mail client if requested"
echo "-"
######################################################

if check_cp_cap CP_CAP_MAIL; then
pipe_mail_enabler
fi
######################################################


######################################################
# Setup cluster users sharing if required
Expand Down
23 changes: 23 additions & 0 deletions workflows/pipe-common/shell/pipe_mail_enabler
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Copyright 2017-2020 EPAM Systems, Inc. (https://www.epam.com/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

echo "Linking $COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail as default linux mail client"
rm -rf "/usr/bin/mail" && ln -s "$COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail" "/usr/bin/mail" \
&& rm -rf "/bin/mail" && ln -s "$COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail" "/bin/mail"
if [ "$?" -eq "0" ]; then
echo "Successfully linked $COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail as default linux mail client"
else
echo "Fail to link $COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail"
fi
6 changes: 0 additions & 6 deletions workflows/pipe-common/shell/sge_setup_master
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,6 @@ fi
# Setup any additional SGE consumable resources if available
sge_setup_resources "$HOSTNAME" "$SGE_MASTER_SETUP_TASK" "$_MASTER_WORKER_CORES"

# Override default mail program
if check_cp_cap CP_CAP_GRID_ENGINE_NOTIFICATIONS; then
rm -rf "/usr/bin/mail" && ln -s "$COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail" "/usr/bin/mail"
check_last_exit_code $? "$COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail was linked as as /usr/bin/mail" "Fail to link $COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail"
fi

pipe_log_success "SGE master node was successfully configured" "$SGE_MASTER_SETUP_TASK"

# Wait for worker nodes to initiate and connect to the master
Expand Down
6 changes: 0 additions & 6 deletions workflows/pipe-common/shell/sge_setup_worker
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,4 @@ echo "export SGE_CLUSTER_NAME=$SGE_CLUSTER_NAME" >> /etc/cp_env.sh
# Setup any additional SGE consumable resources if available
sge_setup_resources "$HOSTNAME" "$SGE_WORKER_SETUP_TASK" "$_WORKER_CORES"

# Override default mail program
if check_cp_cap CP_CAP_GRID_ENGINE_NOTIFICATIONS; then
rm -rf "/usr/bin/mail" && ln -s "$COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail" "/usr/bin/mail"
check_last_exit_code $? "$COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail was linked as as /usr/bin/mail" "Fail to link $COMMON_REPO_DIR_MUTUAL_LOC/shell/pipe_mail"
fi

pipe_log_success "SGE worker node was successfully configured" "$SGE_WORKER_SETUP_TASK"

0 comments on commit 5362e08

Please sign in to comment.