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

Cloud Run revision already exists #5898

Assignees
Labels

Comments

@FallenHoot
Copy link

FallenHoot commented Mar 16, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.12.23

Affected Resource(s)

google_cloud_run_service

Terraform Configuration Files

resource "google_cloud_run_service" "default" {
  name     = "cloudrun-srv"
  location = "us-central1"

  template {
    spec {
      containers {
        image = "gcr.io/cloudrun/hello:latest"
      }
    }
  }

  traffic {
    percent         = 100
    latest_revision = true
  }
}

Expected Behavior

I assumed that it would allow the latest revsion to be used unless told otherwise. Terraform has no control over the container revision and should just verify that the latest one is used.

Actual Behavior

Terraform errors out:
Error: Error updating Service "locations/europe-north1/namespaces/project-id/services/hello": googleapi: Error 409: Revision named 'hello-00005-raz' with different configuration already exists.

Steps to Reproduce

  1. terraform init
  2. terraform plan
  3. terraform apply
  4. Push new image to cloud run using Cloud Build
  5. Redo 1-3

Important Factoids

Remote tfstate is located within GCP Cloud Storage
It uses a Terraform Service account running with Cloud Build CI/CD pipeline. It worked in that past, but since the code has been updated. It starts throwing this error listed above.

References

A few simular issues, but with different services.
#1214
#4394

@edwardmedia edwardmedia self-assigned this Mar 16, 2020
@edwardmedia
Copy link
Contributor

edwardmedia commented Mar 16, 2020

  • b/151577360
    Log available in b/151577360

@edwardmedia edwardmedia assigned c2thorn and unassigned edwardmedia Mar 16, 2020
@hectorj
Copy link
Contributor

hectorj commented Mar 24, 2020

Manually setting resource.google_cloud_run_service.default.template.metadata.name to a value matching the format hello-00005-raz (projectName-revisionNumber-3letterID) makes the update go through, though that's not a viable solution.

The revision name used to auto-update given a new configuration, I am not sure when it stopped doing so.

@c2thorn
Copy link
Collaborator

c2thorn commented Mar 24, 2020

@hectorj You are correct. In order to autogenerate the revision name, the template.metadata.name must be omitted when Terraform sends the API request. Unfortunately once the revision name gets set in state, there is no way to unset the name to start autogenerating again (it is a computed field, so it will be read and set every time Terraform refreshes).

We are working on a solution to toggle revision name autogeneration via an extra field.

@c2thorn
Copy link
Collaborator

c2thorn commented Mar 27, 2020

PR has been merged, and will likely be part of the 3.16.0 release scheduled for 4/6/2020.

We've added autogenerate_revision_name as a field. This will toggle the provider to ignore the revision name (template.metadata.name in state) and let it be managed server-side.

If you are receiving Error 409: Revision named '<revision name>' with different configuration already exists. setting autogenerate_revision_name=true will be the way to tell the provider you don't want to manage the revision name (after v3.16.0). Alternatively, you can manage the revision name yourself by changing template.metadata.name to a unique name for each update.

DominicRoyStang added a commit to DominicRoyStang/uvindex that referenced this issue Apr 12, 2020
…ady existing.

It was fixed by bumping up the provider version and setting autogenerate_revision_name = true on the cloud run service. More information here: hashicorp/terraform-provider-google#5898
DominicRoyStang added a commit to DominicRoyStang/uvindex that referenced this issue Apr 12, 2020
…ady existing.

It was fixed by bumping up the provider version and setting autogenerate_revision_name = true on the cloud run service. More information here: hashicorp/terraform-provider-google#5898
@ghost
Copy link

ghost commented Apr 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.