-
Notifications
You must be signed in to change notification settings - Fork 9.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
Cleanup SetResourceInstanceCurrent to be clearer and more reliable #23475
Conversation
Some of the test failures are typical, they were written to expect the wrong output. The problematic ones are where we have the wrong provider stored in the state. I don't think this change is at fault for that however, and I bet it's highlighting that we don't update the provider consistently throughout the lifecycle of the resource. |
@jbardin disagree, I think this change is at fault ... |
yeah, It could just be because the function is overloaded, but the fact that the wrong providers were in there make me wonder if it's not set consistently, and only cleaned up "just in time". (your last fix is still good, we want to restore everything this function needs to do for 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.
This looks generally good! I have one little concern inline regarding a condition I saw in the old implementation of this function which didn't seem to be covered in the new.
6e909e3
to
de953ec
Compare
…test case" This reverts commit e8aa5bf.
@apparentlymart Very very helpful catch, found and fixed. |
// check for an existing resource, now that we've ensured that rs.Instances is more than 0/not nil | ||
is := rs.Instance(addr.Key) | ||
if is == nil { | ||
// if there is no instance, but the resource exists and has other instances, |
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 think this comment is now not totally accurate, because we can get here in the case where the resource exists but has no other instances. The code around it seems correct, but since you've gone to the effort of adding all of these great comments I thought you'd probably want to clarify this one. 😀
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Refactors
setResourceInstanceCurrent
which does lots of things, to do them in a more reliable and predictable order. Deletes dead code in eval_diff discovered over the course of investigation, following our "clean it up if you're nearby" practice.