From 2be7ccac33881255a9164002baf0eef16538e5e2 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 12:24:32 -0500 Subject: [PATCH 1/7] Add function to notify user that log_size_limit may be incorrect --- salt/common/tools/sbin/soup | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index c1b649610..b7471c9f8 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -120,6 +120,58 @@ check_sudoers() { fi } +check_log_size_limit() { + local num_minion_pillars + num_minion_pillars=$(find /opt/so/saltstack/local/pillar/minions/ -type f | wc -l) + + if [[ $num_minion_pillars -gt 1 ]]; then + echo "[INFO] The value of log_size_limit in the minion pillars may be incorrect." + echo " -> We recommend checking and adjusting the values as necessary." + else + local minion_id + minion_id=$(lookup_salt_value "id" "" "grains") + + local minion_arr + IFS='_' read -ra minion_arr <<< "$minion_id" + + local node_type="${minion_arr[0]}" + + local current_limit + current_limit=$(lookup_pillar "log_size_limit" "elasticsearch") + + local percent + case $node_type in + 'standalone' | 'eval') + percent=50 + ;; + *) + percent=80 + ;; + esac + + local disk_dir="/" + if [ -d /nsm ]; then + disk_dir="/nsm" + fi + + local disk_size_1k + disk_size_1k=$(df $disk_dir | grep -v "^Filesystem" | awk '{print $2}') + + local ratio="1048576" + + local disk_size_gb + disk_size_gb=$( echo "$disk_size_1k" "$ratio" | awk '{print($1/$2)}' ) + + local new_limit + new_limit=$( echo "$disk_size_gb" "$percent" | awk '{printf("%.0f", $1 * ($2/100))}') + + if [[ $current_limit != "$new_limit" ]]; then + echo "[WARNING] The value of log_size_limit (${current_limit}) does not match the recommended value of ${new_limit}." + echo " -> We recommend checking and adjusting the value as necessary." + fi + fi +} + clean_dockers() { # Place Holder for cleaning up old docker images echo "Trying to clean up old dockers." @@ -662,6 +714,8 @@ fi check_sudoers +check_log_size_limit + } main "$@" | tee /dev/fd/3 From 4507a89d9510909cafb7875130f93368d74cba60 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 12:24:54 -0500 Subject: [PATCH 2/7] tar arg fix (-x -> -z) --- salt/common/tools/sbin/soup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index b7471c9f8..1a33a7895 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -211,7 +211,7 @@ generate_and_clean_tarballs() { local new_version new_version=$(cat $UPDATE_DIR/VERSION) [ -d /opt/so/repo ] || mkdir -p /opt/so/repo - tar -cxf "/opt/so/repo/$new_version.tar.gz" "$UPDATE_DIR" + tar -czf "/opt/so/repo/$new_version.tar.gz" "$UPDATE_DIR" find "/opt/so/repo" -type f -not -name "$new_version.tar.gz" -exec rm -rf {} \; } From ac6f1df86f30dd2818b6b2d2df2d1eb8915ba8c5 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 12:33:36 -0500 Subject: [PATCH 3/7] [fix] Only check log_size_limit on .2X -> .30 * Since we're showing a message in the middle of soup, wait for keypress if it's shown --- salt/common/tools/sbin/soup | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index 1a33a7895..76addeb13 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -121,10 +121,13 @@ check_sudoers() { } check_log_size_limit() { + local wait_for_enter=false + local num_minion_pillars num_minion_pillars=$(find /opt/so/saltstack/local/pillar/minions/ -type f | wc -l) if [[ $num_minion_pillars -gt 1 ]]; then + wait_for_enter=true echo "[INFO] The value of log_size_limit in the minion pillars may be incorrect." echo " -> We recommend checking and adjusting the values as necessary." else @@ -166,9 +169,16 @@ check_log_size_limit() { new_limit=$( echo "$disk_size_gb" "$percent" | awk '{printf("%.0f", $1 * ($2/100))}') if [[ $current_limit != "$new_limit" ]]; then + wait_for_enter=true echo "[WARNING] The value of log_size_limit (${current_limit}) does not match the recommended value of ${new_limit}." echo " -> We recommend checking and adjusting the value as necessary." fi + + if [[ $wait_for_enter == true ]]; then + echo "" + read -n 1 -s -r -p "Press any key to continue..." + echo "" # Since read doesn't print a newline, print one for it + fi fi } @@ -392,6 +402,7 @@ up_2.3.2X_to_2.3.30() { for pillar in "${minion_pillars[@]}"; do sed -i -r "s/ (\{\{.*}})$/ '\1'/g" "$pillar" done + check_log_size_limit } space_check() { @@ -714,7 +725,7 @@ fi check_sudoers -check_log_size_limit + } From ece79379a504ef315ed96b3ce40ecb5ce6ab7b68 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 12:54:14 -0500 Subject: [PATCH 4/7] Add file name/path to log_size_limit message --- salt/common/tools/sbin/soup | 2 ++ 1 file changed, 2 insertions(+) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index 76addeb13..7cdd0dd2c 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -130,6 +130,7 @@ check_log_size_limit() { wait_for_enter=true echo "[INFO] The value of log_size_limit in the minion pillars may be incorrect." echo " -> We recommend checking and adjusting the values as necessary." + echo " -> Minion pillar directory: /opt/so/saltstack/local/pillar/minions/" else local minion_id minion_id=$(lookup_salt_value "id" "" "grains") @@ -172,6 +173,7 @@ check_log_size_limit() { wait_for_enter=true echo "[WARNING] The value of log_size_limit (${current_limit}) does not match the recommended value of ${new_limit}." echo " -> We recommend checking and adjusting the value as necessary." + echo " -> File: /opt/so/saltstack/local/pillar/minions/${minion_id}.sls" fi if [[ $wait_for_enter == true ]]; then From 298f7da90bab838ff8709bb5dc41b526a4b00397 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 13:56:33 -0500 Subject: [PATCH 5/7] Fix indent in set_default_log_size --- setup/so-functions | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 4410e7443..9275199c4 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -2283,28 +2283,29 @@ sensor_pillar() { } set_default_log_size() { - local percentage + local percentage case $install_type in STANDALONE | EVAL | HEAVYNODE) percentage=50 - ;; + ;; *) - percentage=80 - ;; - esac + percentage=80 + ;; + esac local disk_dir="/" if [ -d /nsm ]; then disk_dir="/nsm" fi + local disk_size_1k disk_size_1k=$(df $disk_dir | grep -v "^Filesystem" | awk '{print $2}') - local ratio="1048576" + local ratio="1048576" - local disk_size_gb - disk_size_gb=$( echo "$disk_size_1k" "$ratio" | awk '{print($1/$2)}' ) + local disk_size_gb + disk_size_gb=$( echo "$disk_size_1k" "$ratio" | awk '{print($1/$2)}' ) log_size_limit=$( echo "$disk_size_gb" "$percentage" | awk '{printf("%.0f", $1 * ($2/100))}') } From e500e248020f16603221f9e85154247ebc183d10 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 13:56:59 -0500 Subject: [PATCH 6/7] Only show log_size_limit warning on dist if heavynode pillars exist --- salt/common/tools/sbin/soup | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index 7cdd0dd2c..1081ea6aa 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -127,10 +127,12 @@ check_log_size_limit() { num_minion_pillars=$(find /opt/so/saltstack/local/pillar/minions/ -type f | wc -l) if [[ $num_minion_pillars -gt 1 ]]; then - wait_for_enter=true - echo "[INFO] The value of log_size_limit in the minion pillars may be incorrect." - echo " -> We recommend checking and adjusting the values as necessary." - echo " -> Minion pillar directory: /opt/so/saltstack/local/pillar/minions/" + if find /opt/so/saltstack/local/pillar/minions/ -type f | grep -q "_heavynode"; then + wait_for_enter=true + echo "[INFO] The value of log_size_limit in any heavy node minion pillars may be incorrect." + echo " -> We recommend checking and adjusting the values as necessary." + echo " -> Minion pillar directory: /opt/so/saltstack/local/pillar/minions/" + fi else local minion_id minion_id=$(lookup_salt_value "id" "" "grains") From 775f274962d0d3966fa1cfb5c7cc6d8ded95d05e Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 24 Feb 2021 14:36:41 -0500 Subject: [PATCH 7/7] Also check /nsm/elasticsearch in soup log_size_limit check Reflect changes from PR#3079 --- setup/so-functions | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/so-functions b/setup/so-functions index 9275199c4..1336406b6 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -2298,6 +2298,9 @@ set_default_log_size() { if [ -d /nsm ]; then disk_dir="/nsm" fi + if [ -d /nsm/elasticsearch ]; then + disk_dir="/nsm/elasticsearch" + fi local disk_size_1k disk_size_1k=$(df $disk_dir | grep -v "^Filesystem" | awk '{print $2}')