Skip to content

Commit d647a4e

Browse files
committed
Make nw config more robust
1 parent d8415ce commit d647a4e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cookbooks/aws-parallelcluster-environment/files/default/network_interfaces/configure_nw_interface.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
set -e
1010

11-
# commented out inputs that are not required and don't exist for efa-only interfaces
1211
if
1312
[ -z "${DEVICE_NUMBER}" ] || # index of the device
1413
[ -z "${NETWORK_CARD_INDEX}" ] || # index of the network card
@@ -21,11 +20,17 @@ then
2120
fi
2221

2322
# Check if this is an EFA-only interface (no device name or IP)
24-
if [ -z "${DEVICE_NAME}" ] || [ -z "${DEVICE_IP_ADDRESS}" ]; then
23+
if [ -z "${DEVICE_NAME}" ] && [ -z "${DEVICE_IP_ADDRESS}" ]; then
2524
echo "EFA-only interface detected - skipping IP configuration"
2625
exit 0
2726
fi
2827

28+
# If one of these is missing but not both, it is an invalid configuration
29+
if [ -z "${DEVICE_NAME}" ] || [ -z "${DEVICE_IP_ADDRESS}" ]; then
30+
echo "One or more environment variables missing"
31+
exit 1
32+
fi
33+
2934
SUFFIX=$NETWORK_CARD_INDEX$(printf "%02d" $DEVICE_NUMBER)
3035

3136
ROUTE_TABLE="$(( $SUFFIX + 1000 ))"

0 commit comments

Comments
 (0)