Skip to content

Commit

Permalink
Adding timeout for command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
gpunathilell committed May 1, 2024
1 parent aeeb243 commit 57eb6ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 0 additions & 8 deletions platform/mellanox/mlnx-sonic-bfb-installer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@

MLNX_SONIC_BFB_INSTALL = sonic-bfb-installer
$(MLNX_SONIC_BFB_INSTALL)_PATH = $(PLATFORM_PATH)/



MLNX_BFB_FILES = $(MLNX_SONIC_BFB_INSTALL)


SONIC_COPY_FILES += $(MLNX_BFB_FILES)


MLNX_FILES += $(MLNX_BFB_FILES)

export MLNX_SONIC_BFB_INSTALL
export MLNX_BFB_INSTALL
12 changes: 10 additions & 2 deletions platform/mellanox/sonic-bfb-installer
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bfb_install_call(){
#Example:sudo bfb-install -b <full path to image> -r rshim<id>
local result_file=$(mktemp "/tmp/result_file.XXXXX")
trap "rm -f $result_file" EXIT
local cmd="sudo bfb-install -b $2 -r $1 $appendix"
local cmd="timeout 300s ./bfb-install -b $2 -r $1 $appendix"
echo "Installing bfb image on DPU connected to $1 using $cmd"
local indicator="$1:"
eval "$cmd" > "$result_file" 2>&1 > >(while IFS= read -r line; do echo "$indicator $line"; done > "$result_file")
Expand Down Expand Up @@ -70,6 +70,8 @@ check_for_root(){
fi
}



main(){
check_for_root
local config=
Expand Down Expand Up @@ -126,7 +128,7 @@ main(){
validate_rshim $dev_names
fi
fi
trap 'pkill -P $$' SIGINT SIGTERM SIGHUP
trap 'kill_ch_procs' SIGINT SIGTERM SIGHUP
for i in "${dev_names[@]}"
do
:
Expand All @@ -135,6 +137,12 @@ main(){
wait
}

kill_ch_procs(){
echo ""
echo "Installation Interrupted.. killing All child procs"
pkill -P $$
}

appendix=
verbose=false
main "$@"

0 comments on commit 57eb6ae

Please sign in to comment.