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

Error: Provider produced inconsistent result after apply #40

Closed
tibers opened this issue Nov 5, 2019 · 17 comments · Fixed by #58 or #59
Closed

Error: Provider produced inconsistent result after apply #40

tibers opened this issue Nov 5, 2019 · 17 comments · Fixed by #58 or #59
Assignees
Labels

Comments

@tibers
Copy link

tibers commented Nov 5, 2019

Hi there,

Terraform Version

0.12.12
apigee provider 0.17

Terraform Configuration Files

Use the examples, but explode a proxy zip into ~/proxy_files

Expected Behavior

It actually works...

Actual Behavior

apigee_api_proxy.helloworld_proxy: Creating...
apigee_company.helloworld_company: Creating...
apigee_developer.helloworld_developer: Creating...
apigee_target_server.helloworld_target_server_testing: Creating...
apigee_api_proxy.helloworld_proxy: Creation complete after 1s [id=ad0170dd-3276-4fdd-975a-aea54e6ad83d]
apigee_api_proxy_deployment.helloworld_proxy_deployment: Creating...
apigee_product.helloworld_product: Creating...
apigee_company.helloworld_company: Creation complete after 1s [id=31061393-ce1b-490f-9c7a-14cec04a5e97]
apigee_developer.helloworld_developer: Creation complete after 1s [id=53e169d7-9bd0-411e-8770-ec47ebdb5a76]
apigee_product.helloworld_product: Creation complete after 1s [id=434ba16d-3933-49a1-94bb-8b1881e0d989]
apigee_company_app.helloworld_company_app: Creating...
apigee_developer_app.helloworld_developer_app: Creating...
apigee_target_server.helloworld_target_server_testing: Creation complete after 3s [id=c8aa8590-c2b9-47c9-bb04-b26de8b9f916]
apigee_developer_app.helloworld_developer_app: Creation complete after 1s [id=c1825e45-17a5-435b-9f6f-951a77c3a811]
apigee_company_app.helloworld_company_app: Creation complete after 2s [id=ad649013-01cf-400b-8819-1abebb766ba8]

Error: Provider produced inconsistent result after apply

When applying changes to
apigee_api_proxy_deployment.helloworld_proxy_deployment, provider "apigee"
produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

Steps to Reproduce

do the hello world code, explode a proxy into the ~/proxy_files dir

Important Factoids

Note that this is not a new apigee tenancy, this is me trying to bring automation to the existing tenancy.

@zambien
Copy link
Owner

zambien commented Nov 5, 2019

This is fixed in #37 and is the result of changes in how apigee returns results in their API which broke the provider. I will work on releasing both open PRs into v0.0.18.

@zambien
Copy link
Owner

zambien commented Nov 5, 2019

When you say:

Note that this is not a new apigee tenancy, this is me trying to bring automation to the existing tenancy.

Can you elaborate on that please?

@tibers
Copy link
Author

tibers commented Nov 5, 2019

We have a bunch of manually provisioned stuff and I'm trying to use this terraform module to bring CI/CD to it instead of a bunch of point-and-click administration which has become a headache.

I will close this as you indicated the bug has been squished. :)

@tibers tibers closed this as completed Nov 5, 2019
@zambien
Copy link
Owner

zambien commented Nov 5, 2019

Ah OK. You need to import those resources most probably. The provider won't import things that exist in Apigee unless you explicitly import them as they aren't there in the terraform state.

I think this is a different issue than the one I referenced.

@tibers
Copy link
Author

tibers commented Nov 5, 2019

I'll open a new bug report if the issue persists in 0.18 I suppose.

@tibers
Copy link
Author

tibers commented Nov 6, 2019

Yeah still happening reliably in 0.0.18

@tibers tibers reopened this Nov 6, 2019
@zambien
Copy link
Owner

zambien commented Nov 6, 2019

I was able to reproduce this. I'm not sure how the bug was introduced but I will dig into it.

@zambien zambien self-assigned this Nov 6, 2019
@zambien zambien added the bug label Nov 6, 2019
@zambien
Copy link
Owner

zambien commented Nov 6, 2019

@tibers FYI, it will be a few days before I can dig into this due to other priorities.

