Commit Graph

591 Commits

Author SHA1 Message Date
James Bardin c080334c3f Merge pull request #12069 from hashicorp/jbardin/state-locking
Add inmem remote backend
2017-02-21 19:00:21 -05:00
James Bardin d710ecbd4d Fix regression from not having an real unlock test
args were sliced incorrectly.
2017-02-20 14:50:31 -05:00
James Bardin 5095d7c6a7 Add complete unlock test
Test actual unlock failure and success through the the unlock command.
2017-02-20 14:50:31 -05:00
clint shryock be6ae20ac1 Merge branch 'pr-8299'
* pr-8299:
  Patch up website docs
  provider/dns: DNS dynamic updates (RFC 2136)
  vendor: Capture new dependency miekg-dns
2017-02-17 17:02:37 -06:00
Chris Paris 5812bae27f RefreshState in output command 2017-02-16 18:44:43 -08:00
Mitchell Hashimoto 716132431a
command/init: initialize backend even if not set in the config
We need to initialize the backend even if the config has no backend set.
This allows `init` to work when unsetting a previously set backend.
Without this, there was no way to unset a backend.
2017-02-15 15:44:53 -08:00
James Bardin a372e9c54b fix state migration lock info 2017-02-15 17:00:54 -05:00
James Bardin ec00564be6 Clean up LockInfo and LockError and use them
Gove LockInfo a Marshal method for easy serialization, and a String
method for more readable output.

