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

google_endspoints_service config_id output variable inconsistent final plan #6713

Closed
Assignees
Labels
bug forward/review In review; remove label to forward service/endpoints

Comments

@felixhuttmann
Copy link

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.28
+ provider.google v3.27.0
+ provider.null v2.1.2
+ provider.random v2.2.1

Affected Resource(s)

  • google_endpoints_service

Terraform Configuration Files

provider "google" {
  version = "3.27"
}

provider "random" {
  version = "2.2.1"
}

provider "null" {
  version = "2.1.2"
}

variable "revision" {}

variable "project_id" {}

locals {
  project_id     = var.project_id
  service_name   = "bugtest-${random_id.this.hex}.endpoints.${local.project_id}.cloud.goog"
  openapi_config = <<EOF
---
swagger: "2.0"
info:
  title: "Some service with revision ${var.revision}"
  description: "some description"
  version: "1.0.0"
host: "${local.service_name}"
schemes:
  - "https"
paths: {}
EOF
}

resource "random_id" "this" {
  byte_length = 8
}

resource "null_resource" "some" {
  triggers = {
    config_id = google_endpoints_service.service.config_id
  }
}

resource "google_endpoints_service" "service" {
  service_name   = local.service_name
  project        = local.project_id
  openapi_config = local.openapi_config
}

output "config_id" {
  value = google_endpoints_service.service.config_id
}

Debug Output

https://gist.githubusercontent.com/fhut/103bfa34de45b5aa910cdd147539a94a/raw/0527f51a5738f4d681abd90e5902b16f4097b057/google_endpoints_bug_debug_log.txt

Expected Behavior

Run terraform apply in sequence three times with different revision parameter

terraform0.12.28 apply -auto-approve -var="revision=foo"
=> output config_id = 2020-06-26r0
terraform0.12.28 apply -auto-approve" -var="revision=bar"
=> output config_id = 2020-06-26r1
terraform0.12.28 apply -auto-approve -var="revision=blubb"
=> output config_id = 2020-06-26r2

Actual Behavior

terraform0.12.28 apply -auto-approve -var="revision=foo"
=> output config_id = 2020-06-26r0
terraform0.12.28 apply -auto-approve -var="revision=bar"
=> output config_id = 2020-06-26r1
terraform0.12.28 apply -auto-approve -var="revision=blubb"
=> 
Error: Provider produced inconsistent final plan

When expanding the plan for null_resource.some to
include new values learned so far during apply, provider
"registry.terraform.io/-/null" produced an invalid new value for
.triggers["config_id"]: was cty.StringVal("2020-06-26r1"), but now
cty.StringVal("2020-06-26r2").

This is a bug in the provider, which should be reported in the provider's own
issue tracker.
@ghost ghost added the bug label Jun 26, 2020
@edwardmedia edwardmedia self-assigned this Jun 29, 2020
@edwardmedia
Copy link
Contributor

@fhut Can you repro the inconsistent error by removing null_resource? I can see the output config_id is just fine. The error happens on null_resource. There is nothing to do with google_endpoints_service. Let me know if this makes sense to you?

@felixhuttmann
Copy link
Author

The issue occurs in exactly the same way if I replace

resource "null_resource" "some" {
  triggers = {
    config_id = google_endpoints_service.service.config_id
  }
}

with

resource "google_storage_bucket" "this" {
  name = "some-bucket-name-${google_endpoints_service.service.config_id}"
  project = var.project_id
}

I believe that the fact that terraform core misattributes the inconsistent final plan to the dependent resource (null_resource or google_storage_bucket), rather than attributing it to the google_endpoints_service, is a separate issue in terraform core, it also says in the debug log:

Provider "registry.terraform.io/-/google" produced an unexpected new value for google_endpoints_service.service, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:

@nat-henderson
Copy link
Contributor

nat-henderson commented Jun 30, 2020

Hi there - this is a terraform core issue that we can (sometimes!) work around. This workaround is imperfect but it will be right most of the time. If you find that this issue is recurring often after the next release (as of next monday), please refile the issue.

After the fix, there are a few known conditions that will trigger this issue to recur. For example, if you trigger an update from Terraform while a rollout (not managed by Terraform) is in progress, or if the Plan happens on a different calendar date than the Apply, then you will see this even after the fix.

@ghost
Copy link

ghost commented Jul 31, 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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 31, 2020
@github-actions github-actions bot added forward/review In review; remove label to forward service/endpoints labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.