From ead392ae9235a7a63a1e1b113b720696347f43b1 Mon Sep 17 00:00:00 2001 From: nkinkade Date: Wed, 30 Oct 2024 13:40:40 -0600 Subject: [PATCH] Removes the errexit shell option from generate_network_config.sh (#276) * Removes the bash -e shopt to avoid script exiting on error The script runs a loop that checks for a files that may not exist. With -e set, if it tries to list the files and they don't exist then the script exits. This commit simply removes the -e shell option. There is likely some other workaround, but this is pretty simple. * Changes fq qdisc config script to look for carrier file The file /sys/class/net/ethN/carrier is what the generate-network-config script uses, and is probably more appropriate to the intention, and it was just an oversight that this file didn't previously get changed too. --- configs/stage3_ubuntu/opt/mlab/bin/configure_tc_fq.sh | 6 ++++-- .../stage3_ubuntu/opt/mlab/bin/generate_network_config.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configs/stage3_ubuntu/opt/mlab/bin/configure_tc_fq.sh b/configs/stage3_ubuntu/opt/mlab/bin/configure_tc_fq.sh index b57b76c..c23ef01 100755 --- a/configs/stage3_ubuntu/opt/mlab/bin/configure_tc_fq.sh +++ b/configs/stage3_ubuntu/opt/mlab/bin/configure_tc_fq.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -ux + # This script writes out a Prometheus metric file which will be collected by the # node_exporter textfile collector. Make sure that METRIC_DIR exists. METRIC_DIR=/cache/data/node-exporter @@ -23,8 +25,8 @@ function write_metric_file { # with a link. Set the default to eth0 as a fallback. DEVICE="eth0" for i in /sys/class/net/eth*; do - STATE=$(cat $i/operstate) - if [[ $STATE == "up" ]]; then + CARRIER=$(cat $i/carrier) + if [[ $CARRIER == "1" ]]; then DEVICE=$(basename $i) break fi diff --git a/configs/stage3_ubuntu/opt/mlab/bin/generate_network_config.sh b/configs/stage3_ubuntu/opt/mlab/bin/generate_network_config.sh index 35b8969..274ca42 100755 --- a/configs/stage3_ubuntu/opt/mlab/bin/generate_network_config.sh +++ b/configs/stage3_ubuntu/opt/mlab/bin/generate_network_config.sh @@ -4,7 +4,7 @@ # writes a networkd configuration file for the static IP to the named file. # generate_network_config also sets the machine hostname. -set -euxo pipefail +set -ux OUTPUT=${1:?Please provide the name for writing config file}