Commit Graph

1759 Commits

Author SHA1 Message Date
Mitchell Hashimoto 1d1dc7cf30 release: clean up after v0.9.1 2017-03-17 22:54:23 +00:00
Mitchell Hashimoto 7c25ef851b
v0.9.1 2017-03-17 22:48:44 +00:00
Mitchell Hashimoto e8b3062629
terraform: unknown value for variables not set
Fixes #12836

Realistically, these should be caught during validation anyways. In this
case, this was causing 12386 because refresh with a data source will
attempt to use module variables. I don't see any clear logic to prune
those module variables or not add them so its easier to return unknown
to cause the data to be computed and not run.
2017-03-17 15:33:33 -07:00
James Bardin 9e8ddaed47 Don't interpolate multivariables during walkInput
We don't need these expanded for input, and if the multivar's count is a
variable, it may be known but not available during the input walk.
2017-03-16 13:45:07 -04:00
James Bardin fe5f519817 Add failing test for invalid interpolation
Adding the submodule causes the count variable interpolation to fail.
2017-03-16 10:35:18 -04:00
Mitchell Hashimoto 37b3fe1119 release: clean up after v0.9.0 2017-03-15 16:39:53 +00:00
Mitchell Hashimoto 5bd194faa6
v0.9.0 2017-03-15 16:33:13 +00:00
James Bardin 7c9863ccb0 fix another hot lop in tests
Found another test spinlock.
Slow it down to prevent it from blocking the runtime scheduler.
2017-03-15 12:02:28 -04:00
Mitchell Hashimoto 9900bd752a
terraform: string through the context meta 2017-03-13 16:21:09 -07:00
Mitchell Hashimoto 4e1511c77f
terraform: interpolate "terraform.env" 2017-03-13 16:14:27 -07:00
James Bardin ecb1944c31 Merge pull request #12498 from hashicorp/jbardin/test-reset
Add schema.Provider.TestReset to reset StopContext between tests
2017-03-09 08:34:54 -05:00
James Bardin 5238f51dc7 move TestReset mock from terraform to helper
the terraform package doesn't know about TestProvider, so don't put the
hooks in terraform.MockResourceProvider. Wrap the mock in the test where
we need to check the TestProvider functionality.
2017-03-08 17:48:11 -05:00
James Bardin 38d2a8f6ac Fix logic race with Context.watchStop
Always wait for watchStop to return during context.walk.

Context.walk would often complete immediately after sending the close
signal to watchStop, which would in turn call the deferred releaseRun
cancelling the runContext.

Without any synchronization points after the select statement in
watchStop, that goroutine was not guaranteed to be scheduled
immediately, and in fact it often didn't continue until after the
runContext was canceled. This in turn left the select statement with
multiple successful cases, and half the time it would chose to Stop the
providers.

Stopping the providers after the walk of course didn't cause any
immediate failures, but if there was another walk performed, the
provider StopContext would no longer be valid and could cause
cancellation errors in the provider.
2017-03-08 15:11:10 -05:00
James Bardin 0279d11c8a Add TestReset to terraformMockResourceProvider
Have MockResourceProvider implement TestProvider to check that TestReset
is called by the test harness.
2017-03-07 11:39:12 -05:00
James Bardin 3e0af2abbb Sort Validation warning and errors
Make the UI output consistent
2017-03-03 09:46:08 -05:00
Mitchell Hashimoto a2d78b62aa release: clean up after v0.9.0-beta2 2017-03-02 19:42:41 +00:00
Mitchell Hashimoto dbb920ff54
v0.9.0-beta2 2017-03-02 19:38:11 +00:00
James Bardin e5e37b0025 Merge pull request #12340 from hashicorp/jbardin/GH-12253
return 0 from resourceCountMax with a nil Resource
2017-03-02 11:59:32 -05:00
Mitchell Hashimoto 19a594ba3d
terraform: run Gosched in test so other goroutines run
Starting with Go 1.8 betas, we've periodically received SIGQUITs on our
tests in Travis. The stack trace looks like this:

