Commit Graph

20875 Commits

Author SHA1 Message Date
James Bardin ca191a3b2f
Merge pull request #16599 from hashicorp/jbardin/orphaned-module-outputs
Remove modules and module outputs from state
2017-11-09 12:33:35 -05:00
James Bardin e3ea3150ae make NodeOutputOrphan referenceable
The removed output need to be referencable so if its parent module is
also being remove, the removal happens in the correct order.
2017-11-09 10:52:46 -05:00
James Bardin e0ad3300c6 fix References used by the ReferenceTransformer
There was a bug where all references would be discarded in the case when
a self-reference was encountered. Since a module references all
descendants by it's own path, it returns a self-reference by definition.
2017-11-09 10:36:42 -05:00
James Bardin 7e4dcdb9f0 run RemovedModuleTransformer before References
Also add RemovedModuleTransformer to the plan graph for parity.
2017-11-09 10:34:56 -05:00
James Bardin 3916f3a5a3 only add nodes in RemovedModuleTransformer
Let the ReferenceTransformer connect them once it's fixed.
2017-11-09 10:32:01 -05:00
James Bardin 5915d883d2 make NodeModuleRemoved a GraphNodeReferencer
This was the node can be automatically connected by the
ReferenceTransformer.
2017-11-09 10:30:55 -05:00
James Bardin 14cc654b16 preserve order when removing module from state 2017-11-08 22:12:35 -05:00
James Bardin ccc9b1d767 replacing orphaned with removed 2017-11-08 22:10:43 -05:00
Martin Atkins 4cde21501c core: more explanation when a provider block cannot be found
Our new resource-to-provider matching is stricter about explicitly
matching aliases when config is present (no longer automatically
inherited) and with locating providers to destroy removed resources.

With this in mind, this is an attempt to expand slightly on this error
message now that users are more likely to see it.

In future it would be nice to do some explicit validation of this a bit
closer to the UI, so we can have room for more explanatory text, but this
additional messaging is intended to help users understand why they might
be seeing this message after removing a provider configuration block from
configuration, whether directly or as a side-effect of removing a module.
2017-11-08 17:00:35 -08:00
James Bardin 15ea04af8a remove modules from state
Remove the module entry from the state if a module is no longer in the
configuration. Modules are not removed if there are any existing
resources with the module path as a prefix. The only time this should be
the case is if a module was removed in the config, but the apply didn't
target that module.

Create a NodeModuleRemoved and an associated EvalDeleteModule to track
the module in the graph then remove it from the state. The
NodeModuleRemoved dependencies are simply any other node which contains
the module path as a prefix in its path.

This could have probably been done much easier as a step in pruning the
state, but modules are going to have to be promoted to full graph nodes
anyway in order to support count.
2017-11-08 19:11:53 -05:00
Martin Atkins 1750f03df9
Update CHANGELOG.md 2017-11-08 12:03:25 -08:00
James Bardin aa2bd0945b properly find orphaned outputs
You can't find orphans by walking the config, because by definition
orphans aren't in the config.

Leaving the broken test for when empty modules are removed from the
state as well.
2017-11-08 14:28:02 -05:00
James Bardin 9283568dca add OrphanOutputTransformer to the plan graph
make sure orphaned outputs appear in the plan as well
2017-11-08 14:28:02 -05:00
James Bardin 68b07a766a add failing test for orphaned modules outputs
When an entire module is removed from the config, that module's outputs
are not removed from the state.
2017-11-08 14:28:02 -05:00
James Bardin 00b7715710
Merge pull request #16586 from hashicorp/jbardin/providers
Store resolved providers in state
2017-11-08 14:27:48 -05:00
Martin Atkins 6722b7bbdc
Update CHANGELOG.md 2017-11-08 11:25:38 -08:00
Nic Cope 27ba7de77d backend/gcs: automatically add trailing slash to prefix
The backend doesn't function correctly if a trailing slash is not present, due to how workspaces are enumerated.
2017-11-08 11:24:36 -08:00
Radek Simko 2974d63e75
Merge pull request #16588 from hashicorp/f-panic-on-invalid-rd-set
helper/schema: Opt-in panic on invalid ResourceData.Set
2017-11-08 19:17:46 +00:00
Nándor István Krácser e5cc8af7f3 helper/resource: fix ungrammatical doc comment in StateChangeConf 2017-11-08 09:43:36 -08:00
Radek Simko e93d64b18c
helper/schema: Opt-in panic on invalid ResourceData.Set 2017-11-08 10:05:11 +00:00
James Bardin b8b7548614 remove module referencing existing provider 2017-11-07 22:05:52 -05:00
James Bardin 3801ca5bbf test that Refresh updates Provider fields in state 2017-11-07 21:42:30 -05:00
James Bardin 09180a10ff cannot destroy without a config 2017-11-07 21:23:37 -05:00
James Bardin d62e9217ae update test state strings for backend/local 2017-11-07 21:23:10 -05:00
James Bardin 3c807e5427 update state test strings in command package 2017-11-07 21:18:08 -05:00
James Bardin d613959cda write provider to state for import nodes
and update the test state strings
2017-11-07 21:05:37 -05:00
James Bardin 3977fe8b2d write provider to state for refresh nodes
and update the test state strings
2017-11-07 21:05:28 -05:00
James Bardin c2f3522f7d write providers to state for data resources
And update the test state strings

