terraform/helper
Paul Hinze 6b6b5a43c3 provider/aws: serialize SG rule access to fix race condition
Because `aws_security_group_rule` resources are an abstraction on top of
Security Groups, they must interact with the AWS Security Group APIs in
a pattern that often results in lots of parallel requests interacting
with the same security group.

We've found that this pattern can trigger race conditions resulting in
inconsistent behavior, including:

 * Rules that report as created but don't actually exist on AWS's side
 * Rules that show up in AWS but don't register as being created
   locally, resulting in follow up attempts to authorize the rule
   failing w/ Duplicate errors

Here, we introduce a per-SG mutex that must be held by any security
group before it is allowed to interact with AWS APIs. This protects the
space between `DescribeSecurityGroup` and `Authorize*` / `Revoke*`
calls, ensuring that no other rules interact with the SG during that
span.

The included test exposes the race by applying a security group with
lots of rules, which based on the dependency graph can all be handled in
parallel. This fails most of the time without the new locking behavior.

I've omitted the mutex from `Read`, since it is only called during the
Refresh walk when no changes are being made, meaning a bunch of parallel
`DescribeSecurityGroup` API calls should be consistent in that case.
2015-11-18 12:39:59 -06:00
..
config Fix failing tests 2014-10-09 21:29:21 -07:00
diff config: use new API 2015-01-14 22:03:15 -08:00
hashcode formatting, cleanups 2015-02-11 11:40:49 -08:00
mutexkv provider/aws: serialize SG rule access to fix race condition 2015-11-18 12:39:59 -06:00
pathorcontents ssh: accept private key contents instead of path 2015-11-12 14:59:14 -06:00
resource fix a bunch of tests from go-getter import 2015-10-15 13:48:58 -07:00
schema Reflect new comment format in stringer.go 2015-11-09 11:38:51 -05:00
README.md dos2unix 2014-07-28 10:43:00 -07:00

README.md

Helper Libraries

This folder contains helper libraries for Terraform plugins. A running joke is that this is "Terraform standard library" for plugins. The goal of the packages in this directory are to provide high-level helpers to make it easier to implement the various aspects of writing a plugin for Terraform.