https://gist.github.com/mitchellh/abf09b0980f8ea01269f8d9d6133884d

The tests are timing out! This is a test that hasn't been touched really
in a very long time and has always passed. I've **reproduced this
locally** by setting `GOMAXPROCS=1` and running the test. By yielding
the scheduler in the hot loop, it now passes almost instantly every
time.

Perhaps the test can be written in a different way, but this gets tests
passing and I think will fix our periodic errors.
2017-03-01 23:12:41 -08:00
James Bardin ff445d3c26 fix test that were relying on non-matching configs
A couple interpolation tests were using invalid state that didn't match
the config. These will still pass but were flushed out by an attempt to
make this an error. The repl however still required interpolation
without a config, and tests there will provide a indication if this
behavior changes.
2017-03-01 15:24:52 -05:00
James Bardin 6fa4a591a0 prevent calling Count() on non-existent resources
It turns out that a few use cases depend on not finding a resource
without an error.

The other code paths had sufficient nil checks for this, but there was
one place where we called Count() that needed to be checked. If the
existence of the resource matters, it would be caught at a higher level
and still return an "unknown resource" error to the user.
2017-03-01 15:24:40 -05:00
James Bardin 1e80c402bf add failing test for GH-12253 2017-03-01 11:48:38 -05:00
James Bardin 41ec5b3bd2 missing defaults in sort
Need to properly catch some sort cases around 0-1 indexing.
This can cause output to shift slightly, resulting in an intermittent
test failure.
2017-02-25 16:50:24 -05:00
James Bardin 82914b5e44 Merge pull request #12219 from hashicorp/jbardin/state-mv-sort
fix sorting of module resources during state mv
2017-02-24 09:49:26 -05:00
James Bardin d6eb7c8989 one test was relying on out-of-order output 2017-02-24 09:36:24 -05:00
James Bardin 43c7bd648c fix sorting of module resources during state mv
Module resource were being sorted lexically by name by the state filter.
If there are 10 or more resources, the order won't match the index
order, and resources will have different indexes in their new location.

Sort the FilterResults by index numerically when the names match.

Clean up the module String output for visual inspection by sorting
Resource name parts numerically when they are an integer value.
2017-02-23 18:27:16 -05:00
Mitchell Hashimoto 41d2c145b2
terraform: State.Equal needs to use reflect for rich types
Due to the change to `interface{}` we need to use `reflect.DeepEqual`
here. With the restriction of primitive types this should always be
safe. We'll never get functions, channels, etc.
2017-02-23 14:00:40 -08:00
Mitchell Hashimoto 3342aa580c
terraform: InstanceState.Meta is value type interface{}
This changes the type of values in Meta for InstanceState to
`interface{}`. They were `string` before.

This will allow richer structures to be persisted to this without
flatmapping them (down with flatmap!). The documentation clearly states
that only primitives/collections are allowed here.

The only thing using this was helper/schema for schema versioning.
Appropriate type checking was added to make this change safe.

The timeout work @catsby is doing will use this for a richer structure.
2017-02-23 10:44:05 -08:00
Mitchell Hashimoto c6d0333dc0
flatmap: mark computed list as a computed value in Expand
Fixes #12183

The fix is in flatmap for this but the entire issue is a bit more
complex. Given a schema with a computed set, if you reference it like
this:

    lookup(attr[0], "field")

And "attr" contains a computed set within it, it would panic even though
"field" is available. There were a couple avenues I could've taken to
fix this:

1.) Any complex value containing any unknown value at any point is
entirely unknown.

2.) Only the specific part of the complex value is unknown.