Destroying with no config is no longer allowed, run an exlpicit destroy
for the destroyOrder test.
2017-11-07 21:05:21 -05:00
James Bardin 8dfaae1f23 rewrite all of the test state string for providers
Now that the resolved provider is always stored in state, we need to
udpate all the test data to match. There will probably be some more
breakage once the provider field is properly diffed.
2017-11-07 13:49:43 -05:00
James Bardin b79adeae02 save resolved providers for resources to state
Use the ResourceState.Provider field to store the full name of the
provider used during apply. This field is only used when a resource is
removed from the config, and will allow that resource to be removed by
the exact same provider with which it was created.

Modify the locations which might accept the alue of the
ResourceState.Provider field to detect that the name is resolved.
2017-11-07 13:09:36 -05:00
James Bardin 990acca758 remove commented out fields 2017-11-07 10:15:11 -05:00
James Bardin b9b4912bfb complete passing providers through modules
Here we complete the passing of providers between modules via the
module/providers configuration, add another test and update broken test
outputs.

The DisbableProviderTransformer is being removed, since it was really
only for provider configuration inheritance. Since configuration is no
longer inherited, there's no need to keep around unused providers. The
actually shouldn't be any unused providers going into the graph any
longer, but put off verifying that condition for later.  Replace it's
usage with the PruneProviderTransformer, and use that to also remove the
unneeded proxy provider nodes.
2017-11-07 09:41:57 -05:00
James Bardin 49e6ecfd7a pass providers into modules via config
Implement the adding of provider through the module/providers map in the
configuration.

The way this works is that we start walking the module tree from the
top, and for any instance of a provider that can accept a configuration
through the parent's module/provider map, we add a proxy node that
provides the real name and a pointer to the actual parent provider node.
Multiple proxies can be chained back to the original provider.  When
connecting resources to providers, if that provider is a proxy, we can
then connect the resource directly to the proxied node. The proxies are
later removed by the DisabledProviderTransformer.

This should re-instate the 0.11 beta inheritance behavior, but will
allow us to later store the actual concrete provider used by a resource,
so that it can be re-connected if it's orphaned by removing its module
configuration.
2017-11-06 21:57:06 -05:00
James Bardin b15258dfec remove provider inheritance from Tree.Load
Now that resources can be connected to providers with different paths in
the core graph, handling the inheritance in config makes less sense.

Removing this to make room for core to walk the Tree and connect
resources directly to the proper provider instance.
2017-11-06 17:27:45 -05:00
James Bardin 57470f6bf5 remove ProviderConfig Path and Inherited fields
maving all inheritance into core
2017-11-06 17:11:07 -05:00
James Bardin 3297f60d03 remove raw print statements 2017-11-06 17:10:33 -05:00
James Bardin 6302916e65
Merge pull request #16572 from hashicorp/jbardin/provider-config
don't add missing provider aliases to the graph
2017-11-06 15:03:27 -05:00
James Bardin a089a4ba21
Merge pull request #16573 from hashicorp/jbardin/ProvidedBy
Minor cleanup, ProvidedBy return value is a single string
2017-11-06 15:03:12 -05:00
James Bardin 72d4e15c47 ProvidedBy return value is a single string
Clean up ProvidedBy, which doesn't need to be a slice.
2017-11-06 14:27:01 -05:00
James Bardin d9d21d4200 don't add missing provider aliases to the graph
A missing provider alias should not be implicitly added to the graph.

