spectacles-ci / spectacles

A continuous integration tool for Looker and LookML.
https://spectacles.dev
MIT License
217 stars 35 forks source link

Keep getting tmp branch already exists error #778

Open AngieWongHeb opened 9 months ago

AngieWongHeb commented 9 months ago

We are using spectacles with github actions to automatically detect errors for Looker PRs.

This is the command we run

Run spectacles sql --do-not-track --config-file ./spectacles/config.yaml --project heb --branch cicd --explores -heb/google_ads_campaign_test --incremental --remote-reset -v

This is the log for the job run on Github's side.

Run spectacles sql  --do-not-track  --config-file ./spectacles/config.yaml  --project heb  --branch cicd --explores -heb/google_ads_campaign_test  --incremental  --remote-reset  -v
Authenticating to the Looker as client ID '***'
Checking Looker instance release version
Connected to Looker version 24.0.39 using Looker API 4.0
Setting up branch manager in project 'heb'

Setting Git state for project 'heb' @ cicd:
.. Getting the workspace in use by this session
.. Getting active branch for project 'heb'
.. The active branch is '__LOOKER_PROD_7c29b30778aa4473fd9d46ef04e66abdf2d4e2a5'
.. Updating session to use the dev workspace
.. Getting the workspace in use by this session
.. Getting active branch for project 'heb'
.. The active branch is 'cicd'
.. Branching 'tmp_spectacles_d2b4b79edd' off 'origin/cicd'. Afterwards, restoring to
     branch '__LOOKER_PROD_7c29b30778aa4473fd9d46ef04e66abdf2d4e2a5' in project 'heb'
.. Creating branch 'tmp_spectacles_d2b4b79edd' on project 'heb'
.. Creating branch 'tmp_spectacles_d2b4b79edd' on project 'heb'
.. Creating branch 'tmp_spectacles_d2b4b79edd' on project 'heb'
Completed SQL validation in [15](https://github.com/homeequitybank/LookML-HEB-Preprod/actions/runs/7935607433/job/21669135029?pr=309#step:7:16) seconds.

Couldn't create new Git branch. Unable to create branch 'tmp_spectacles_d2b4b79edd' in project 'heb'. Confirm the branch doesn't already exist and try again.

Run in verbose mode (-v) or check your log file to see the full response from the Looker API. For support, please create an issue at https://github.com/spectacles-ci/spectacles/issues

.. Spectacles received a 409 response code from the Looker API with the following
     details: {
  "message": "A branch named tmp_spectacles_d2b4b79edd already exists",
     "documentation_url": "https://cloud.google.com/looker/docs/r/err/4.0/409/post/proje
     cts/:project_id/git_branch"
}
Error: Process completed with exit code 101.

Looker API is returning to me that the branch exists. But

  1. Spectacles auto-delete branches after a job regardless of if it succeeds or fails right?
  2. I do not see those branches when I go to the branches tab on github repo nor when I do git branch -r.

Please advise.

joshtemple commented 9 months ago

Hi @AngieWongHeb, could you please try following the steps in this guide in our docs? It's likely the Looker user that you're using to run Spectacles has gotten into a corrupted Git state.

The guide is written for our web application, but the process is the same, just replace "set up a new worker in Spectacles" with "replace your Looker credentials in GitHub Actions".

AngieWongHeb commented 9 months ago

Hi Josh, thanks for the prompt response. I followed the guide and I could checkout a branch from within Looker? When you say, "replace your Looker credentials in GitHub Actions", do you mean replacing the client ID and secret and the new Looker user's?

Edit: I sudo'ed into the Looker user and I see that there were some tmp_xxx branches that were remnants from the last time another team member tried to play around with spectacles. They couldn't be deleted, gives the same error described in the docs you linked - Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. The weird part is the Spectacles Looker User did not exist before I created it a few weeks back, why are branches created from the other team member showing up?

AngieWongHeb commented 9 months ago

image Wanted to add this in case spectacles team isn't aware, is this change accounted?

joshtemple commented 9 months ago

Hi @AngieWongHeb, sorry for the delay in response here.

You'll need to delete the Looker user, create a new one, and then use the credentials from the new user in Spectacles. As far as I know, there isn't a way to fix this issue other than contacting Looker support, and it will be much faster to just make a new Looker user.

If you and your teammate were both using the same API credentials to test Spectacles, that would explain why there would be branches from both of your tests.

joshtemple commented 9 months ago

Regarding the API Endpoint update, we are aware of it, and don't have any reason to believe we need to make changes to Spectacles as we don't use those endpoints.