I took route 2 so that the above works without any computed (since
"name" is not computed but something else is). This may actually have an
effect on other parts of Terraform configs, however those similar
configs would've simply crashed previously so it shouldn't break any
pre-existing configs.
2017-02-23 10:03:59 -08:00
Mitchell Hashimoto a49875067d
terraform: extra logging 2017-02-21 20:35:36 -08:00
Mitchell Hashimoto f6ab0bc5c4
terraform: interpolation failures on a destroy provisioner should error 2017-02-17 14:32:32 -08:00
Mitchell Hashimoto a1ec81964b
terraform: destroy ordering needs to handle destroy provisioner edges
This ensures that things aren't destroyed before their values are used.
2017-02-17 14:29:22 -08:00
Mitchell Hashimoto 757217b91f
terraform: destroy resource should depend on destroy-time prov deps 2017-02-17 13:13:44 -08:00
Mitchell Hashimoto ef546517be
terraform: close transform should not include untargeted providers 2017-02-17 09:27:47 -08:00
Mitchell Hashimoto 9062a1893e
terraform: don't include providers if not targeted
Fixes #12009

This is a simple change similar to #10911 where we need to exclude
providers that aren't targeted.
2017-02-17 09:21:29 -08:00
Mitchell Hashimoto 1607c1187d release: clean up after v0.9.0-beta1 2017-02-15 22:39:57 +00:00
Mitchell Hashimoto 4e96da57ee
v0.9.0-beta1 2017-02-15 22:35:37 +00:00
Mitchell Hashimoto bbae22007d Merge pull request #11921 from hashicorp/b-untarget-output
terraform: outputs should not be included if not targeted
2017-02-15 10:47:14 -08:00
Mitchell Hashimoto c36b6c42ba
terraform: test case for #10982 (passes) 2017-02-13 13:06:22 -08:00
Mitchell Hashimoto 4d6085b46a
terraform: outputs should not be included if not targeted
Fixes #10911

Outputs that aren't targeted shouldn't be included in the graph.

This requires passing targets to the apply graph. This is unfortunate
but long term should be removable since I'd like to move output changes
to the diff as well.
2017-02-13 12:52:45 -08:00
James Bardin 92cea2478d Add test for nil *os.File in ReadState 2017-02-09 16:06:07 -05:00
James Bardin 0c1b138719 Add state locking during backend init
During backend initialization, especially during a migration, there is a
chance that an existing state could be overwritten.

Attempt to get a locks when writing the new state. It would be nice to
always have a lock when reading the states, but the recursive structure
of the Meta.Backend config functions makes that quite complex.
2017-02-09 15:47:27 -05:00
Mitchell Hashimoto 8ed9bdfedc
terraform: node referenceable name from state shuldn't contain path
Fixes #11749

I'm **really** surprised this didn't come up earlier.

When only the state is available for a node, the advertised
referenceable name (the name used for dependency connections) included
the module path. This module path is automatically prepended to the
name. This means that probably every non-root resource for state-only
operations (destroys) didn't order properly.

This fixes that by omitting the path properly.

Multiple tests added to verify both graph correctness as well as a
higher level context test.

Will backport to 0.8.x
2017-02-07 20:14:38 -08:00
Mitchell Hashimoto af61d566c2
terraform: passing test for destroy edge for module only
Just adding passing tests as a sanity check for a bug.
2017-02-07 19:12:03 -08:00
Mitchell Hashimoto ac3d67e40f
terraform: remove old logging line 2017-02-07 16:28:01 -08:00
Mitchell Hashimoto 7192c1a9a1 Merge pull request #11732 from hashicorp/b-diff-map-removal
terraform: ignore RequiresNew for collection removal in diff.Same
2017-02-07 12:58:15 -08:00
Mitchell Hashimoto e7aa1fd48d Merge pull request #11733 from hashicorp/b-disable-shadow
terraform: default shadow to false
2017-02-07 12:57:46 -08:00
Mitchell Hashimoto ac934cf003
terraform: add one more forgotten ordering assertion 2017-02-07 12:01:27 -08:00
Mitchell Hashimoto a765740827
terraform: CBD destroy nodes should not advertise themselves as normal 2017-02-07 11:49:50 -08:00
Mitchell Hashimoto 44233441c2
terraform: CBD edge should ignore "index" 2017-02-07 10:53:12 -08:00