Score:0

gcloud compute commands sometimes getting stuck in WSL

in flag

I am running various gcloud compute commands from the linux subsystem on Windows 11 using Debian. In general, it works great. However, sometimes the gcloud command simply does not return, even after several minutes. Sometimes it happens once, sometimes several times in a row. This happens regularly enough that I cannot trust that a sh script that uses gcloud commands will run through to completion. Here is an example. The same command run 3 times without problem, then twice it just sits there, then works again:

root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances list
NAME            ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP  STATUS
docker-2        us-east1-b  e2-medium     true         10.142.0.13               TERMINATED
docker-install  us-east1-b  e2-medium     true         10.142.0.11               TERMINATED
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances list
NAME            ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP  STATUS
docker-2        us-east1-b  e2-medium     true         10.142.0.13               TERMINATED
docker-install  us-east1-b  e2-medium     true         10.142.0.11               TERMINATED
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances list
NAME            ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP  STATUS
docker-2        us-east1-b  e2-medium     true         10.142.0.13               TERMINATED
docker-install  us-east1-b  e2-medium     true         10.142.0.11               TERMINATED
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances list
^C

Command killed by keyboard interrupt


root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances list

^C

Command killed by keyboard interrupt


root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances list
NAME            ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP  STATUS
docker-2        us-east1-b  e2-medium     true         10.142.0.13               TERMINATED
docker-install  us-east1-b  e2-medium     true         10.142.0.11               TERMINATED
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#

Another example with debug on, the first gets stuck, the second works:

root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances --verbosity=debug list
DEBUG: Running [gcloud.compute.instances.list] with arguments: [--verbosity: "debug"]
INFO: Display format: "    table(
      name,
      zone.basename(),
      machineType.machine_type().basename(),
      scheduling.preemptible.yesno(yes=true, no=''),
      networkInterfaces[].networkIP.notnull().list():label=INTERNAL_IP,
      networkInterfaces[].accessConfigs[0].natIP.notnull().list()      :label=EXTERNAL_IP,
      status
    )"
DEBUG: Starting new HTTPS connection (1): compute.googleapis.com:443



^C

Command killed by keyboard interrupt


root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud compute instances --verbosity=debug list
DEBUG: Running [gcloud.compute.instances.list] with arguments: [--verbosity: "debug"]
INFO: Display format: "    table(
      name,
      zone.basename(),
      machineType.machine_type().basename(),
      scheduling.preemptible.yesno(yes=true, no=''),
      networkInterfaces[].networkIP.notnull().list():label=INTERNAL_IP,
      networkInterfaces[].accessConfigs[0].natIP.notnull().list()      :label=EXTERNAL_IP,
      status
    )"
DEBUG: Starting new HTTPS connection (1): compute.googleapis.com:443
DEBUG: https://compute.googleapis.com:443 "POST /batch/compute/v1 HTTP/1.1" 200 None
INFO: cache collection=compute.instances api_version=v1 params=['project', 'zone', 'instance']
NAME            ZONE        MACHINE_TYPE  PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP  STATUS
docker-2        us-east1-b  e2-medium     true         10.142.0.13               TERMINATED
docker-install  us-east1-b  e2-medium     true         10.142.0.11               TERMINATED
DEBUG: SDK update checks are disabled.
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#

Version is:

root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# gcloud --version
Google Cloud SDK 376.0.0
alpha 2022.03.04
beta 2022.03.04
bq 2.0.74
bundled-python3-unix 3.8.11
core 2022.03.04
gsutil 5.6
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#

This does not seem to be a matter of just being slow to return. I've never had it return after being stuck, even after several minutes. It is using gcloud from /usr/bin and I've tried running it with /usr/bin/gcloud just to be sure:

root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun# whereis gcloud
gcloud: /usr/bin/gcloud /mnt/c/Users/ddgun/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud /mnt/c/Users/ddgun/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd /mnt/c/Users/ddgun/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.ps1 /usr/share/man/man1/gcloud.1.gz
root@DESKTOP-H8CB6JO:/mnt/c/Users/ddgun#

This has never happened in Powershell so it seems to be related to WSL. Version is 2:

PS C:\Users\ddgun> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu                 Running         2
  docker-desktop         Running         2
  Debian                 Running         2
  docker-desktop-data    Running         2
PS C:\Users\ddgun>

Any ideas?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.