Skip to content

Commit 93c87f1

Browse files
a-r-ncopybara-github
authored andcommitted
gce-nic-naming: restore fallback to hardcoded ip paths
We observe that in some distributions (RHEL-like), `ip` is not available in the `PATH` when udev rules execute. PiperOrigin-RevId: 873043850
1 parent deb0e11 commit 93c87f1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/usr/bin/gce-nic-naming

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,24 @@ function name_gpu_greater_ethernet() {
458458
}
459459

460460
function run_ip_cmd() {
461-
debug "Running command: ip $@"
462-
if [[ "$TEST" != "test" ]]; then
463-
ip "$@"
461+
local ip_cmd=""
462+
if [[ $TEST == 'test' ]]; then
463+
ip_cmd="debug ip"
464+
elif command -v ip >/dev/null 2>&1; then
465+
ip_cmd=$(command -v ip)
466+
elif [[ -x /usr/sbin/ip ]]; then
467+
ip_cmd='/usr/sbin/ip'
468+
elif [[ -x /sbin/ip ]]; then
469+
ip_cmd='/sbin/ip'
470+
elif [[ -x /bin/ip ]]; then
471+
ip_cmd='/bin/ip'
464472
fi
473+
474+
if [[ -z "${ip_cmd}" ]]; then
475+
error_and_exit "ip command not found"
476+
fi
477+
debug "Running command: ${ip_cmd} $@"
478+
${ip_cmd} "$@"
465479
}
466480

467481
#################################

0 commit comments

Comments
 (0)