CircleCI-Public / gcp-cli-orb

Install and configure the Google Cloud CLI (gcloud)
https://circleci.com/orbs/registry/orb/circleci/gcp-cli
MIT License
9 stars 32 forks source link

Orb tries to install the latest CLI version, even though it's already in the image #80

Open simon360 opened 11 months ago

simon360 commented 11 months ago

Orb version

3.1.1

What happened

We've been using this orb, with the CLI version set to latest and the executor set to gcp-cli/google. However, this leads to an issue every few weeks where either:

When that happens, our deploys are blocked with an error along these lines:

The version installed (451.0.0) differs from the version requested (451.0.1).
Uninstalling v451.0.0...
sudo is required to uninstall the Google Cloud SDK.
Please install it and try again.
Failed to uninstall the current version.

Exited with code exit status 1

There's no way to get past this, unless we hard-set the CLI version to whatever's in the Docker image. This is frequently leading to our deploys being blocked for hours, sometimes up to a day.

In our case, we'd be more than happy to simply use whatever version is provided by the latest Google Cloud SDK docker image. We know it'll be the newest version the vast majority of the time, and if it's not the newest version, it'll be very, very close. And the docs for this orb's install command suggest that this is the intended behaviour (emphasis mine):

  Install the gcloud CLI. **When installing within the Docker executor, the
  install will only occur if the CLI isn't already installed.** If installing in
  a Linux machine image, it will remove the pre-installed version and instead
  install the version specified by this orb.

Expected behavior

When using the gcp-cli/google executor and the latest version is specified for the CLI, don't try to uninstall/reinstall a different version, because doing so will always fail with permission errors anyway.

(I'd be happy enough to put together a PR for this, but I wanted to open the discussion first to make sure I wouldn't be wasting any work putting forward a fix for this)

awinograd commented 10 months ago

Just experienced this same issue for the first time. Another potential solution would be to expose a new command gcp-cli/setup-no-install / gcp-cli/setup-only which executes the setup step without attempting to perform an install. Instead, it assumes that gcloud is already properly installed