terraform/state/remote
Martin Atkins 4d53eaa6df state: more robust handling of state Serial
Previously we relied on a constellation of coincidences for everything to
work out correctly with state serials. In particular, callers needed to
be very careful about mutating states (or not) because many different bits
of code shared pointers to the same objects.

Here we move to a model where all of the state managers always use
distinct instances of state, copied when WriteState is called. This means
that they are truly a snapshot of the state as it was at that call, even
if the caller goes on mutating the state that was passed.

We also adjust the handling of serials so that the state managers ignore
any serials in incoming states and instead just treat each Persist as
the next version after what was most recently Refreshed.

(An exception exists for when nothing has been refreshed, e.g. because
we are writing a state to a location for the first time. In that case
we _do_ trust the caller, since the given state is either a new state
or it's a copy of something we're migrating from elsewhere with its
state and lineage intact.)

The intent here is to allow the rest of Terraform to not worry about
serials and state identity, and instead just treat the state as a mutable
structure. We'll just snapshot it occasionally, when WriteState is called,
and deal with serials _only_ at persist time.

This is intended as a more robust version of #15423, which was a quick
hotfix to an issue that resulted from our previous slopping handling
of state serials but arguably makes the problem worse by depending on
an additional coincidental behavior of the local backend's apply
implementation.
2017-07-05 12:34:30 -07:00
..
artifactory.go add artifactory remote state storage 2015-10-29 09:33:09 -04:00
artifactory_test.go add artifactory remote state storage 2015-10-29 09:33:09 -04:00
azure.go provider/azurerm: Upgrading to AutoRest v8 (#15006) 2017-06-02 15:30:41 +01:00
azure_test.go provider/azurerm: Upgrading to v10 of the Azure SDK (#14004) 2017-06-01 10:18:22 +01:00
etcd.go Use cleanhttp for new http clients 2015-10-22 14:23:59 -04:00
etcd_test.go Etcd remote state backend 2015-10-18 23:24:55 +02:00
file.go state/remote: add undocumented file backend for remote state 2015-03-05 13:15:14 -08:00
file_test.go state/remote: add undocumented file backend for remote state 2015-03-05 13:15:14 -08:00
gcs.go remote state: Add GCS provider for remote state 2016-05-31 13:42:57 -05:00
gcs_test.go remote state: Add GCS provider for remote state 2016-05-31 13:42:57 -05:00
http.go Basic authentication for HTTP remote state backend 2017-01-19 21:01:50 -05:00
http_test.go Use cleanhttp for new http clients 2015-10-22 14:23:59 -04:00
manta.go state/remote: New provider - manta 2016-09-14 20:44:52 +01:00
manta_test.go state/remote: New provider - manta 2016-09-14 20:44:52 +01:00
remote.go remote/swift: Migrate Swift remote state to a backend 2017-06-13 22:04:01 +01:00
remote_test.go Make remote state test run 2017-02-15 14:41:55 -05:00
state.go state: more robust handling of state Serial 2017-07-05 12:34:30 -07:00
state_test.go add mutexes to remote.State 2017-05-25 11:20:52 -04:00
testing.go Have consul state reutrn the lock ID 2017-02-15 14:44:43 -05:00