GoogleCloudPlatform / cloud-code-vscode

Cloud Code for Visual Studio Code: Issues, Documentation and more
Other
417 stars 111 forks source link

Cloud SDK installation is corrupted #346

Closed brightzheng100 closed 3 years ago

brightzheng100 commented 3 years ago

Environment: Extension version: 1.7.0 VSCode version: 1.51.1 OS: darwin

Description:

Trying to follow the doc to walk through the "hello world" process but I could see only a message like this, no other process was made:

Running "Run on Kubernetes" configuration (.vscode/launch.json) in Run mode

To view more detailed logs, go to Output channel : "Run on Kubernetes - Detailed"

Repro step:

  1. <To make sure the issue was not caused by VS Code, I deleted it completely and re-installed it with only cloud-code extension;
  2. Followed the doc to go though the "New application" process, it worked well and a "guest book" application was crreated;
  3. Already made sure Minikube was working fine and the icon was displayed in Cloud Code status bar;
    $ minikube version
    minikube version: v1.15.0
    commit: 3e098ff146b8502f597849dfda420a2fa4fa43f0
    $ kubectl version --short
    Client Version: v1.19.4
    Server Version: v1.19.4
  4. Clicked Cloud Code -> Run on Kubernetes, a message would be displayed in "OUTPUT" console, with
    
    Running "Run on Kubernetes" configuration (.vscode/launch.json) in Run mode

To view more detailed logs, go to Output channel : "Run on Kubernetes - Detailed"


5. The debugging bar was also displayed but no more process;
6. Stopped the deugging bar but the status bar was still on "Run on Kubernetes (guessbook)"
j-windsor commented 3 years ago

Could you please share the output of the "Run on Kubernetes - Detailed" output window when it stalls out?

brightzheng100 commented 3 years ago

The tricky thing is: there was no such an output window, and what I could see is like below attached.

Screenshot 2020-12-08 at 10 29 13 AM
brightzheng100 commented 3 years ago

Meanwhile, if I clicked minikube button at the status bar, I had no way to proceed as when prompting "Choose minikube cluster (profile) to control (1/2)", I could do nothing -- I tried with and without minikubw spun up outside to see whether it would detect and let me choose.

Screenshot 2020-12-08 at 10 32 09 AM
j-windsor commented 3 years ago

Hmm ok. Let's try something else then to verify minikube, since that looks like it is at the center of the problem here.

  1. Could you make sure you have the vscode setting cloudcode.autoDependencies set to 'on'? It should look like this. Screen Shot 2020-12-08 at 9 51 14 AM

  2. If it is set to 'on', could you please run this command to test the minikube binary Cloud Code uses: ~/Library/Application\ Support/cloud-code/installer/google-cloud-sdk/bin/minikube profile list

brightzheng100 commented 3 years ago

Yes, the Cloudcode: Auto Dependencies is on.

But obviously the minikube is not there:

$ ls ~/Library/Application\ Support/cloud-code/installer/google-cloud-sdk/bin
anthoscli                bq                       docker-credential-gcloud gcloud                   gsutil
bootstrapping            dev_appserver.py         endpointscfg.py          git-credential-gcloud.sh java_dev_appserver.sh

$ which minikube
/usr/local/bin/minikube

# As I've deleted minikube instance, no profile exists for now
# But it would be the same even if I spun up minikube
$ minikube profile list
I1209 10:26:09.533144   93487 translate.go:65] Getting system locale failed: Could not detect Language

❌  Exiting due to MK_USAGE: No minikube profile was found. You can create one using `minikube start`.

$ minikube config view
I1209 10:26:57.927959   93510 translate.go:65] Getting system locale failed: Could not detect Language
- kubernetes-version: v1.19.4
- memory: 4096
j-windsor commented 3 years ago

Hmmm ok. Looks like all your gcloud components failed to install here. Can you provide the output of ~/Library/Application\ Support/cloud-code/installer/google-cloud-sdk/bin/gcloud components list

brightzheng100 commented 3 years ago

I re-installed Google Cloud SDK carefully by following the official doc, without running gcloud init (as to avoid a login).

Then I re-installed Cloud Code addon in VS Code and reloaded it.

Now as per your request:

$ ~/Library/Application\ Support/cloud-code/installer/google-cloud-sdk/bin/gcloud components list
Traceback (most recent call last):
  File "/Users/brightzheng/Library/Application Support/cloud-code/installer/google-cloud-sdk/lib/gcloud.py", line 104, in <module>
    main()
  File "/Users/brightzheng/Library/Application Support/cloud-code/installer/google-cloud-sdk/lib/gcloud.py", line 62, in main
    from googlecloudsdk.core.util import encoding
  File "/Users/brightzheng/Library/Application Support/cloud-code/installer/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
    from googlecloudsdk.core.util import importing
  File "/Users/brightzheng/Library/Application Support/cloud-code/installer/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
    import imp
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 23, in <module>
    from importlib import util
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/util.py", line 2, in <module>
    from . import abc
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/abc.py", line 17, in <module>
    from typing import Protocol, runtime_checkable
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 26, in <module>
    import re as stdlib_re  # Avoid confusion with the re we export.
  File "/usr/local/Cellar/python@3.9/3.9.0_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/re.py", line 124, in <module>
    import enum
  File "/Users/brightzheng/Library/Application Support/cloud-code/installer/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
    spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'

