[google-cloud-sdk] `gcloud container clusters get-credentials` resolves symlinks from Snap executable

Bug #1802385 reported by Jesse Glick
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

Originally reported as https://issuetracker.google.com/issues/118842667 but refiling here since the Google Cloud team only supports their own package repository and declined to fix a bug only known to affect the Snap packaging.

Not even sure whether this is the right place to file bugs for actual snap packages, as opposed to the snap tooling. https://snapcraft.io/google-cloud-sdk gives https://cloud.google.com/sdk/docs/ as a contact link, but as I just noted, they do not agree; and the “verified account” is simply listed as “Cloud SDK (google-cloud-sdk)” with no further ownership information. From web searches all I can find is https://launchpad.net/~google-cloud-sdk-devel but I suppose they handle a PPA and not the snap?

Anyway, to repeat the original bug:

----

The `gcloud container clusters get-credentials` command edits `~/.kube/config` and defines, among other things, `/users/*/user/auth-provider/config/cmd-path`. When gcloud is installed via Snap, this path is overly specific. Rather than `/snap/bin/gcloud` as expected, it saves for example `/snap/google-cloud-sdk/59/bin/gcloud`, which will not be correct or perhaps even work when the snap is next updated.

What you expected to happen:

The `cmd-path` should be set to the command actually used to invoke `gcloud`, not the fully-resolved `argv[0]`.

Steps to reproduce:

On Ubuntu Bionic,

    snap install google-cloud-sdk

to add https://snapcraft.io/google-cloud-sdk to the system. Create a GKE cluster, then copy and run the Connect string from the UI:

    gcloud container clusters get-credentials … --zone … --project …

Now look at `~/.kube/config`. It will contain for example

        cmd-path: /snap/google-cloud-sdk/59/bin/gcloud

despite

~$ which gcloud
/snap/bin/gcloud
~$ ls -l /snap/bin
total 0
lrwxrwxrwx 1 root root 19 Nov 1 17:10 bq -> google-cloud-sdk.bq
lrwxrwxrwx 1 root root 23 Nov 1 17:10 gcloud -> google-cloud-sdk.gcloud
lrwxrwxrwx 1 root root 13 Nov 1 17:10 google-cloud-sdk.bq -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 Nov 1 17:10 google-cloud-sdk.gcloud -> /usr/bin/snap
lrwxrwxrwx 1 root root 13 Nov 1 17:10 google-cloud-sdk.gsutil -> /usr/bin/snap
lrwxrwxrwx 1 root root 23 Nov 1 17:10 gsutil -> google-cloud-sdk.gsutil
…others…
~$ ls -l /snap/google-cloud-sdk
total 0
drwxr-xr-x 13 root root 518 Oct 30 10:23 59
lrwxrwxrwx 1 root root 2 Nov 1 17:10 current -> 59
~$ ls -l /snap/google-cloud-sdk/59
total 328
drwxr-xr-x 3 root root 263 Oct 30 10:23 bin
-rwxr-xr-x 1 root root 35 Oct 30 10:23 command-bq.wrapper
-rwxr-xr-x 1 root root 39 Oct 30 10:23 command-gcloud.wrapper
-rwxr-xr-x 1 root root 39 Oct 30 10:23 command-gsutil.wrapper
…etc…

Workaround: manually edit the config file whenever updating the snap.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.