-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
scheduler: fix perm diff on appEngineRouting #2270
scheduler: fix perm diff on appEngineRouting #2270
Conversation
Hello! I am a robot who works on Magic Modules PRs. I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review. They will authorize it to run through our CI pipeline, which will generate downstream PRs. Thanks for your contribution! A human will be with you soon. @emilymye, please review this PR or find an appropriate assignee. |
if targets := d.Get("app_engine_http_target").([]interface{}); len(targets) > 0 { | ||
return targets[0].(map[string]interface{})["app_engine_routing"] | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another choice is doing like this; I don't know which is better...
return []interface{}{map[string]interface{}{
"service": d.Get("app_engine_http_target.0.app_engine_routing.0.service"),
"version": d.Get("app_engine_http_target.0.app_engine_routing.0.version"),
"instance": d.Get("app_engine_http_target.0.app_engine_routing.0.instance"),
}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm pretty sure the easiest might actually be
if v, ok := d.GetOk("app_engine_http_target"); ok && len(v.([]interface{})) > 0 {
return d.Get("app_engine_http_target.0.app_engine_routing")
}
return nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, I adopted your suggestion! ea6171a
@emilymye I have no idea why my ci is pending for so long, but...should I do anything? |
@tmshn sorry! for community PRs we actually ahve to manually approve runs on our end, so that's on me |
Hi! I'm the modular magician, I work on Magic Modules. Pull request statusesNo diff detected in terraform-google-conversion. New Pull RequestsI built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed. |
@tmshn Thanks for contributing, sorry for the delay in review! I just looked at this and if the value isn't being returned by the API, we can just set it to |
701c4aa
to
7e3743f
Compare
@tmshn thanks for being patient! So, after some inspection, it appears that
|
That sound so curios to me, so I've tried out that too, and found:
Ooh...so weird behavior! 😕 For later reference, I paste the result here. None specifiedapp_engine_routing {
} $ terraform apply -auto-approve
google_cloud_scheduler_job.tmshn_test: Creating...
google_cloud_scheduler_job.tmshn_test: Creation complete after 2s [id=tmshn-test-scheduler-job]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Outputs:
tmshn-test-res = {"host":"myproject.appspot.com"} only
|
@emilymye Sorry I couldn't fully understand what you mean here (oh my poor English!) |
@tmshn sorry about that! my comments didnt actually submit - submitting now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmshn Looks good to me! I'll go ahead and start generation again to confirm, and will merge if all goes well. Thanks for your patience!
templates/terraform/custom_flatten/cloudscheduler_job_appenginerouting.go.erb
Outdated
Show resolved
Hide resolved
Let me know if I need to merge latest master |
Hi! I'm the modular magician, I work on Magic Modules. Pull request statusesterraform-provider-google-beta already has an open PR. New Pull RequestsI didn't open any new pull requests because of this PR. |
@tmshn (deleted my previous comment) so I ran our tests for cloud scheduler job and it looks like import will cause an issue because there is no value in state, but any diff causes a recreation which is technically a breaking change. Thus, I was wondering if you'd be willing to change your flatten method one more time so we fallback on API value if it's not set in state, like:
Once this is in, the tests should be fine and we should be able to submit finally :) Sorry for the trouble! This resource is not very straightforward so we appreciate that you're helping us to debug its behavior. |
I'm okay to fix this in that way; e.g.: fallback to the original method that read data from api.
@emilymye Can I see the test result you refer to? |
Yeah, I'm not sure we can do anything about the case where someone is importing the API state into config with weird cases. I think as long as we don't make those cases worse (since they would permadiff anyways) and we fix the cases for
we should be ok? The fallback should only be triggered on import, so if you create it in Terraform with one of the weird cases, it'll still be fine. As for the weird cases, I think we probably shouldn't do any special logic and should just ask the upstream API to fix it (I filed a bug against them). The test command:
gives the following error without the state changes:
Our test infrastructure verifies test resources by attempting to import the newly created test resources into an empty state and seeing if they differ. Because the original state had the appEngineRouting set, but the imported state did not, we got this error. |
Thank you for the clear explanation, I got what's happening! But anyway, I agree with you that we are improving things as far as we can, and doesn't make the other cases worse.
Thank you! |
Fixed 194b7d9 ✅ |
Hi! I'm the modular magician, I work on Magic Modules. Pull request statusesterraform-provider-google-beta already has an open PR. New Pull RequestsI didn't open any new pull requests because of this PR. |
194b7d9
to
6b158f8
Compare
@tmshn had to rebase, but should be going in! |
Hi! I'm the modular magician, I work on Magic Modules. Pull request statusesNo diff detected in terraform-google-conversion. New Pull RequestsI built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed. |
Tracked submodules are build/terraform-beta build/terraform-mapper build/terraform build/ansible build/inspec.
Problem
Cloud Scheduler Job created by terraform permanently claims "new resource required" and recreated every time.
This is due to API behavior;
appEngineRouting
field returned by API only contains read-onlyhost
field, without any ofservice
,version
norinstance
fields.What's changed
Fixed flatten function (used in Read function) for
appEngineRouting
to use config value rather than API response.Release Note for Downstream PRs (will be copied)