- Notifications
You must be signed in to change notification settings - Fork927
Description
When doing a standard installcurl -L https://coder.com/install.sh | sh
of coder, the api calls to get the latest version is often rate limited by github. This results in a[403](curl: (22) The requested URL returned error: 403)
, which should should prompt the script to fail, but instead returns a blank version. As the version can not be determinedInstalling v of the amd64 rpm package from GitHub.
is printed andcurl -#fL -o ~/.cache/coder/coder__linux_amd64.rpm.incomplete -C - https://github.com/coder/coder/releases/download/v/coder__linux_amd64.rpm
is downloaded
See output:
curl -L https://coder.com/install.sh | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 20209 100 20209 0 0 19137 0 0:00:01 0:00:01 --:--:-- 101kcurl: (22) The requested URL returned error: 403Red Hat Enterprise Linux 9.3 (Plow)Installing v of the amd64 rpm package from GitHub.+ mkdir -p ~/.cache/coder+ curl -#fL -o ~/.cache/coder/coder__linux_amd64.rpm.incomplete -C - https://github.com/coder/coder/releases/download/v/coder__linux_amd64.rpmcurl: (22) The requested URL returned error: 404
A workaround would have been to pass in the version you want
curl -L https://coder.com/install.sh| sh -s -- --version 2.10.0
But this is not honored and the api call is still made.
Expected outcome
- When passing in the version number, we should honor it and ignore getting the latest version
- Not to rely on the github api to get the latest version of coder (or to check for being rate limited)
Possible Fix
Initial change to useVERSION
when set
if [-z"${VERSION}" ];thenif ["${MAINLINE}"= 0 ];then VERSION=${STABLE_VERSION}elseVERSION=$(echo_latest_mainline_version)fifi
also adding a check toecho_latest_mainline_version
would help debugging this issue in the future
echo_latest_mainline_version() {# Fetch the releases from the GitHub API, sort by version number,# and take the first result. Note that we're sorting by space-# separated numbers and without utilizing the sort -V flag for the# best compatibility.version=$(curl -fsSL https://api.github.com/repos/coder/coder/releases|awk -F'"''/"tag_name"/ {print $4}'|tr -d v|tr.''|sort -k1,1nr -k2,2nr -k3,3nr|head -n1|tr'' .)if [-z"$version" ];thenecho"Failed to fetch the latest version from GitHub."exit 1fiecho"$version"}
In general using the GitHub api comes with severe limits when anonymous and via a share NAT ("The primary rate limit for unauthenticated requests is 60 requests per hour."). Maybe an alternative could be used to get the latest stable and mainline releases (like a static file updated on release)
Workaround for stable
Stable installs won't be effected as it is using Github site and not the api.
curl -L https://coder.com/install.sh| sh -s -- --stable