Michael Schurter
12171cdc28
make AllocBroadcaster easier to use
...
And test thoroughly.
2018-10-16 16:53:30 -07:00
Michael Schurter
9da25adc54
client: hclog-ify most of the client
...
Leaving fingerprinters in case that interface changes with plugins.
2018-10-16 16:53:30 -07:00
Michael Schurter
c95155d45c
implement stopping, destroying, and disk migration
...
* Stopping an alloc is implemented via Updates but update hooks are
*not* run.
* Destroying an alloc is a best effort cleanup.
* AllocRunner destroy hooks implemented.
* Disk migration and blocking on a previous allocation exiting moved to
its own package to avoid cycles. Now only depends on alloc broadcaster
instead of also using a waitch.
* AllocBroadcaster now only drops stale allocations and always keeps the
latest version.
* Made AllocDir safe for concurrent use
Lots of internal contexts that are currently unused. Unsure if they
should be used or removed.
2018-10-16 16:53:30 -07:00
Michael Schurter
de5426124b
lots of comment/log fixes
2018-10-16 16:53:30 -07:00
Michael Schurter
051c5ea891
keep forgetting lxc
2018-10-16 16:53:30 -07:00
Michael Schurter
b97bbd9d30
persist alloc state on changes, not periodically
...
Allow alloc and task runners to persist their own state when something
changes instead of periodically syncing all state.
2018-10-16 16:53:30 -07:00
Michael Schurter
c0d1b63b75
wrap boltdb in a write deduplicator
...
Saves a tiny bit of cpu and some IO. Sadly doesn't prevent all IO on
duplicate writes as the transactions are still created and committed.
$ go test -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/hashicorp/nomad/helper/boltdd
BenchmarkWriteDeduplication_On-4 500 4059591 ns/op 23736 B/op 56 allocs/op
BenchmarkWriteDeduplication_Off-4 300 4115319 ns/op 25942 B/op 55 allocs/op
2018-10-16 16:53:30 -07:00
Michael Schurter
e808a1bb35
wip wrap boltdb to get path information
...
finished but doesn't handle deleting deeply nested buckets
2018-10-16 16:53:30 -07:00
Michael Schurter
c9e97123e6
Move all encoding and put deduping into state db
...
Still WIP as it does not handle deletions.
2018-10-16 16:53:30 -07:00
Michael Schurter
63fea0c888
implement all boltdb interactions behind StateDB
2018-10-16 16:53:30 -07:00
Michael Schurter
27894a5ff8
tr: persist hook state whenever it changes
2018-10-16 16:53:30 -07:00
Michael Schurter
e8036fff78
artifacts: don't emit event when there's no artifacts
2018-10-16 16:53:30 -07:00
Michael Schurter
8958919a5f
removing old restoration path before api change
2018-10-16 16:53:30 -07:00
Michael Schurter
7ca41a89c4
Implement alloc updates in arv2
...
Updates are applied asynchronously but sequentially
2018-10-16 16:53:30 -07:00
Michael Schurter
97dbf99d3f
call handle.Network() instead of storing it
2018-10-16 16:53:30 -07:00
Michael Schurter
cea2b879e4
Add Network method to Handle interface
...
Should probably be moved to an Inspect method in the Driver Plugin world
2018-10-16 16:53:30 -07:00
Michael Schurter
76194c7414
consul service hook
...
Deregistration works but difficult to test due to terminal updates not
being fully implemented in the new client/ar/tr.
2018-10-16 16:53:29 -07:00
Michael Schurter
bb273896b5
restore vault client
2018-10-16 16:53:29 -07:00
Michael Schurter
3bca9472f0
log before killing tasks
2018-10-16 16:53:29 -07:00
Michael Schurter
a744845ac7
no need to TaskStateUpdated to return an error
...
also updated comments
2018-10-16 16:53:29 -07:00
Alex Dadgar
52ae83d4d5
Update state with server
2018-10-16 16:53:29 -07:00
Alex Dadgar
ebf1aa0952
Define and thread through state updating interface
2018-10-16 16:53:29 -07:00
Michael Schurter
fae947419d
tr: add validate task hook
2018-10-16 16:53:29 -07:00
Michael Schurter
b09b552ae5
missed locking around c.allocs access
2018-10-16 16:53:29 -07:00
Alex Dadgar
4f2d6415ca
wip
2018-10-16 16:53:29 -07:00
Alex Dadgar
cdabf425b9
Fix deadlock
2018-10-16 16:53:29 -07:00
Alex Dadgar
bbcc916030
Remove SetState from interface
2018-10-16 16:53:29 -07:00
Alex Dadgar
9c04ed379c
compile
2018-10-16 16:53:29 -07:00
Michael Schurter
457250b687
wip split event emitting and state transitions
2018-10-16 16:53:29 -07:00
Michael Schurter
7e60f0ba77
client: implement all-or-nothing alloc restoration
...
Restoring calls NewAR -> Restore -> Run
NewAR now calls NewTR
AR.Restore calls TR.Restore
AR.Run calls TR.Run
2018-10-16 16:53:29 -07:00
Alex Dadgar
80303412de
Implement lifecycle hooks on the task runner
2018-10-16 16:53:29 -07:00
Alex Dadgar
c19ea97011
comments
2018-10-16 16:53:29 -07:00
Alex Dadgar
912d3613ec
Hook renames
2018-10-16 16:53:29 -07:00
Alex Dadgar
05a0565040
remove comment
2018-10-16 16:53:29 -07:00
Alex Dadgar
711d09e1be
Template hook
2018-10-16 16:53:29 -07:00
Alex Dadgar
781c498070
address comments
2018-10-16 16:53:29 -07:00
Alex Dadgar
427eab563a
vault hook
2018-10-16 16:53:29 -07:00
Michael Schurter
fdd3bb63d4
tr: improve skip log line
2018-10-16 16:53:29 -07:00
Michael Schurter
eea820ecf1
tr: pass context to hooks
2018-10-16 16:53:29 -07:00
Michael Schurter
d3d590f175
tr: fix setting done in existing hooks
2018-10-16 16:53:29 -07:00
Michael Schurter
bfbc95e258
fix hclog level
2018-10-16 16:53:29 -07:00
Michael Schurter
4107afdbf6
reimplement success state for tr hooks and state persistence
...
splits apart local and remote persistence
removes some locking *for now*
2018-10-16 16:53:29 -07:00
Michael Schurter
370d92ff2e
pass statedb into allocrunnerv2
2018-10-16 16:53:29 -07:00
Michael Schurter
6250509a76
remove unused allocrunner shim
2018-10-16 16:53:29 -07:00
Michael Schurter
07d5bacee8
tr: cleanup main loop and shutdown hook impl
2018-10-16 16:53:29 -07:00
Michael Schurter
1e24cd6cfc
tr: skip error/success saving
...
All hooks only need to be run once.
Since only one hook can fail per run there's no need to
track errors on a per hook basis.
2018-10-16 16:53:29 -07:00
Michael Schurter
256bc5a14c
tr: don't lock for immutable fields
2018-10-16 16:53:29 -07:00
Michael Schurter
124ad51944
tr: start update/shutdown logic
2018-10-16 16:53:29 -07:00
Michael Schurter
2d90ec63f3
Copy TR.Config vals to TR
...
I think I like this pattern better as some Config vals are mutable
(Alloc) and some aren't and some are used to derive other values and
never used directly.
Promoting them onto the TR struct is a little more work but is hopefully
more clear as to how each value is used.
2018-10-16 16:53:29 -07:00
Michael Schurter
53a4b3fe99
example redis job "runs" on arv2! see below
...
Tons left to do and lots of churn:
1. No state saving
2. No shutdown or gc
3. Removed AR factory *for now*
4. Made all "Config" structs local to the package they configure
5. Added allocID to GC to avoid a lookup
Really hating how many things use *structs.Allocation. It's not bad
without state saving, but if AllocRunner starts updating its copy things
get racy fast.
2018-10-16 16:53:29 -07:00