Skip to content

Commit d562445

Browse files
authored
Merge pull request #11619 from Security-Onion-Solutions/revert-11612-upgrade/salt3006.3
Revert "Upgrade/salt3006.3"
2 parents 205748e + c41e19a commit d562445

File tree

7 files changed

+305
-2053
lines changed

7 files changed

+305
-2053
lines changed

salt/common/tools/sbin/so-common

+11-64
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,15 @@ check_salt_master_status() {
152152
return 0
153153
}
154154

155-
# this is only intended to be used to check the status of the minion
156155
check_salt_minion_status() {
157-
local minion="$1"
158-
local timeout="${2:-5}"
159-
local logfile="${3:-'/dev/stdout'}"
160-
echo "Checking if the salt minion will respond to jobs" >> "$logfile" 2>&1
161-
salt "$minion" test.ping -t $timeout > /dev/null 2>&1
156+
local timeout="${1:-5}"
157+
echo "Checking if the salt minion will respond to jobs" >> "$setup_log" 2>&1
158+
salt "$MINION_ID" test.ping -t $timeout > /dev/null 2>&1
162159
local status=$?
163160
if [ $status -gt 0 ]; then
164-
echo " Minion did not respond" >> "$logfile" 2>&1
161+
echo " Minion did not respond" >> "$setup_log" 2>&1
165162
else
166-
echo " Received job response from salt minion" >> "$logfile" 2>&1
163+
echo " Received job response from salt minion" >> "$setup_log" 2>&1
167164
fi
168165

169166
return $status
@@ -443,24 +440,6 @@ run_check_net_err() {
443440
fi
444441
}
445442

446-
wait_for_salt_minion() {
447-
local minion="$1"
448-
local timeout="${2:-5}"
449-
local logfile="${3:-'/dev/stdout'}"
450-
retry 60 5 "journalctl -u salt-minion.service | grep 'Minion is ready to receive requests'" >> "$logfile" 2>&1 || fail
451-
local attempt=0
452-
# each attempts would take about 15 seconds
453-
local maxAttempts=20
454-
until check_salt_minion_status "$minion" "$timeout" "$logfile"; do
455-
attempt=$((attempt+1))
456-
if [[ $attempt -eq $maxAttempts ]]; then
457-
return 1
458-
fi
459-
sleep 10
460-
done
461-
return 0
462-
}
463-
464443
salt_minion_count() {
465444
local MINIONDIR="/opt/so/saltstack/local/pillar/minions"
466445
MINIONCOUNT=$(ls -la $MINIONDIR/*.sls | grep -v adv_ | wc -l)
@@ -473,51 +452,19 @@ set_os() {
473452
OS=rocky
474453
OSVER=9
475454
is_rocky=true
476-
is_rpm=true
477455
elif grep -q "CentOS Stream release 9" /etc/redhat-release; then
478456
OS=centos
479457
OSVER=9
480458
is_centos=true
481-
is_rpm=true
482-
elif grep -q "AlmaLinux release 9" /etc/redhat-release; then
483-
OS=alma
459+
elif grep -q "Oracle Linux Server release 9" /etc/system-release; then
460+
OS=oel
484461
OSVER=9
485-
is_alma=true
486-
is_rpm=true
487-
elif grep -q "Red Hat Enterprise Linux release 9" /etc/redhat-release; then
488-
if [ -f /etc/oracle-release ]; then
489-
OS=oracle
490-
OSVER=9
491-
is_oracle=true
492-
is_rpm=true
493-
else
494-
OS=rhel
495-
OSVER=9
496-
is_rhel=true
497-
is_rpm=true
498-
fi
462+
is_oracle=true
499463
fi
500464
cron_service_name="crond"
501-
elif [ -f /etc/os-release ]; then
502-
if grep -q "UBUNTU_CODENAME=focal" /etc/os-release; then
503-
OSVER=focal
504-
UBVER=20.04
505-
OS=ubuntu
506-
is_ubuntu=true
507-
is_deb=true
508-
elif grep -q "UBUNTU_CODENAME=jammy" /etc/os-release; then
509-
OSVER=jammy
510-
UBVER=22.04
511-
OS=ubuntu
512-
is_ubuntu=true
513-
is_deb=true
514-
elif grep -q "VERSION_CODENAME=bookworm" /etc/os-release; then
515-
OSVER=bookworm
516-
DEBVER=12
517-
is_debian=true
518-
OS=debian
519-
is_deb=true
520-
fi
465+
else
466+
OS=ubuntu
467+
is_ubuntu=true
521468
cron_service_name="cron"
522469
fi
523470
}

salt/manager/tools/sbin/soup

+13-49
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ stop_salt_master() {
460460
echo ""
461461
echo "Killing any queued Salt jobs on the manager."
462462
pkill -9 -ef "/usr/bin/python3 /bin/salt" >> $SOUP_LOG 2>&1
463+
set -e
463464

464465
echo ""
465466
echo "Storing salt-master pid."
466467
MASTERPID=$(pgrep -f '/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-master MainProcess')
467468
echo "Found salt-master PID $MASTERPID"
468469
systemctl_func "stop" "salt-master"
469470
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."
470-
set -e
471471
}
472472

473473
stop_salt_minion() {
@@ -480,12 +480,14 @@ stop_salt_minion() {
480480
echo ""
481481
echo "Killing Salt jobs on this node."
482482
salt-call saltutil.kill_all_jobs --local
483+
set -e
483484

484485
echo "Storing salt-minion pid."
485486
MINIONPID=$(pgrep -f '/opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion' | head -1)
486487
echo "Found salt-minion PID $MINIONPID"
487488
systemctl_func "stop" "salt-minion"
488489

490+
set +e
489491
timeout 30 tail --pid=$MINIONPID -f /dev/null || echo "Killing salt-minion at $(date +"%T.%6N") after waiting 30s" && pkill -9 -ef /usr/bin/salt-minion
490492
set -e
491493
}
@@ -618,7 +620,6 @@ upgrade_check_salt() {
618620
if [ "$INSTALLEDSALTVERSION" == "$NEWSALTVERSION" ]; then
619621
echo "You are already running the correct version of Salt for Security Onion."
620622
else
621-
echo "Salt needs to be upgraded to $NEWSALTVERSION."
622623
UPGRADESALT=1
623624
fi
624625
}
@@ -627,48 +628,22 @@ upgrade_salt() {
627628
SALTUPGRADED=True
628629
echo "Performing upgrade of Salt from $INSTALLEDSALTVERSION to $NEWSALTVERSION."
629630
echo ""
630-
# If rhel family
631-
if [[ $is_rpm ]]; then
631+
# If CentOS
632+
if [[ $OS == 'centos' ]]; then
632633
echo "Removing yum versionlock for Salt."
633634
echo ""
634635
yum versionlock delete "salt-*"
635636
echo "Updating Salt packages."
636637
echo ""
637638
set +e
638-
# if oracle run with -r to ignore repos set by bootstrap
639-
if [[ $OS == 'oracle' ]]; then
640-
run_check_net_err \
641-
"sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -X -r -F -M -x python3 stable \"$NEWSALTVERSION\"" \
642-
"Could not update salt, please check $SOUP_LOG for details."
643-
# if another rhel family variant we want to run without -r to allow the bootstrap script to manage repos
644-
else
645-
run_check_net_err \
646-
"sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -X -F -M -x python3 stable \"$NEWSALTVERSION\"" \
647-
"Could not update salt, please check $SOUP_LOG for details."
648-
fi
639+
run_check_net_err \
640+
"sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -X -r -F -M -x python3 stable \"$NEWSALTVERSION\"" \
641+
"Could not update salt, please check $SOUP_LOG for details."
649642
set -e
650643
echo "Applying yum versionlock for Salt."
651644
echo ""
652645
yum versionlock add "salt-*"
653646
# Else do Ubuntu things
654-
elif [[ $is_deb ]]; then
655-
echo "Removing apt hold for Salt."
656-
echo ""
657-
apt-mark unhold "salt-common"
658-
apt-mark unhold "salt-master"
659-
apt-mark unhold "salt-minion"
660-
echo "Updating Salt packages."
661-
echo ""
662-
set +e
663-
run_check_net_err \
664-
"sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -X -F -M -x python3 stable \"$NEWSALTVERSION\"" \
665-
"Could not update salt, please check $SOUP_LOG for details."
666-
set -e
667-
echo "Applying apt hold for Salt."
668-
echo ""
669-
apt-mark hold "salt-common"
670-
apt-mark hold "salt-master"
671-
apt-mark hold "salt-minion"
672647
fi
673648

674649
echo "Checking if Salt was upgraded."
@@ -680,7 +655,7 @@ upgrade_salt() {
680655
echo "Once the issue is resolved, run soup again."
681656
echo "Exiting."
682657
echo ""
683-
exit 1
658+
exit 0
684659
else
685660
echo "Salt upgrade success."
686661
echo ""
@@ -810,7 +785,7 @@ main() {
810785
if [[ $is_airgap -eq 0 ]]; then
811786
yum clean all
812787
check_os_updates
813-
elif [[ $OS == 'oracle' ]]; then
788+
elif [[ $OS == 'oel' ]]; then
814789
# sync remote repo down to local if not airgap
815790
repo_sync
816791
check_os_updates
@@ -827,8 +802,7 @@ main() {
827802
echo "Hotfix applied"
828803
update_version
829804
enable_highstate
830-
(wait_for_salt_minion "$MINIONID" "5" '/dev/stdout' || fail "Salt minion was not running or ready.") 2>&1 | tee -a "$SOUP_LOG"
831-
highstate
805+
salt-call state.highstate -l info queue=True
832806
else
833807
echo ""
834808
echo "Performing upgrade from Security Onion $INSTALLEDVERSION to Security Onion $NEWVERSION."
@@ -864,14 +838,6 @@ main() {
864838
echo "Upgrading Salt"
865839
# Update the repo files so it can actually upgrade
866840
upgrade_salt
867-
868-
# for Debian based distro, we need to stop salt again after upgrade output below is from bootstrap-salt
869-
# * WARN: Not starting daemons on Debian based distributions
870-
# is not working mostly because starting them is the default behaviour.
871-
if [[ $is_deb ]]; then
872-
stop_salt_minion
873-
stop_salt_master
874-
fi
875841
fi
876842

877843
preupgrade_changes
@@ -934,8 +900,7 @@ main() {
934900
echo ""
935901
echo "Running a highstate. This could take several minutes."
936902
set +e
937-
(wait_for_salt_minion "$MINIONID" "5" '/dev/stdout' || fail "Salt minion was not running or ready.") 2>&1 | tee -a "$SOUP_LOG"
938-
highstate
903+
salt-call state.highstate -l info queue=True
939904
set -e
940905

941906
stop_salt_master
@@ -950,8 +915,7 @@ main() {
950915
set -e
951916

952917
echo "Running a highstate to complete the Security Onion upgrade on this manager. This could take several minutes."
953-
(wait_for_salt_minion "$MINIONID" "5" '/dev/stdout' || fail "Salt minion was not running or ready.") 2>&1 | tee -a "$SOUP_LOG"
954-
highstate
918+
salt-call state.highstate -l info queue=True
955919
postupgrade_changes
956920
[[ $is_airgap -eq 0 ]] && unmount_update
957921

salt/salt/map.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{% if grains.os|lower in ['Rocky', 'redhat', 'CentOS Stream'] %}
2424
{% set UPGRADECOMMAND = 'yum clean all ; /usr/sbin/bootstrap-salt.sh -s 120 -r -F -x python3 stable ' ~ SALTVERSION %}
2525
{% elif grains.os_family|lower == 'debian' %}
26-
{% set UPGRADECOMMAND = '/usr/sbin/bootstrap-salt.sh -s 120 -F -x python3 stable ' ~ SALTVERSION %}
26+
{% set UPGRADECOMMAND = '/usr/sbin/bootstrap-salt.sh -s 120 -r -F -x python3 stable ' ~ SALTVERSION %}
2727
{% endif %}
2828
{% else %}
2929
{% set UPGRADECOMMAND = 'echo Already running Salt Minion version ' ~ SALTVERSION %}

salt/salt/master.defaults.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# When updating the salt version, also update the version in securityonion-builds/images/iso-task/Dockerfile and saltify function in so-functions
33
salt:
44
master:
5-
version: 3006.3
5+
version: 3006.1

salt/salt/minion.defaults.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# When updating the salt version, also update the version in securityonion-builds/images/iso-task/Dockerfile and saltify function in so-functions
33
salt:
44
minion:
5-
version: 3006.3
5+
version: 3006.1
66
check_threshold: 3600 # in seconds, threshold used for so-salt-minion-check. any value less than 600 seconds may cause a lot of salt-minion restarts since the job to touch the file occurs every 5-8 minutes by default
77
service_start_delay: 30 # in seconds.

0 commit comments

Comments
 (0)