From 56666ad82c237ffa068b5af7e0ec81ff53bfb0ea Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Mon, 16 Sep 2024 11:19:16 -0400 Subject: [PATCH 1/2] resolve 13247 --- salt/common/tools/sbin/so-common | 2 ++ salt/manager/tools/sbin/soup | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index 6ae35324f..2b557a306 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -249,8 +249,10 @@ download_and_verify() { fi if ! verify_md5_checksum "$dest_file" "$md5_file"; then + set +e retry 15 10 "curl --fail --retry 5 --retry-delay 15 -L '$source_url' --output '$dest_file'" "" "" retry 15 10 "curl --fail --retry 5 --retry-delay 15 -L '$source_md5_url' --output '$md5_file'" "" "" + set -e if verify_md5_checksum "$dest_file" "$md5_file"; then echo "Source file and checksum are good." diff --git a/salt/manager/tools/sbin/soup b/salt/manager/tools/sbin/soup index 7807c9884..b14cf97e7 100755 --- a/salt/manager/tools/sbin/soup +++ b/salt/manager/tools/sbin/soup @@ -525,11 +525,17 @@ stop_salt_master() { pkill -9 -ef "/usr/bin/python3 /bin/salt" >> $SOUP_LOG 2>&1 echo "" - echo "Storing salt-master pid." + echo "Storing salt-master PID." MASTERPID=$(pgrep -f '/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master MainProcess') - echo "Found salt-master PID $MASTERPID" - systemctl_func "stop" "salt-master" - timeout 30 tail --pid=$MASTERPID -f /dev/null || echo "salt-master still running at $(date +"%T.%6N") after waiting 30s. We cannot kill due to systemd restart option." + if [ ! -z "$MASTERPID" ]; then + echo "Found salt-master PID $MASTERPID" + systemctl_func "stop" "salt-master" + if ps -p "$MASTERPID" > /dev/null 2>&1; then + timeout 30 tail --pid=$MASTERPID -f /dev/null || echo "salt-master still running at $(date +"%T.%6N") after waiting 30s. We cannot kill due to systemd restart option." + fi + else + echo "The salt-master PID was not found. The process '/usr/bin/salt-master MainProcess' is not running." + fi set -e } From 0ab2695cebbd20505392e35373fa373b19161008 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Mon, 16 Sep 2024 13:11:08 -0400 Subject: [PATCH 2/2] move set to soup --- salt/common/tools/sbin/so-common | 2 -- salt/manager/tools/sbin/soup | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/common/tools/sbin/so-common b/salt/common/tools/sbin/so-common index 2b557a306..6ae35324f 100755 --- a/salt/common/tools/sbin/so-common +++ b/salt/common/tools/sbin/so-common @@ -249,10 +249,8 @@ download_and_verify() { fi if ! verify_md5_checksum "$dest_file" "$md5_file"; then - set +e retry 15 10 "curl --fail --retry 5 --retry-delay 15 -L '$source_url' --output '$dest_file'" "" "" retry 15 10 "curl --fail --retry 5 --retry-delay 15 -L '$source_md5_url' --output '$md5_file'" "" "" - set -e if verify_md5_checksum "$dest_file" "$md5_file"; then echo "Source file and checksum are good." diff --git a/salt/manager/tools/sbin/soup b/salt/manager/tools/sbin/soup index b14cf97e7..452300bba 100755 --- a/salt/manager/tools/sbin/soup +++ b/salt/manager/tools/sbin/soup @@ -843,8 +843,10 @@ determine_elastic_agent_upgrade() { if [[ $is_airgap -eq 0 ]]; then update_elastic_agent_airgap else + set +e # the new elasticsearch defaults.yaml file is not yet placed in /opt/so/saltstack/default/salt/elasticsearch yet update_elastic_agent "$UPDATE_DIR" + set -e fi }