Run the AttachaProviderConfigTransformer immediately after adding the
providers, since the ProviderConfigTransformer should have just added
these nodes.
2017-11-06 14:21:28 -05:00
Malik Bougacha ed0d57d1b7 Get the enviroment from the environment variable (#16326)
* Get the enviroment from the enviroment variable

* typo
2017-11-06 16:59:48 +00:00
James Belchamber ec2281106f Adding documentation for all supported imports in the Heroku provider (#16312) 2017-11-06 16:57:57 +00:00
Dominik Lekse 323654a716 Fixed documentation of azurerm backend advanced access variables (#16552)
Signed-off-by: Dominik Lekse <dominik@lekse.de>
2017-11-06 16:54:30 +00:00
Chris Marchesi 1bed7deb8f
Merge pull request #16565 from hashicorp/b-mapwriter-overwrites
helper/schema: Clear existing map/set/list contents before overwriting
2017-11-06 08:33:11 -08:00
Andy Brody 4b1c7a1d9b website: Fix broken link in 0.10 upgrade guide 2017-11-05 18:21:49 -08:00
Chris Marchesi 3fa11e456b
helper/schema: Clear existing map/set/list contents before overwriting
There are situations where one may need to write to a set, list, or map
more than once per single TF operation (apply/refresh/etc). In these
cases, further writes using Set (example: d.Set("some_set", newSet))
currently create unstable results in the set writer (the name of the
writer layer that holds the data set by these calls) because old keys
are not being cleared out first.

This bug is most visible when using sets. Example: First write to set
writes elements that have been hashed at 10 and 20, and the second write
writes elements that have been hashed at 30 and 40. While the set length
has been correctly set at 2, since a set is basically a map (as is the
entire map writer) and map results are non-deterministic, reads to this
set will now deliver unstable results in a random but predictable
fashion as the map results are delivered to the caller non-deterministic
- sometimes you may correctly get 30 and 40, but sometimes you may get
10 and 20, or even 10 and 30, etc.

This problem propagates to state which is even more damaging as unstable
results are set to state where they become part of the permanent data
set going forward.

The problem also applies to lists and maps. This is probably more of an
issue with maps as a map can contain any key/value combination and hence
there is no predictable pattern where keys would be overwritten with
default or zero values. This is contrary to complex lists, which has
this problem as well, but since lists are deterministic and the length
of a list properly gets updated during the overwrite, the problem is
masked by the fact that a read will only read to the boundary of the
list, skipping any bad data that may still be available due past the
list boundary.

This update clears the child contents of any set, list, or map before
beginning a new write to address this issue. Tests are included for all
three data types.
2017-11-05 12:04:23 -08:00
Martin Atkins 645df36af0 release: clean up after v0.11.0-beta1 2017-11-03 23:51:47 +00:00
Martin Atkins 23caaf9feb
v0.11.0-beta1 2017-11-03 23:17:07 +00:00
Martin Atkins 37e276e043 core: test correct behavior of plan+apply with unstable values
We have a few pesky functions that don't act like proper functions and
instead return different values on each call. These are tricky because
we need to make sure we don't trip over ourselves by re-generating these
between plan and apply.

Here we add a context test to verify correct behavior in the presence
of such functions.

There's actually a pre-existing bug which this test caught as originally
written: we re-evaluate the interpolation expressions during apply,
causing these unstable functions to produce new values, and so the
applied value ends up not exactly matching the plan. This is a bug that
needs fixing, but it's been around at least since v0.7.6 (random old
version I tried this with to see) so we'll put it on the list and address
it separately. For now, this part of the test is commented out with a
TODO attached.
2017-11-03 16:11:13 -07:00
Martin Atkins c003e8f9a6 core: don't compare attribute values in Diff.Same
We previously didn't compare values but had a TODO to start doing so,
which we then recently did. Unfortunately it turns out that we _depend_
on not comparing values here, because when we use EvalCompareDiff (a key
user of Diff.Same) we pass in a diff made from a fresh re-interpolation
of the configuration and so any non-pure function results (timestamp,
uuid) have produced different values.
2017-11-03 16:11:13 -07:00