I may have to do some python troubleshooting

brightzheng100 commented 3 years ago

BTW, just realized that I installed the latest Google Cloud SDK in another folder.

$ pwd
/Users/brightzheng/development/gcp/google-cloud-sdk

$ which gcloud
/Users/brightzheng/development/gcp/google-cloud-sdk/bin/gcloud

$ ./bin/gcloud components list

Your current Cloud SDK version is: 320.0.0
The latest available version is: 320.0.0

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                 Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬──────────┤
│     Status    │                         Name                         │            ID            │   Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼──────────┤
│ Not Installed │ App Engine Go Extensions                             │ app-engine-go            │  4.8 MiB │
│ Not Installed │ Appctl                                               │ appctl                   │ 18.5 MiB │
│ Not Installed │ Cloud Bigtable Command Line Tool                     │ cbt                      │  7.6 MiB │
│ Not Installed │ Cloud Bigtable Emulator                              │ bigtable                 │  6.6 MiB │
│ Not Installed │ Cloud Datalab Command Line Tool                      │ datalab                  │  < 1 MiB │
│ Not Installed │ Cloud Datastore Emulator                             │ cloud-datastore-emulator │ 18.4 MiB │
│ Not Installed │ Cloud Firestore Emulator                             │ cloud-firestore-emulator │ 42.1 MiB │
│ Not Installed │ Cloud Pub/Sub Emulator                               │ pubsub-emulator          │ 56.3 MiB │
│ Not Installed │ Cloud SQL Proxy                                      │ cloud_sql_proxy          │  7.4 MiB │
│ Not Installed │ Emulator Reverse Proxy                               │ emulator-reverse-proxy   │ 14.5 MiB │
│ Not Installed │ Google Cloud Build Local Builder                     │ cloud-build-local        │  6.2 MiB │
│ Not Installed │ Google Container Registry's Docker credential helper │ docker-credential-gcr    │  1.8 MiB │
│ Not Installed │ Kind                                                 │ kind                     │  4.4 MiB │
│ Not Installed │ Kustomize                                            │ kustomize                │ 22.8 MiB │
│ Not Installed │ Minikube                                             │ minikube                 │ 22.8 MiB │
│ Not Installed │ Nomos CLI                                            │ nomos                    │ 17.6 MiB │
│ Not Installed │ Skaffold                                             │ skaffold                 │ 16.1 MiB │
│ Not Installed │ anthos-auth                                          │ anthos-auth              │ 16.4 MiB │
│ Not Installed │ config-connector                                     │ config-connector         │ 42.0 MiB │
│ Not Installed │ gcloud Alpha Commands                                │ alpha                    │  < 1 MiB │
│ Not Installed │ gcloud Beta Commands                                 │ beta                     │  < 1 MiB │
│ Not Installed │ gcloud app Java Extensions                           │ app-engine-java          │ 59.6 MiB │
│ Not Installed │ gcloud app PHP Extensions                            │ app-engine-php           │ 21.9 MiB │
│ Not Installed │ gcloud app Python Extensions                         │ app-engine-python        │  6.1 MiB │
│ Not Installed │ gcloud app Python Extensions (Extra Libraries)       │ app-engine-python-extras │ 27.1 MiB │
│ Not Installed │ kpt                                                  │ kpt                      │ 12.0 MiB │
│ Not Installed │ kubectl                                              │ kubectl                  │  < 1 MiB │
│ Not Installed │ kubectl-oidc                                         │ kubectl-oidc             │ 16.4 MiB │
│ Not Installed │ pkg                                                  │ pkg                      │          │
│ Installed     │ BigQuery Command Line Tool                           │ bq                       │  < 1 MiB │
│ Installed     │ Cloud SDK Core Libraries                             │ core                     │ 15.8 MiB │
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │  3.5 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴──────────┘

So I guess I have to install to the hardcoded folder ~/Library/Application\ Support/cloud-code/installer/google-cloud-sdk instead, and I may have to install another copy of minikube as it states that Minikube is not installed (but actually it is installed outside and accessible through $PATH).

Is my understanding right?

sivakku commented 3 years ago

The cloud SDK that that cloud-code SDK automatically installed seems corrupted. Can you try the workaround mentioned in #332 ? We are looking to address the issue in our next release. Dupe of the task #310

brightzheng100 commented 3 years ago

After deleting the files under ~/Library/Application\ Support/cloud-code/installer/google-cloud-sdk and copying over all files from a new unzip of the latest Google Cloud SDK, it now goes further:

But I haven't had a chance to make Debug on Kubernetes work.

  1. I checked the pods, nothing had been injected as the debugger as what skaffold debug should look like;
  2. So it would never hit the endpoints set.
sivakku commented 3 years ago

@brightzheng100 - Are you using "Go" guestbook sample application for debugging on k8? Can you share your logs from the "Run on Kubernetes - Detailed" output window? thanks.