Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALREADY_EXISTS error while trying to update function with dash instead of underscore in name #447

Open
vitorelourenco opened this issue Nov 19, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@vitorelourenco
Copy link

TL;DR

The error seems to be realated to how gcp treats function names. The correct function name was foo_bar but in the name field for the action, I had written foo-bar instead.

Expected behavior

An error message saying 'Failed to update' or a successful update.

Observed behavior

Error showing an attempt to create a cloud function with the "same name".

Action YAML

name: ...
on:
  push:
    branches:
      - main
    paths:
      - ...
  workflow_dispatch:
jobs:
  deploy-job:
    environment: ...

    permissions:
      id-token: write
      contents: read

    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - id: 'auth'
        name: 'Authenticate to Google Cloud'
        uses: 'google-github-actions/auth@v2'
        with:
          workload_identity_provider: ...
          service_account: ...

      - id: 'deploy'
        uses: 'google-github-actions/deploy-cloud-functions@v3'
        with:
          name: ...
          runtime: 'nodejs20'
          entry_point: ...
          environment: 'GEN_2'
          region: ...
          source_dir: ...

      - name: Report Status
        if: always()
        uses: ravsamhq/notify-slack-action@v2
        with:
          status: ${{ job.status }}
          notify_when: 'failure'
        env:
          ...

Log output

Run google-github-actions/deploy-cloud-functions@v3
Created zip file from --REDACTED--
Creating new Cloud Functions deployment
Error: google-github-actions/deploy-cloud-functions failed with: failed to POST --REDACTED--: (409) {
  "error": {
    "code": 409,
    "message": "Could not create Cloud Run service --REDACTED--. A Cloud Run service with this name already exists. Please redeploy the function with a different name.",
    "status": "ALREADY_EXISTS"
  }
}

Additional information

No response

@vitorelourenco vitorelourenco added the bug Something isn't working label Nov 19, 2024
@sethvargo
Copy link
Member

Does a Cloud Run service with that name already exist? You can check in the Google Cloud Console.

@vitorelourenco
Copy link
Author

Does a Cloud Run service with that name already exist? You can check in the Google Cloud Console.

It does but it is the same service, it's a cloud function gen 2. In the clound functions console it's named as foo_bar (underscore) and in the cloud run console it's named as foo-bar (dash)

@sethvargo
Copy link
Member

Does this happen every time? Or did you rename the function and then it started happening?

@vitorelourenco
Copy link
Author

I've only started using github actions for it today, before that I would zip and redeploy via console. I do remember fiddling around with that function, back when I was moving it from GEN 1 to GEN 2. I may have changed it's name back then but I'm not sure if it was my doing or google's, since the function still displays with an underscore in the cloud functions console. It's also a pretty set-and-done function so it hasnt seen any new deployments for several months. I don't have other examples of this in our repo but that happens every time for this function. I was thinking this could be a problem related to the underlying tool instead of the action but the error I get is different when I use gcloud with the same arugments.

cloud run name: foo-bar
cloud function name: foo_bar

gcloud functions deploy --entry-point ... --gen2 --region us-east1 --source ... --runtime nodejs20 foo-bar
ERROR: (gcloud.functions.deploy) One of arguments [--trigger-topic, --trigger-bucket, --trigger-http, --trigger-event, --trigger-event-filters] is required: You must specify a trigger when deploying a new function.


gcloud functions deploy --entry-point ... --gen2 --region us-east1 --source ... --runtime nodejs20 foo_bar
Preparing function...done.                                                                                                                                                                                                
X Updating function (may take a while)...  
<more stuff>

@sethvargo
Copy link
Member

Are you able to put together a reproduction case from scratch? I'm having trouble reproducing this, so I must be missing a step.

@vitorelourenco
Copy link
Author

I'll see if I can reproduce it over the weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants