23

I tried downloading and using the gcloud bash tool to manage my accounts, however everything I do with the tool is exceptionally slow. It will take MINUTES to reply to a command that is typed.

Is there perhaps a firewall I need to open up on my router or something else to get this to work fast like it's supposed to? For example, the "Installing..." lines in this video https://youtu.be/4y4-xn4Vi04?t=1m21s -- you'll notice they are all complete in the tutorial within a few seconds. This takes over 10 minutes to complete on my machine.

I'm on a newer Macbook Air, and all other internet/etc works really fast. I'm on a decent speed internet connection from AT&T Uverse (30mbps/3mbps). All other browsing is fast and just fine, the only thing in the world I have a problem with is this gcloud tool.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Mark Shust at M.academy
  • 6,300
  • 4
  • 32
  • 50
  • Are others facing the same issue? I am facing this in on Mac OS X El Captain and cant seem to find a clear solution. Running `traceroute www.googleapis.com` reveals the delay on remote Google servers and not at the client or router's end. gcloud version is SDK 169.0.0 – Anupam Sep 05 '17 at 05:35
  • using gcloud on an f1-micro instance is slower than actually starting the whole instance. I really hope Google is going to exchange this extremely bulky tool against something FAST – John Nov 24 '17 at 01:08
  • 1
    I'm getting this recently (on Linux), and using strace have seen that it's when refreshing auth tokens with `gcloud.py config config-helper` - both with the `gcloud` & `kubectl` commands - it appears to be hanging during a DNS lookup of `metadata.google.internal` for me. Using Google's public DNS servers may help. – Andrew Rembrandt Aug 05 '21 at 10:14
  • @AndrewRembrandt Had the exact same behaviour (on an M1 Mac), and traced it back to this same DNS lookup that was hanging. Your solution of adding google's public DNS as a secondary DNS server to my laptop fixed the issue ! – Pierre Avérous May 05 '22 at 13:21
  • 2
    This is still an issue in 2023 for any devs that see this... – alvrm Jan 23 '23 at 18:24

4 Answers4

19

I just ran into a similar issue myself, though not as bad as minute long response times. What helped me was turning off the usage reporting.

Looking at some timings:

$ gcloud config set disable_usage_reporting False
$ time gcloud compute -h | tail -1
  real  0m7.058s
  user  0m0.464s
  sys   0m0.088s

A whopping 7 secs to access the help!

Fortunately, this improves greatly after disabling reporting:

$ gcloud config set disable_usage_reporting True
$ time gcloud compute -h | tail -1
  real  0m0.541s
  user  0m0.459s
  sys   0m0.080s

Much better!

vtrubets
  • 341
  • 1
  • 9
  • What version of the SDK are you currently using? – Mark May 11 '15 at 15:21
  • gcloud -v returns: "Google Cloud SDK 0.9.58" – vtrubets May 12 '15 at 20:20
  • 4
    This answer still applies on Google Cloud SDK 137.0.0! – Conrad Irwin Dec 14 '16 at 08:06
  • 1
    This is still an issue on Google Cloud SDK version 139.0.1 and Mac OS X Sierra. I think it's a different issue from the one noticed by Mark Shust. Commands went from taking about 10 seconds each to taking less than a second. – Michael Younkin Jan 17 '17 at 20:13
  • On windows 10, gcloud ssh into docker-optimized image, not as slow as reported about, but still extremely distracting. Disabling reporting helps only marginally. – bw4sz Jan 18 '17 at 17:41
  • Looks like subsequent runs of the above command (without updating the config) reduces the time anyways (maybe some kind of caching). This what I got on two subsequent runs without any change in the config: First run: `time gcloud compute -h | tail -1 real 0m3.031s user 0m0.756s sys 0m0.477s` Second run: `time gcloud compute -h | tail -1 real 0m0.585s user 0m0.426s sys 0m0.147s` Also I didn't see any visible difference by disabling reporting on ver SDK 169.0.0 – Anupam Sep 05 '17 at 05:16
  • Still pretty slow with v310.0.0. 1.8 sec just for `gcloud -v` or `gcloud config get-value product` on my machine. – GaryO Oct 23 '20 at 14:54
11

I traced this back to packet filters. When I deleted this rule #5 in my AT&T Uverse modem/router (Motorola NVG589), everything works ok. This was a default setting in the modem which caused all sorts of issues.

packet filters

Mark Shust at M.academy
  • 6,300
  • 4
  • 32
  • 50
  • 2
    this answer helped me tremendously.. ipv6 was enabled, had to login to the arris router admin and under firewall, disable `block fragmented ip packets` (enabled by default..) – grgry Sep 17 '17 at 11:38
  • 1
    This help me as well on AT&T Small Business fiber. In fact none of the rules were enabled for us, but I still had this problem. Disabling the packet filter completely solved it. – Gabe Kopley Jan 23 '18 at 17:57
  • 1
    Thank you. I have their fiber service as well. I had to disable all the packet filters as well then reset my broadband connection. – JamWils Feb 01 '18 at 17:16
3

Mark Shust's answer hinted to me that something might be going on with IPv6. Turning this support off in my router brought the gcloud times back to a couple of seconds from over 2 minutes for a gcloud compute machine-types list.

Note: I've also had to turn off IPv6 support in apt for a similar reason so this is likely a problem with my router or ISP, not the google cloud sdk.

  • I just disabled ipv6 on my router and it worked as well – polvoazul Mar 18 '22 at 17:51
  • In addition to my comment on the OP, it turns out my real issue was actually to do with the fact that IPv6 was mis-configured on a second router in my home network (it was requesting prefix delegation when it shouldn't have). As soon as I corrected the prefix issue, the gcloud sdk delays (when renewing auth tokens I suspect) went away. NB: Running `strace -f -e trace=network -s 10000 gcloud ` shows some interesting things that one would normally not expect - it appears that google has written it to detect if it's running within google's internal networks, which can be problematic – Andrew Rembrandt May 07 '22 at 13:20
  • This also was an issue with my network; misconfigured ipv6; I disabled ipv6 from the adapter settings in windows. In my case gcloud was hanging forever, not just slow. – Hussein Hijazi Aug 18 '23 at 06:38
0

Same behavior for me. Simple command hang on

gcloud compute instances list --log-http --verbosity debug

DEBUG: Starting new HTTPS connection (1): oauth2.googleapis.com:443

If I ping oauth2.googleapis.com PING oauth2.googleapis.com(sof02s34-in-x0a.1e100.net (2a00:1450:4017:80b::200a)) 56 data bytes you can see IPv6. In my case I have router Zyxel EX3301-T0

Disable LAN IPv6 Mode Setup and ping oauth2.googleapis.com PING oauth2.googleapis.com (172.217.17.138) 56(84) bytes of data. 64 bytes from 172.217.17.138 (172.217.17.138): icmp_seq=1 ttl=114 time=82.8 ms