Skip to content

Commit b223667

Browse files
committed
add retries
1 parent 6ca1a0a commit b223667

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

parts/linux/cloud-init/artifacts/cse_config.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,19 +1004,19 @@ NETWORKD_EOF
10041004
echo "Configured secondary NIC ${iface_name} (mac=${mac}, metric=${metric})"
10051005
done
10061006

1007-
# Apply all configs in a single operation to avoid repeated network restarts
1007+
# Apply all configs in a single operation to avoid repeated network restarts.
10081008
if [ "$is_netplan" = true ]; then
1009-
if ! netplan apply; then
1009+
if ! retrycmd_if_failure 5 3 10 netplan apply; then
10101010
echo "Failed to apply netplan config for secondary NICs" >&2
10111011
return $ERR_SECONDARY_NIC_CONFIG_FAIL
10121012
fi
10131013
else
1014-
if ! networkctl reload; then
1014+
if ! retrycmd_if_failure 5 3 10 networkctl reload; then
10151015
echo "Failed to reload networkd for secondary NICs" >&2
10161016
return $ERR_SECONDARY_NIC_CONFIG_FAIL
10171017
fi
10181018
for i in $(seq 1 $((nic_count - 1))); do
1019-
if ! networkctl up "eth${i}"; then
1019+
if ! retrycmd_if_failure 5 3 10 networkctl up "eth${i}"; then
10201020
echo "Failed to bring up eth${i}" >&2
10211021
return $ERR_SECONDARY_NIC_CONFIG_FAIL
10221022
fi

spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ Describe 'cse_config.sh'
169169
networkctl() {
170170
echo "networkctl $@"
171171
}
172+
retrycmd_if_failure() {
173+
echo "retrycmd_if_failure $@"
174+
shift 3
175+
"$@"
176+
}
172177

173178
It 'should skip when only a single NIC is present'
174179
IMDS_INSTANCE_METADATA_CACHE_FILE="spec/parts/linux/cloud-init/artifacts/imds_mocks/network/single_nic.json"

0 commit comments

Comments
 (0)