Skip to content

Commit

Permalink
Fix Debian OS unable to download binaries
Browse files Browse the repository at this point in the history
- Use `uname -m` as fallback to get the architecture as needed in some distributions such as Debian since `uname -p` outputs "unknown".
- In case the binary URL isn't found based on the architecture then fallback to amd64 based binaries with an error.
  • Loading branch information
ralongit committed Jan 28, 2024
1 parent e766c71 commit 317c487
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 9 additions & 6 deletions scripts/linux/functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ function get_linux_info {
write_log "$LOG_LEVEL_DEBUG" "$message"

local cpu_arch=$(uname -p 2>"$TASK_ERROR_FILE")
if [[ $? -ne 0 ]]; then
message="agent.bash ($EXIT_CODE): error getting cpu arch: $(get_task_error_message)"
send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_PRE_INIT" "$LOG_SCRIPT_AGENT" "$func_name" "$AGENT_ID"
write_task_post_run "write_error \"$message\""
if [[ $? -ne 0 || $cpu_arch == "unknown" ]]; then
cpu_arch=$(uname -m 2>"$TASK_ERROR_FILE")
if [[ $? -ne 0 ]]; then
message="agent.bash ($EXIT_CODE): error getting cpu arch: $(get_task_error_message)"
send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_PRE_INIT" "$LOG_SCRIPT_AGENT" "$func_name" "$AGENT_ID"
write_task_post_run "write_error \"$message\""

return $EXIT_CODE
return $EXIT_CODE
fi
fi

message="CPU architecture is '$cpu_arch'"
send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_PRE_INIT" "$LOG_SCRIPT_AGENT" "$func_name" "$AGENT_ID"
write_log "$LOG_LEVEL_DEBUG" "$message"
Expand Down
5 changes: 4 additions & 1 deletion scripts/linux/utils_functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ function get_arch_specific_url {
elif [[ ( "$CPU_ARCH" == "amd64" || "$CPU_ARCH" == "x86_64" ) && ! -z "$amd_url" ]]; then
echo "$amd_url"
else
echo "error getting arch specific url, arm_url: '$arm_url', amd_url: '$amd_url'"
local message="error getting arch specific url, arm_url: '$arm_url', amd_url: '$amd_url'. Attempting fallback to amd64 arch based URL $amd_url..."
send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" '' "$LOG_SCRIPT_UTILS_FUNCTIONS" "$func_name" "$AGENT_ID"
write_error "$message"
echo "$amd_url"
fi
}

0 comments on commit 317c487

Please sign in to comment.