Have the state.Locker implementations use LockError when possible to
return LockInfo and an error.
2017-02-15 14:44:43 -05:00
James Bardin f2e496a14c Have backend operations properly unlock state
Make sure unlock is called with the correct LockID during operations
2017-02-15 14:41:55 -05:00
James Bardin f5ed8cd288 Use NewLockInfo to get a pre-populated value
Using NewLockInfo ensure we start with all required fields filled.
2017-02-15 14:41:55 -05:00
James Bardin 4f0c465187 make command tests pass with new state.Locker 2017-02-15 14:41:55 -05:00
James Bardin 67dc16c9ca Make backend/local test pass 2017-02-15 14:41:55 -05:00
Mitchell Hashimoto b7a143fffb
command/state: improved error message on state lock fail 2017-02-14 11:44:43 -08:00
Mitchell Hashimoto 18bc77c359
command/state: up the threshold for showing lock info 2017-02-14 11:36:21 -08:00
Mitchell Hashimoto 90f3d40c1f
command: use new state lock/unlock helpers for better UX 2017-02-14 11:33:55 -08:00
Mitchell Hashimoto 34f438b635
command/state: helpers for UX with lock/unlock state 2017-02-14 11:17:18 -08:00
Kazumichi Yamamoto cd7f69ab11 New provider arukas (#11171)
* Add a Arukas provider

* Add dependencies for the Arukas provider

* Add documents for the Arukas
2017-02-13 19:11:30 +00:00
George Hartzell e39f4e1993 Typo: determien -> determine (#11888) 2017-02-12 19:46:32 +00:00
Roberto Jung Drebes e3934c23c8 provider/dns: DNS dynamic updates (RFC 2136) 2017-02-10 21:38:26 +01: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
James Bardin 5c2e945b3c Fix format string and typos 2017-02-09 10:27:42 -05:00
Mitchell Hashimoto a5ab6e447b command/apply: update help text to be "parallel" instead of concurrent 2017-02-08 11:49:08 -08:00
James Bardin 5ca5a3c78a Merge pull request #11724 from hashicorp/jbardin/state-locking
add force-unlock command
2017-02-08 10:19:15 -05:00
James Bardin 65abe98047 Remove lock command and rename lock/force-unlock
Remove the lock command for now to avoid confusion about the behavior of
locks. Rename lock to force-unlock to make it more aparent what it does.

Add a success message, and chose red because it can be a dangerous
operation.

Add confirmation akin to `destroy`, and a `-force` option for
automation and testing.
2017-02-07 18:28:48 -05:00
Mitchell Hashimoto 0c97c5a3d9
command: tests should move to temporary cwd
This fixes any issues where rogue tfstate files may appear in the cwd
otherwise.
2017-02-07 09:11:48 -08:00
James Bardin 015198ca11 Add lock/unlock commands 2017-02-06 13:50:01 -05:00
James Bardin b80ae5e13e Add source path argument to testLockState
The new test pattern is to chdir into a temp location for the test, but
the prevents us from locating the testdata directory in the source. Add
a source path to testLockState so we can find the statelocker.go source.
2017-02-06 13:50:01 -05:00
James Bardin eb8e5ac739 Change CLI flag to '-lock' 2017-02-06 10:07:32 -05:00
James Bardin 07903189f1 s/Meta.lockState/Meta.stateLock/g 2017-02-06 09:58:04 -05:00
James Bardin cd96bb5aca Add test/untaint tests with locked state
add missing lock-state flag to untaint
2017-02-03 16:13:42 -05:00
James Bardin 82e59cd826 Add test for destroy with locked state 2017-02-03 16:06:01 -05:00
James Bardin 9fa436e0bd Add test for locked state in plan 2017-02-03 16:02:22 -05:00
James Bardin f3e4c05250 build the statelocker binary before running
this way we can signal it directly to amke sure it exits cleanly.
2017-02-03 15:59:24 -05:00
James Bardin bd65ddbcaa Add test for apply/refresh on locked state files
Verify that these operations fail when a state file is locked.
2017-02-03 15:32:40 -05:00
James Bardin fb60b6f6f2 Add separate program for locking state files
Depending on the implementation, local state locks may be reentrant
within the same process. Use a separate process to test locked state
files.
2017-02-03 15:31:21 -05:00
James Bardin 6a20c35d61 apply-test 2017-02-03 14:55:21 -05:00
James Bardin 91608843a4 Add state locking in taint/untaint 2017-02-03 14:55:21 -05:00
James Bardin a157ebbccd add -lock-state usage to plan/refresh/apply/destr 2017-02-03 14:17:17 -05:00
James Bardin 94f2f4d6ae Create state files first for backup tests
Previously when runnign a plan with no exitsing state, the plan would be
written out and then backed up on the next WriteState by another
BackupState instance. Since we now maintain a single State instance
thoughout an operation, the backup happens before any state exists so no
backup file is created.

This is OK, as the backup state the tests were checking for is from the
plan file, which already exists separate from the state.
2017-02-03 13:07:34 -05:00
James Bardin dd19cb202d add locking to plan and refresh commands 2017-02-02 18:08:28 -05:00
James Bardin 9cdba1f199 enable local state locking for apply
Have the LocalBackend lock the state during operations, and enble this
for the apply comand.
2017-02-02 18:08:28 -05:00
James Bardin 9acb86a182 Merge pull request #11187 from hashicorp/jbardin/state-locking
State Locking initial implementations
2017-02-01 14:35:55 -05:00
Seth Vargo 0d39123cb0
Update error message when no outputs are defined
Terraform can't tell the difference between an empty output and an
undefined output. This is often confusing for folks using interpolation.
As much as it would be great to fix upstream, changing this error
message to be a bit more helpful is a good stop-gap to avoid
frustration.
2017-01-31 15:20:11 -08:00
Seth Vargo 037d4b6c87
Suggest refresh instead of apply
Suggesting an apply could actually change remote resources whereas a
refresh will at-worst modify local state.
2017-01-31 15:12:11 -08:00
James Bardin 11d601ad6d TestRefresh_badState can be re-enabled
Refactored the code to maintain the behavior.
2017-01-30 18:06:30 -05:00
James Bardin 1380bbedb2 don't print err in Fatalf when it's nil 2017-01-30 18:02:35 -05:00
James Bardin b8bd4846db fix test despite original comments
Original comments were incorrect, and the test was checking for the
absence of state
2017-01-30 17:55:49 -05:00
James Bardin 39ca4fa2f8 Ensure that backend tests check for data in state
Test should not simply check for the existence of a file for state, but
make sure that file also contains data.
2017-01-30 17:48:39 -05:00
James Bardin 8f7f1917f2 Remove state file data when writing a nil state
The old behavior in this situation was to simply delete the file. Since
we now have a lock on this file we don't want to close or delete it, so
instead truncate the file at offset 0.

Fix a number of related tests
2017-01-30 17:16:57 -05:00
James Bardin eb59b5925e Fix some tests, and make rest fail with good errs
Having the state files always created for locking breaks a lot of tests.
Most can be fixed by simple checking for state within a file, but a few
still might be writing state when they shouldn't.
2017-01-30 17:16:57 -05:00