@tibers
Copy link
Author

tibers commented Nov 6, 2019

OK thanks for the heads up. It's not a blocker as it looks like everything is working? I'm not sure what TF is actually complaining about. Maybe I'll even take a shot at it and try to learn some TF under the hood.

@zambien
Copy link
Owner

zambien commented Nov 6, 2019

Yep, it is working. I think this has to do with some of the changes for 'latest' a while back which may cause this even if you aren't using 'latest'. I'm able to reproduce it so once I have some time I can get it resolved but please feel free to look into it.

Writing terraform providers is pretty straightforward but understanding how the tests work is a little... well weird I guess.

@bostrowski13
Copy link

I'm pretty new to Go, but is there anything I can help with here? Was I correct in the issue I reaised in saying the issue was reading back the info from Reader? Is this just an issue with conversion from JSON to a Go map?

@tibers
Copy link
Author

tibers commented Nov 21, 2019

I also suck at Go - I piddle about with it and then get stuck and then give up. I have an open feature req if you're bored or brave. The apigee API isn't the best and it's getting overhauled sometime in 2020 per our support contact.

The problem is that latest can really be any value, because apigee will accept a proxy bundle and assign it a version number upon upload. But there's no notion of "latest" in the API. While it's a nice convenience feature, to reference the latest version of something, you have to upload that something, then get the version of the thing that's been uploaded, then reference that everywhere else. Apigee also has a problem where the API is lazy - objects which are uploaded take a moment to be exploded and actually exist to the API, hence the workaround with the SHA. It's just.... not fun to use.

@bostrowski13
Copy link

happy new year all! i spent my break learning more go, but i'm honestly not sure where exactly this is breaking yet. if you can point it out to me and tellme what needs to be fixed i have time and am in need of getting this working. i'be happy to do a PR.

@sairamaj
Copy link

sairamaj commented Feb 19, 2020

I am using first time apigee provider and this is really great stuff (thank you). I got this issue "Provider produced inconsistent result after apply" when i used revision = "latest" in apigee_api_proxy_deployment . Then i started reading the https://www.terraform.io/docs/extend/terraform-0.12-compatibility.html and trying to understand throgh terraform plan . What I understood is because the code is updating the revision in resourceApiProxyDeploymentRead , terraform is complaining about this as this is not appeared in plan (plan shows latest but apply came up with different in this case it is 1).

As experimental I changed the code like below

if found {
	if d.Get("revision").(string) == "latest" {
		d.SetId(matchedRevision)
	} else {

Instead of updating the revision , updating the id with revision.
and terraform show matches with terraform plan and now terraform does not complaining.

I am not sure my thinking is correct or not but wanted to inform

@twohyjr
Copy link

twohyjr commented Nov 30, 2020

I am still running into this issue. What is the fix? I cannot seem to locate it throughout this thread.

@tkonsta
Copy link

tkonsta commented Feb 19, 2021

Just an additional comment to help people who land here when they google for this problem:

One cause, which can make this error appear, can be that the deployment of a proxy fails because there's some error in the proxy. So a way to find out what's wrong when this error appears in a terraform run, can be to deploy the proxy manually using the Apigee UI and look at what error this gives you.

An example which in our case recently made this problem appear is that there was another proxy with the same "BasePath" already existing in the system. When trying to deploy the proxy with terraform the message about "unexpected new value for was present, but now absent" appeared and we only found out about our problem when we tried to deploy the proxy manually.

@sudheer-palagiri
Copy link

we are experiencing similar issue when deploying

to understand the problem, i will use this version here
Before deployment
stage: version 2
production: version 2
pipeline deploys to stage and tags correctly,
post stage deployment:
stage: version 3
production: version 2
this is expected behaviour
prod deployment: (fails)
stage: version 3
prod: error
apigee_api_proxy_deployment.printsitemanagement_proxy_deployment to include
new values learned so far during apply, provider
“registry.terraform.io/-/apigee” produced an invalid new value for .revision:
was cty.StringVal(“3"), but now cty.StringVal(“4”).

we have around 2 dozens for proxies, it fails on every proxy when deploying to production, but on rerun it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants