Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistently tgswitch command returned "Unable to get release from repo" #88

Closed
pulakiitr opened this issue Sep 10, 2021 · 10 comments · Fixed by #98
Closed

inconsistently tgswitch command returned "Unable to get release from repo" #88

pulakiitr opened this issue Sep 10, 2021 · 10 comments · Fixed by #98
Assignees
Labels
bug Something isn't working

Comments

@pulakiitr
Copy link

pulakiitr commented Sep 10, 2021

~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch --version

Version: 0.4.326
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$

~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ mkdir ~/tg-test

~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
Switched terragrunt to version "0.28.7" 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
Switched terragrunt to version "0.28.7" 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
Switched terragrunt to version "0.28.7" 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:22:45 Unable to get release from repo 
2021/09/09 21:22:45 Unable to make request Please try again.
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:22:48 Unable to make request Please try again.
2021/09/09 21:22:48 Unable to make request Please try again.
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:22:50 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:22:53 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:22:55 Unable to get release from repo 
2021/09/09 21:22:55 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:22:58 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:02 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:03 Unable to get release from repo 
2021/09/09 21:23:03 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:05 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:07 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:09 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:11 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:13 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:16 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:19 Unable to get release from repo 
2021/09/09 21:23:19 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:21 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:24 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:26 Unable to get release from repo 
2021/09/09 21:23:26 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:29 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:31 Unable to get release from repo 
2021/09/09 21:23:31 Unable to get release from repo 
2021/09/09 21:23:31 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ tgswitch -b ~/tg-test/terragrunt 0.28.7
2021/09/09 21:23:43 Unable to get release from repo 
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$ ll ~/tg-test/
total 0
drwxr-xr-x+ 84 xxxxxxxx  staff  2688 Sep  9 21:21 ..
lrwxr-xr-x   1 xxxxxxxx  staff    55 Sep  9 21:22 terragrunt -> /Users/xxxxxx/.terragrunt.versions/terragrunt_0.28.7
drwxr-xr-x   3 xxxxxxxx  staff    96 Sep  9 21:22 .
~/github/azure/az-AKS/modules/deploy_Kubernetes_pod$
@nadirollo
Copy link

nadirollo commented Sep 10, 2021

Same problem here. Fails randomly
Same version (0.4.236)
With the binaries already downloaded, tgswitch is still complaining about:
Unable to get release from repo

root@0687f7a9f59b:/# ls -l ~/.terragrunt.versions/
total 77892
-rw-r--r-- 1 root root       21 Aug 10 14:54 RECENT
-rwxr-xr-x 1 root root 16513684 Aug 10 14:54 terragrunt_0.14.7
-rwxr-xr-x 1 root root 28224568 Aug 10 14:54 terragrunt_0.19.4
-rwxr-xr-x 1 root root 35015542 Aug 10 14:54 terragrunt_0.31.0
root@0687f7a9f59b:/# tgswitch -v

Version: 0.4.326
root@0687f7a9f59b:/# cat .tgswitchrc
0.14.7
root@0687f7a9f59b:/# tgswitch
Reading required terragrunt version .tgswitchrc
2021/09/10 09:30:05 Unable to get release from repo

@mihica123
Copy link

Same here. Switched through a couple of versions, stopped working.
Even after purging the PATH of the tgswitch executable and rerunning the install script.

@Vishwas1976
Copy link

same issue

@steven-edgar
Copy link
Contributor

steven-edgar commented Sep 30, 2021

Also seeing this, I've tried tgswitch versions 0.4.326, 0.4.315 & 0.3.308.
Hitting github directly, either to download a release or list releases, works fine, eg
curl https://api.github.com/repos/gruntwork-io/terragrunt/releases/
Similarly to other reporters I'm seeing this error whether or not I've already got the relevant version of Terragrunt in ~/.terragrunt.versions/
To me there are 2 bugs here, firstly tgswitch trying to (I think) list versions available on github even when the version requested is already available locally, and secondly the issue actually communicating with Github.

UPDATE
I've just cloned the main branch for tgswitch and built the code, then using the resulting binary run the same "tgswitch -b ~/bin/terragrunt 0.33.1" command, and get the following more detailed output
2021/09/30 14:36:51 Unable to get release from repo {"message":"API rate limit exceeded for 1.2.3.4. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"} 2021/09/30 14:36:51 json: cannot unmarshal object into Go value of type []modal.Repo

I suspect Github have changed their rate-limiting, and tgswitch is now failing because of that.

@steven-edgar
Copy link
Contributor

I've created a fork of this project with fixes in, so that it only hits Github if the version requested doesn't already exist in ~/.terragrunt.versions/. I suspect the way the code is actually accessing github is generating too many requests, but that's beyond my abilities to fix, as I've not really dealt with Go before. Upstream may not want to take this change as-is, but it works for me. Clone it, install go (yum install epel-release && yum install golang), then run "make release". https://github.com/steven-edgar/tgswitch. I've tested with switching between existing versions and downloading a new one, and using a .tgswitchrc file to specify the version, all using the '-b' flag to set the bin location as I don't have access to /usr/local/bin on this system, so haven't tested that.

@korenshoshan
Copy link

Same here.

@Ian-T-Price
Copy link

Ian-T-Price commented Nov 9, 2021

Thanks for your efforts @steven-edgar; I think you've hit the nail on the head.

I tried your code but it didn't work initially. I then figured out that I was still rate limited at the time. After that period lapsed it has worked well for me.

The link mentioned (https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting) makes reference to a URL to check the API usage. HOWEVER, that hits the API and uses up your quota! Doh!

The quota is 60 requests per hour. There is a check that does not hit your API rate limit which can be found at: https://docs.github.com/en/rest/reference/search#rate-limit

I've created an alias to put this into a useable format. This probably ought to be a bash or zsh function but it works. It does require jq JSON parser

alias tgsapi='echo -e "\nRemaining GitHub API requests: $(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/rate_limit | jq ".rate | .remaining")\n\t\t Resets at: $(date -d @$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/rate_limit | jq ".rate | .reset"))"'

$ tgsapi 

Remaining GitHub API requests: 59
		    Resets at: Tue  9 Nov 12:26:45 GMT 2021

@warrensbox
Copy link
Owner

@Ian-T-Price @korenshoshan @Vishwas1976 @mihica123 @pulakiitr @nadirollo

Please get the latest version of tgswitch - Version: 0.5.378 #98 . See how to get latest here.
Please see the changelog here: https://github.com/warrensbox/tgswitch/blob/master/CHANGELOG.md
I am no longer using github APIs to get the releases. In the older tgswitch version - all users share the same API token (embedded in the app). Github limits the number of calls (used by this API token). Some tgswitch users were unable to switch when tgswitch hits the API limit. Although it worked, it was fundamentally flawed.

The new version of tgswitch gets at a list of the terragrunt version (periodically updates) from here. Once the user selects a version, it should directly download from the gruntwork.io/terragrunt release page. The new version should work faster.

@warrensbox warrensbox self-assigned this Nov 15, 2021
@warrensbox warrensbox added the bug Something isn't working label Nov 15, 2021
@warrensbox warrensbox linked a pull request Nov 15, 2021 that will close this issue
@Ian-T-Price
Copy link

This is working as described; my personal API count is unaffected by downloading different versions of terragrunt.

Many thanks for your time and effort to fix this issue; much appreciated.

I consider this issue closed

@davidjeddy
Copy link

Continue to see this with v 0.6.0 on a Debian Linux box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants