-
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
provider/aws: Fix crash when reading VPC Peering Connection options. #8338
provider/aws: Fix crash when reading VPC Peering Connection options. #8338
Conversation
Hm, it looked like in the original issue that |
@mitchellh OK, leave it with me. |
241f759
to
fdf4e3f
Compare
@mitchellh done. I hope that I was able to put guards around the values that we believe might be missing. I have also noticed that sometimes the I sincerely apologise for all the troubles. |
I have updated the test that checks for tags so that it actually runs. Tests are passing:
I have manually tested with
|
When running Just wanted to check if this the intended behaviour? otherwise this works fine for me :) Side-note and not really related: It would be awesome to get something like Sorry for going a little bit off topic :) $ terraform plan
~ module.stack.vpc.aws_vpc_peering_connection.main
accepter.#: "" => "<computed>"
|
@heimweh sorry for troubles! I am going to look into the plan never settling issues. |
@kwilczynski - no worries at all, just happy to help :) |
@heimweh you rock! Both blocks are computed should there be a value to read they would trigger update in state. Thus, once you apply and state will be persisted, then it should stop. What does the |
@kwilczynski - this is what
|
@heimweh thank you! Can I ask a favour of you? If you have a minute, can you add It would be very helpful to see what it does show for you and your setup. |
@kwilczynski - I managed to replicate it as well with newly created resources. To really isolate it, I created a VPC with a peering connection to another account. Feel free to check out this gist: https://gist.github.com/heimweh/b3fc6f08f38e00be79420c6ab445a84f I added a comment section below the plan log describing the steps I took. |
@heimweh thank you again. There are two issues to solve:
The (2) complicates things as options can only be applied to a peering in an active state. |
@mitchellh and @stack72, I am going to remove ability to set option at the This is primarily due to the more apparent chicken-and-egg problem that arises with the use case where the VPC Peering Connection is to be manually accepted (especially, when people are accepting peering across different accounts). Options cannot be set when the peering is not active and the also responses seem to exclude elements related to the peering options in such case. Would that be fine with you? Update: This is an interesting problem - people want to create peering, but not accept. In such case even Unless we keep the new feature, but issue a warning or an error when user is not setting the |
8afba58
to
e890b3f
Compare
@mitchellh @stack72 @heimweh apologies for the delay with the fix. I am in the middle of moving back from Tokyo to London this week. I have resolved the issue with nil pointer dereference, plus made sure that both blocks are only populated as needed only if they are present. I have also made sure that the user case when user would create VPC Peering Connection but do not accept it immediately in the I sincerely apologise for the delay and for the troubles caused! |
Tests are passing:
Provider builds successfully:
|
At a high level this looks good to me now but I'm going to wait for @catsby or someone else that is more familiar these days with the AWS provider to double check. |
714bf5c
to
04d42f6
Compare
@mitchellh thank you! I have rebased against current master. |
This resolves the issue introduced in hashicorp#8310. Signed-off-by: Krzysztof Wilczynski <[email protected]>
04d42f6
to
a46f9f4
Compare
|
||
d.Set("accept_status", *pc.Status.Code) | ||
d.Set("peer_owner_id", *pc.AccepterVpcInfo.OwnerId) | ||
d.Set("peer_vpc_id", *pc.AccepterVpcInfo.VpcId) | ||
d.Set("vpc_id", *pc.RequesterVpcInfo.VpcId) |
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.
When using d.Set
, it's recommend to simply reference the attribute and not dereference it.
So instead of:
d.Set("vpc_id", *pc.RequesterVpcInfo.VpcId)
use
d.Set("vpc_id", pc.RequesterVpcInfo.VpcId)
d.Set
will safely dereference it if it's nil, so it's considered safer than dereferencing its yourself. Note that this does not work for d.SetId
, which must be an value and not a pointer.
Don't feel you must make this change, but I wanted to pass that on
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.
@catsby thank you, I will revise :) Good to know.
I have some questions about why we choose to conditionally read those attributes that I would like to hear back on before merging this. Otherwise the code changes seem good 👍 |
Signed-off-by: Krzysztof Wilczynski <[email protected]>
@catsby (re-posting reply, since it got eaten by a commit amoeba): This was the only one way I found which could stop the accepter from being set either to 0 (the count), or when the value is to be computed to every time. This happens when blocks are either not provided or are empty and when the auto_accept is set to false (the default), which results in the missing fields in the response from AWS, and in turn empty value is persisted on our side. An empty value results in a change being detected, and then we are back to trying to set (empty) value again, etc, etc. To add, if we allow empty value to be passed when making a request to the AWS (which in its own right is fine) it would explode if the peering connection is not yet accepted (and some people choose to accept it outside of Terraform), thus it would explode every time apply is run (error bubbles from the AWS side). I am not sure how to solve this in a different way. My aim was to ignore work involving the new blocks completely if they are not present. There is no concept of "undefined" value in the Schema and relying on empty values often leads to this (or similar; especially when boolean is concerned) behaviour. |
…upersedes #8338) (#8432) * Fix crash when reading VPC Peering Connection options. This resolves the issue introduced in #8310. Signed-off-by: Krzysztof Wilczynski <[email protected]> * Do not de-reference values when using Set(). Signed-off-by: Krzysztof Wilczynski <[email protected]> * provider/aws: Update VPC Peering connect accept/request attributes * change from type list to type set * provider/aws: Update VPC Peering accept/requst options, tests * errwrap some things
Continued and merged in #8432 |
…upersedes hashicorp#8338) (hashicorp#8432) * Fix crash when reading VPC Peering Connection options. This resolves the issue introduced in hashicorp#8310. Signed-off-by: Krzysztof Wilczynski <[email protected]> * Do not de-reference values when using Set(). Signed-off-by: Krzysztof Wilczynski <[email protected]> * provider/aws: Update VPC Peering connect accept/request attributes * change from type list to type set * provider/aws: Update VPC Peering accept/requst options, tests * errwrap some things
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. |
This resolves the issue introduced in #8310.
Signed-off-by: Krzysztof Wilczynski [email protected]