Commit Graph

494 Commits

Author SHA1 Message Date
Frank Schroeder 80d9df69e4
Revert "local state: fix test with updated error message"
This reverts commit e9149f64d9afb38246f9432edd806321c1eefb83.
2017-10-23 10:08:34 +02:00
Frank Schroeder ded6f79b6a
Revert "local state: fix anti-entropy state tests"
This reverts commit f8e20cd9960e19bbe61e258c445250723870816f.
2017-10-23 10:08:34 +02:00
Frank Schroeder 9b40a3cde6
Revert "agent: skip non-sensical TestCatalogRegister"
This reverts commit ce1f35373e6ad1486cb83398fce70f5c54f910d3.
2017-10-23 10:08:34 +02:00
Frank Schroeder 5aa77fb9e4
Revert "local state: drop retry loops from tests"
This reverts commit 2bdba8ab06d1c9dd99d5e7cf8370c94b4f7adfaa.
2017-10-23 10:08:34 +02:00
Frank Schroeder d7bb81a940
Revert "local state: rename tests"
This reverts commit ff62eaf0634a4c09377c53d4623685437f217b49.
2017-10-23 10:08:34 +02:00
Frank Schroeder 3d67ce9000
Revert "local state: fix TestAgentAntiEntropy_EnableTagOverride"
This reverts commit 86f7ea601342d6f3ceb9d0dc74bd5b33dae0b8d8.
2017-10-23 10:08:34 +02:00
Frank Schroeder 1bd73d2a6e
Revert "local state: refactor TestAgentAntiEntropy_EnableTagOverride"
This reverts commit c28e23eac8ada7a668b13e9a4a3d8066457488ef.
2017-10-23 10:08:33 +02:00
Frank Schroeder c72d21813b
Revert "local state: address review comments"
This reverts commit 1d315075b15647db7fcd42986c9c5673cbb77a77.
2017-10-23 10:08:33 +02:00
Frank Schroeder 4177bad4f3
Revert "local state: update comments"
This reverts commit 42188164f885188e3bc8cff70ea5aeb47d633b83.
2017-10-23 10:08:33 +02:00
Frank Schroeder d1e514cedc
Revert "local state: update documentation of updateSyncState"
This reverts commit e86521e637d742bce1e460b6b960037cef3578ed.
2017-10-23 10:08:33 +02:00
Frank Schroeder 133b23fb77
Revert "local state: move Metadata methods together"
This reverts commit 9bc8127728a62beb94b28849070b6ac35c181404.
2017-10-23 10:08:33 +02:00
Frank Schroeder 67135cc33e
Revert "local state: rename Add{Check,Service}State to Set{Check,Service}State"
This reverts commit 9280841a80d98b253a8f23967875e45e5e37e093.
2017-10-23 10:08:33 +02:00
Frank Schroeder 79405b7ce3
Revert "ae: ensure that syncs are blocked when paused"
This reverts commit ffb265dd939cefd7e865d624d0a4ba81f88e4505.
2017-10-23 10:08:33 +02:00
Frank Schroeder cb28151210
Revert "ae: restore previous pause/resume behavior"
This reverts commit 126046be2366afde97fdf01d0dceece2977dd6d6.
2017-10-23 10:08:33 +02:00
Frank Schroeder ec186ca7ba
Revert "ae: make stagger function pluggable for testing"
This reverts commit 066ad01c3804a39161c4d46147aa2eb86e48cd67.
2017-10-23 10:08:33 +02:00
Frank Schroeder 272b729ad9
Revert "ae: add test for ifNotPausedRun"
This reverts commit f5177ef332b8396aea368b7dea18a976e029a54f.
2017-10-23 10:08:33 +02:00
Frank Schroeder 54cebeda74
Revert "ae: add test for resume triggering SyncChanges"
This reverts commit cd0262744deab9294af17e4039ed2e2a27818cde.
2017-10-23 10:08:32 +02:00
Frank Schroeder 7a92839663
Revert "ae: fix typo in constructor name"
This reverts commit e88f49e2ccc79f77b5395de28d8fbdfc6eeb36f6.
2017-10-23 10:08:32 +02:00
Frank Schroeder 4bdf161d5c
Revert "ae: make control flow more explicit"
This reverts commit b9a8b53d5257d679c427422c324e6f124664db60.
2017-10-23 10:08:32 +02:00
Frank Schroeder 6eae18ac63
Revert "ae: add test that we run a full before a partial sync"
This reverts commit 8158cec82969a1262de793ee46e13f63cc2954e6.
2017-10-23 10:08:32 +02:00
Frank Schroeder 701ed61230
Revert "ae: refactor StateSyncer to state machine for better testing"
This reverts commit 8a45365f68147dd13c1232bc574bd54e4a12e478.
2017-10-23 10:08:32 +02:00
Frank Schroeder 27b8e55dc4
Revert "ae: add remaining test cases"
This reverts commit c32915bb4ff28b1670e88edaf0bbb9779dc6e2bc.
2017-10-23 10:08:32 +02:00
Frank Schroeder c27a2f1c66
Revert "ae: do not trigger on Resume while holding the lock"
This reverts commit bd00814301bbf5db037e739e91a0b66ebb564821.
2017-10-23 10:08:32 +02:00
Frank Schroeder 655a24e383
Revert "local state: use synchronized access to internal maps"
This reverts commit 39a2d8d25e629823e183e384e8414171edcf4164.
2017-10-23 10:08:32 +02:00
Frank Schroeder fe0f7c961d
Revert "local state: clone check to avoid side effect"
This reverts commit af1243c7251fe6291145bbe4f4dacd374779c425.
2017-10-23 10:08:32 +02:00
Frank Schroeder a6e55af1e0
Revert "local state: make test more robust"
This reverts commit f9267380dbcdb2746393eee5067e5037dff2b184.
2017-10-23 10:08:32 +02:00
Frank Schroeder 64d9529d94
Revert "local state: remove stale comment"
This reverts commit 35f4acdddc38f0371543e12b0d2ccb27a0a64869.
2017-10-23 10:08:32 +02:00
Frank Schroeder aaf6e376e2
Revert "config: document telemetry options"
This reverts commit 7fede4472d4db87b4652253510556906821ac756.
2017-10-23 10:08:31 +02:00
Frank Schroeder dcb70f7def
Revert "config: document http options"
This reverts commit 5f598574483e59af377ae447857d40872563ac87.
2017-10-23 10:08:31 +02:00
Frank Schroeder 1ce9c1ba45
Revert "config: document dns options"
This reverts commit 5e57e9273ea6e27eb79ed531189fd3c69e19c7b2.
2017-10-23 10:08:31 +02:00
Frank Schroeder 3638b2932d
Revert "config: document autopilot options"
This reverts commit 7685ef409c9340227e3969a86e0bfa627eafdd0f.
2017-10-23 10:08:31 +02:00
Frank Schroeder 32c8d7e0db
Revert "config: document acl options"
This reverts commit 7396bd31fd1c35347d0c88284ea358bfbd9ca948.
2017-10-23 10:08:31 +02:00
Frank Schroeder 83bfe0d223
Revert "config: document config options"
This reverts commit a38c69d7844a4e4a9d54051470977c7446fc8e57.
2017-10-23 10:08:31 +02:00
Frank Schroeder ff42a00ef1
Revert "config: document more acl options"
This reverts commit 2682ce0b825528f379487cbd11c2c2a321fd94e8.
2017-10-23 10:08:31 +02:00
Frank Schroeder 6ae5c0594a
Revert "config: document more config options"
This reverts commit bf81cdea6eb90ae099201c545910780ccd020540.
2017-10-23 10:08:31 +02:00
Frank Schroeder 2d96f700c0
Revert "config: document more config options"
This reverts commit 9864609201f333cd90af9535e2e4d4c7c1e65c4a.
2017-10-23 10:08:31 +02:00
Frank Schroeder bd72f3676d
Revert "config: document remaining config options"
This reverts commit 0ed4561f12cf52a44ab1f1887d4f4bfd27df77f4.
2017-10-23 10:08:31 +02:00
Frank Schroeder 64ac9f4f42
Revert "config: address review comments"
This reverts commit f6e9ad99ec6d230c1eb7f655d2a83e5a4e33807d.
2017-10-23 10:08:31 +02:00
Frank Schroeder c5c586c7f1
Revert "fix go vet issue"
This reverts commit 078e50b635846920a17a3b06c678b2b63b40677a.
2017-10-23 10:00:26 +02:00
Frank Schröder b580f7a533 Revert "config: rename test struct field to args"
This reverts commit f2a291a4704c9954c441567860ca740ac0f58308.
2017-10-23 09:58:37 +02:00
Frank Schröder 0f0b510f37 Revert "config: return error on extra command line arguments (#3397)"
This reverts commit ce935cef55f7298e85843b3ca17ad13415e40e0b.
2017-10-23 09:58:37 +02:00
Frank Schroeder ef3108abc3
fix go vet issue 2017-10-23 08:13:52 +02:00
Frank Schroeder 24689c4f5e config: return error on extra command line arguments (#3397)
The `consul agent` command was ignoring extra command line arguments
which can lead to confusion when the user has for example forgotten to
add a dash in front of an argument or is not using an `=` when setting
boolean flags to `true`. `-bootstrap true` is not the same as
`-bootstrap=true`, for example.

Since all command line flags are known and we don't expect unparsed
arguments we can return an error. However, this may make it slightly
more difficult in the future if we ever wanted to have these kinds of
arguments.

Fixes #3397
2017-10-23 08:08:09 +02:00
Frank Schroeder c8ed3044de config: rename test struct field to args 2017-10-23 08:08:09 +02:00
Frank Schroeder c624c72d5c
config: return error on extra command line arguments (#3397)
The `consul agent` command was ignoring extra command line arguments
which can lead to confusion when the user has for example forgotten to
add a dash in front of an argument or is not using an `=` when setting
boolean flags to `true`. `-bootstrap true` is not the same as
`-bootstrap=true`, for example.

Since all command line flags are known and we don't expect unparsed
arguments we can return an error. However, this may make it slightly
more difficult in the future if we ever wanted to have these kinds of
arguments.

Fixes #3397
2017-10-23 08:07:48 +02:00
Frank Schroeder c1d249c681
config: rename test struct field to args 2017-10-23 08:07:48 +02:00
Frank Schroeder 88a1f3aa53 config: address review comments 2017-10-23 08:06:26 +02:00
Frank Schroeder 97277de196 config: document remaining config options 2017-10-23 08:06:26 +02:00
Frank Schroeder 638bc0e0ac config: document more config options 2017-10-23 08:06:26 +02:00
Frank Schroeder f326eae23e config: document more config options 2017-10-23 08:06:26 +02:00
Frank Schroeder 6332f4d6a7 config: document more acl options 2017-10-23 08:06:26 +02:00
Frank Schroeder 61c8ee564a config: document config options 2017-10-23 08:06:26 +02:00
Frank Schroeder 71112a6510 config: document acl options 2017-10-23 08:06:26 +02:00
Frank Schroeder e00869647c config: document autopilot options 2017-10-23 08:06:26 +02:00
Frank Schroeder 05c1038d58 config: document dns options 2017-10-23 08:06:26 +02:00
Frank Schroeder a17d711b39 config: document http options 2017-10-23 08:06:26 +02:00
Frank Schroeder f95b8f5060 config: document telemetry options 2017-10-23 08:06:26 +02:00
Frank Schroeder 44cc334fc4
config: address review comments 2017-10-23 08:05:47 +02:00
Frank Schroeder 28083cb330
config: document remaining config options 2017-10-23 08:04:03 +02:00
Frank Schroeder b2c2386d75
config: document more config options 2017-10-23 08:04:03 +02:00
Frank Schroeder 7b1f4d5838
config: document more config options 2017-10-23 08:04:03 +02:00
Frank Schroeder b01702f129
config: document more acl options 2017-10-23 08:04:03 +02:00
Frank Schroeder 32ed645df5
config: document config options 2017-10-23 08:04:03 +02:00
Frank Schroeder 3d68185206
config: document acl options 2017-10-23 08:04:03 +02:00
Frank Schroeder 4fc973a256
config: document autopilot options 2017-10-23 08:04:03 +02:00
Frank Schroeder 66e1b9fb64
config: document dns options 2017-10-23 08:04:03 +02:00
Frank Schroeder dc4e90e6c0
config: document http options 2017-10-23 08:04:03 +02:00
Frank Schroeder 018b8d66d6
config: document telemetry options 2017-10-23 08:04:03 +02:00
Frank Schroeder 39dddd433e local state: remove stale comment 2017-10-23 08:03:18 +02:00
Frank Schroeder 779bf04aa3 local state: make test more robust 2017-10-23 08:03:18 +02:00
Frank Schroeder e16c8f3982 local state: clone check to avoid side effect 2017-10-23 08:03:18 +02:00
Frank Schroeder f1028d2486 local state: use synchronized access to internal maps 2017-10-23 08:03:18 +02:00
Frank Schroeder 606e13a569 ae: do not trigger on Resume while holding the lock 2017-10-23 08:03:18 +02:00
Frank Schroeder 82e9494f7f ae: add remaining test cases 2017-10-23 08:03:18 +02:00
Frank Schroeder cf6e6c72ac ae: refactor StateSyncer to state machine for better testing 2017-10-23 08:03:18 +02:00
Frank Schroeder ba8cb5e3d0 ae: add test that we run a full before a partial sync 2017-10-23 08:03:18 +02:00
Frank Schroeder 0d73333c8e ae: make control flow more explicit 2017-10-23 08:03:18 +02:00
Frank Schroeder 0cfe0a42f1 ae: fix typo in constructor name 2017-10-23 08:03:18 +02:00
Frank Schroeder 25ee03e165 ae: add test for resume triggering SyncChanges 2017-10-23 08:03:18 +02:00
Frank Schroeder f61ad4efcd ae: add test for ifNotPausedRun 2017-10-23 08:03:18 +02:00
Frank Schroeder c2ab582d47 ae: make stagger function pluggable for testing 2017-10-23 08:03:18 +02:00
Frank Schroeder f352952fb3 ae: restore previous pause/resume behavior 2017-10-23 08:03:18 +02:00
Frank Schroeder c1badf1034 ae: ensure that syncs are blocked when paused 2017-10-23 08:03:18 +02:00
Frank Schroeder a4d03797ae local state: rename Add{Check,Service}State to Set{Check,Service}State 2017-10-23 08:03:18 +02:00
Frank Schroeder 7414fe0a2a local state: move Metadata methods together 2017-10-23 08:03:18 +02:00
Frank Schroeder 3e953f67da local state: update documentation of updateSyncState 2017-10-23 08:03:18 +02:00
Frank Schroeder ecea35d955 local state: update comments 2017-10-23 08:03:18 +02:00
Frank Schroeder 40e17f9f01 local state: address review comments
* move non-blocking notification mechanism into ae.Trigger
* move Pause/Resume into separate type
2017-10-23 08:03:18 +02:00
Frank Schroeder cfc8bd092f local state: refactor TestAgentAntiEntropy_EnableTagOverride
Make intent clearer by being more explicit and adding some comments.
Use verify.Values to compare service entries.
2017-10-23 08:03:18 +02:00
Frank Schroeder b288c1eb9b local state: fix TestAgentAntiEntropy_EnableTagOverride
The test had a race condition where it relied on the first service to be
synced to the remote catalog which sometimes failed.
2017-10-23 08:03:18 +02:00
Frank Schroeder 71e4d7cd1c local state: rename tests 2017-10-23 08:03:18 +02:00
Frank Schroeder f43972fdc2 local state: drop retry loops from tests
Since the tests are now using synchronous calls for state syncing
we no longer need to use retry loops to wait for the changes to
propagate.
2017-10-23 08:03:18 +02:00
Frank Schroeder 3d10312cd6 agent: skip non-sensical TestCatalogRegister
It is not clear what this test is supposed to verify.
2017-10-23 08:03:18 +02:00
Frank Schroeder 2bef1d4d51 local state: fix anti-entropy state tests
The anti-entropy tests relied on the side-effect of the StartSync()
method to perform a full sync instead of a partial sync. This lead to
multiple anti-entropy go routines being started unnecessary retry loops.

This change changes the behavior to perform synchronous full syncs when
necessary removing the need for all of the time.Sleep and most of the
retry loops.
2017-10-23 08:03:18 +02:00
Frank Schroeder 36677bc90d local state: fix test with updated error message 2017-10-23 08:03:18 +02:00
Frank Schroeder 37c8492e5e local state: fix failing tests 2017-10-23 08:03:18 +02:00
Frank Schroeder 884f98f8aa local state: tests compile 2017-10-23 08:03:18 +02:00
Frank Schroeder 60095484c4 local state: replace multi-map state with structs
The state of the service and health check records was spread out over
multiple maps guarded by a single lock. Access to the maps has to happen
in a coordinated effort and the tests often violated this which made
them brittle and racy.

This patch replaces the multiple maps with a single one for both checks
and services to make the code less fragile.

This is also necessary since moving the local state into its own package
creates circular dependencies for the tests. To avoid this the tests can
no longer access internal data structures which they should not be doing
in the first place.

The tests still don't compile but this is a ncessary step in that
direction.
2017-10-23 08:03:18 +02:00
Frank Schroeder ef9aa6b3b6 local state: move to separate package
This patch moves the local state to a separate package to further
decouple it from the agent code.

The code compiles but the tests do not yet.
2017-10-23 08:03:18 +02:00
Frank Schroeder c03eba91d0 agent: simplify some loops 2017-10-23 08:03:18 +02:00
Frank Schroeder 98e5dc86fb agent: refactor sync loop to linear flow of control 2017-10-23 08:03:18 +02:00
Frank Schroeder 5302479ad5 agent: cleanup StateSyncer
This patch cleans up the state syncer code by renaming fields, adding
helpers and documentation.
2017-10-23 08:03:18 +02:00
Frank Schroeder 034ee43cef agent: decouple anti-entropy from local state
The anti-entropy code manages background synchronizations of the local
state on a regular basis or on demand when either the state has changed
or a new consul server has been added.

This patch moves the anti-entropy code into its own package and
decouples it from the local state code since they are performing
two different functions.

To simplify code-review this revision does not make any optimizations,
renames or refactorings. This will happen in subsequent commits.
2017-10-23 08:03:18 +02:00
Frank Schroeder 6df6ac03b7 config: do not allow an ANY address as DNS recursor 2017-10-23 08:01:25 +02:00
Frank Schroeder 3b13290144 config: add support for go-sockaddr templates for DNS recursors
DNS recursors can be added through go-sockaddr templates. Entries
are deduplicated while the order is maintained.

Originally proposed by @taylorchu

See #2932
2017-10-23 08:01:25 +02:00
James Phillips 2e7d048345
Cleans up import sorting. 2017-10-21 20:08:11 -07:00
Hadar Greinsmark 0c5f5e2821 Implement HTTP Watch handler (#3413)
Implement HTTP Watch handler
2017-10-21 20:39:09 -05:00
Frank Schroeder 74859ff3c0 test: replace porter tool with freeport lib
This patch removes the porter tool which hands out free ports from a
given range with a library which does the same thing. The challenge for
acquiring free ports in concurrent go test runs is that go packages are
tested concurrently and run in separate processes. There has to be some
inter-process synchronization in preventing processes allocating the
same ports.

freeport allocates blocks of ports from a range expected to be not in
heavy use and implements a system-wide mutex by binding to the first
port of that block for the lifetime of the application. Ports are then
provided sequentially from that block and are tested on localhost before
being returned as available.
2017-10-21 22:01:09 +02:00
Frank Schröder d26b0406e4 dns: return NXDOMAIN if datacenter is invalid (#3200) (#3596)
Queries to the DNS server can contain an optional datacenter
name in the query name. You can query for 'foo.service.consul'
or 'foo.service.dc.consul' to get a response for either the
default or a specific datacenter.

Datacenter names cannot have dots, therefore the datacenter
name can refer to only one element in the DNS query name.

The DNS server allowed extra labels between the optional
datacenter name and the domain and returned a valid response
instead of returning NXDOMAIN. For example, if the domain
is set to '.consul' then 'foo.service.dc1.extra.consul'
should return NXDOMAIN because of 'extra' being between
the datacenter name 'dc1' and the domain '.consul'.

Fixes #3200
2017-10-20 16:49:17 -07:00
Frank Schroeder 6628ca1cf1
config: do not allow an ANY address as DNS recursor 2017-10-20 20:00:45 +02:00
Frank Schroeder 2c4f98cf12
config: add support for go-sockaddr templates for DNS recursors
DNS recursors can be added through go-sockaddr templates. Entries
are deduplicated while the order is maintained.

Originally proposed by @taylorchu

See #2932
2017-10-20 15:51:49 +02:00
James Phillips 3d52f42715 Fixes API client for ScriptArgs and updates documentation. (#3589)
* Updates the API client to support the current `ScriptArgs` parameter
for checks.

* Updates docs for checks to explain the `ScriptArgs` parameter issue.

* Adds mappings for "args" and "script-args" to give th API parity
with config.

* Adds checks on return codes.

* Removes debug logging that shows empty when args are used.
2017-10-18 11:28:39 -07:00
Ryan Slade 6f05ea91a3 Replace time.Now().Sub(x) with time.Since(x) 2017-10-17 20:38:24 +02:00
James Phillips 39f2359804 Fixes an XSS issue with unescaped node names. (#3578)
* Fixes an XSS issue with node names in the tomography graph.

* Updates built-in static web assets.

* Updates the change log.
2017-10-16 09:12:36 -07:00
James Phillips fdd08c78a9 Adds a brief wait and poll period to update check status after a timeout. (#3573)
* Adds a brief wait and poll period to update the check status
if we get stucking waiting for the processes to terminate.

Fixes #3570

* Jumps out of timeout case and includes script output.
2017-10-12 13:49:46 -07:00
James Phillips e9670761f9
Cleans up some drift between the OSS and Enterprise trees. 2017-10-11 15:53:07 -07:00
Kyle Havlovitz eea2bd2753 Kill check processes after the timeout is reached (#3567)
* Kill check processes after the timeout is reached

Kill the subprocess spawned by a script check once the timeout is reached. Previously Consul just marked the check critical and left the subprocess around.

Fixes #3565.

* Set err to non-nil when timeout occurs

* Fix check timeout test

* Kill entire process subtree on check timeout

* Add a docs note about windows subprocess termination
2017-10-11 11:57:39 -07:00
Frank Schroeder c4215bc04f
config: remove redundant code 2017-10-11 10:16:21 +02:00
Frank Schroeder 8cda75454a
config: fix check for segment.port <= 0 and add test 2017-10-11 10:15:55 +02:00
James Phillips a16dbc0212
Adds check to make sure port is given so we avoid a nil bind address. 2017-10-10 18:11:21 -07:00
James Phillips 275e83de08
Removes obsolete segment stub. 2017-10-10 17:21:32 -07:00
Frank Schröder 9b2e3c2091 agent: add option to discard health output (#3562)
* agent: add option to discard health output

In high volatile environments consul will have checks with "noisy"
output which changes every time even though the status does not change.
Since the output is stored in the raft log every health check update
unblocks a blocking call on health checks since the raft index has
changed even though the status of the health checks may not have changed
at all. By discarding the output of the health checks the users can
choose a different tradeoff. Less visibility on why a check failed in
exchange for a reduced change rate on the raft log.

* agent: discard output also when adding a check

* agent: add test for discard check output

* agent: update docs

* go vet

* Adds discard_check_output to reloadable config table.

* Updates the change log.
2017-10-10 17:04:52 -07:00
preetapan f6066f8305 Fixes agent error handling when check definition is invalid. Distingu… (#3560)
* Fixes agent error handling when check definition is invalid. Distinguishes between empty checks vs invalid checks

* Made CheckTypes return Checks from service definition struct rather than a new copy, and other changes from code review. This also errors when json payload contains empty structs

* Simplify and improve validate method, and make sure that CheckTypes always returns a new copy of validated check definitions

* Tweaks some small style things and error messages.

* Updates the change log.
2017-10-10 16:54:06 -07:00
Frank Schröder fa22ad4573 config: add generic method to translate between CamelCase and snake_case (#3557)
* doc: document discrepancy between id and CheckID

* doc: document enable_tag_override change

* config: add TranslateKeys helper

TranslateKeys makes it easier to map between different representations
of internal structures. It allows to recursively map alias keys to
canonical keys in structured maps.

* config: use TranslateKeys for config file

This also adds support for 'enabletagoverride' and removes
the need for a separate CheckID alias field.

* config: remove dead code

* agent: use TranslateKeys for FixupCheckType

* agent: translate enable_tag_override during service registration

* doc: add '.hcl' as valid extension

* config: map ScriptArgs to args

* config: add comment for TranslateKeys
2017-10-10 16:40:59 -07:00
James Phillips d1ad538345 Makes RPC handling more robust when rolling servers. (#3561)
* Adds client-side retry for no leader errors.

This paves over the case where the client was connected to the leader
when it loses leadership.

* Adds a configurable server RPC drain time and a fail-fast path for RPCs.

When a server leaves it gets removed from the Raft configuration, so it will
never know who the new leader server ends up being. Without this we'd be
doomed to wait out the RPC hold timeout and then fail. This makes things fail
a little quicker while a sever is draining, and since we added a client retry
AND since the server doing this has already shut down and left the Serf LAN,
clients should retry against some other server.

* Makes the RPC hold timeout configurable.

* Reorders struct members.

* Sets the RPC hold timeout default for test servers.

* Bumps the leave drain time up to 5 seconds.

* Robustifies retries with a simpler client-side RPC hold.

* Reverts untended delete.
2017-10-10 15:19:50 -07:00
Preetha Appan 25e64b5362 Fix unit test after dns library upgrade to account for correct data length 2017-10-06 17:40:17 -05:00
James Phillips a1db119d02 Fixes handling of stop channel and failed barrier attempts. (#3546)
* Fixes handling of stop channel and failed barrier attempts.

There were two issues here. First, we needed to not exit when there
was a timeout trying to write the barrier, because Raft might not
step down, so we'd be left as the leader but having run all the step
down actions.

Second, we didn't close over the stopCh correctly, so it was possible
to nil that out and have the leaderLoop never exit. We close over it
properly AND sequence the nil-ing of it AFTER the leaderLoop exits for
good measure, so the code is more robust.

Fixes #3545

* Cleans up based on code review feedback.

* Tweaks comments.

* Renames variables and removes comments.
2017-10-06 07:54:49 -07:00
Victor Boivie 77f7008363 Minor typo (boostrap) 2017-10-05 16:28:48 +02:00
James Phillips 97b580f593
Adds script warning and fixes Docker args recognition. 2017-10-04 21:41:27 -07:00
Kyle Havlovitz dde743700f Merge pull request #3535 from hashicorp/metric-docs
Update metric names and add a legacy config flag
2017-10-04 17:39:16 -07:00
Kyle Havlovitz d5fec6b7ac
Add a test for legacy metrics with a whitelist filter 2017-10-04 17:27:57 -07:00
Kyle Havlovitz be04bfed34 Clean up subprocess handling and make shell use optional (#3509)
* Clean up handling of subprocesses and make using a shell optional

* Update docs for subprocess changes

* Fix tests for new subprocess behavior

* More cleanup of subprocesses

* Minor adjustments and cleanup for subprocess logic

* Makes the watch handler reload test use the new path.

* Adds check tests for new args path, and updates existing tests to use new path.

* Adds support for script args in Docker checks.

* Fixes the sanitize unit test.

* Adds panic for unknown watch type, and reverts back to Run().

* Adds shell option back to consul lock command.

* Adds shell option back to consul exec command.

* Adds shell back into consul watch command.

* Refactors signal forwarding and makes Windows-friendly.

* Adds a clarifying comment.

* Changes error wording to a warning.

* Scopes signals to interrupt and kill.

This avoids us trying to send SIGCHILD to the dead process.

* Adds an error for shell=false for consul exec.

* Adds notes about the deprecated script and handler fields.

* De-nests an if statement.
2017-10-04 16:48:00 -07:00
Kyle Havlovitz 0063516e5e
Update metric names and add a legacy config flag 2017-10-04 16:43:27 -07:00
Frank Schröder b2c4dc4360 Provide stable config for agent/self (#3532)
* config: provide stable config for /v1/agent/self (#3530)

This patch adds a stable subset of the previous Config struct to the
agent/self response. The actual runtime configuration is moved into
DebugConfig and will be documented to change.

Fixes #3530

* config: fix tests

* doc: update api documentation for /v1/agent/self
2017-10-04 10:43:17 -07:00
James Phillips 6529c505a5 Merge pull request #3531 from hashicorp/pr-3521-slackpad
ui: Use monospace font for textarea controls.
2017-10-04 09:53:41 -07:00
James Phillips 539285cf1f
Updates checked in web assets to pick up CSS change.
Closes #3521
2017-10-04 09:52:15 -07:00
Preetha Appan f38d20eb40 Remove extra newline 2017-10-03 15:19:31 -05:00
Preetha Appan 3c81e2db7c Only allow 'list' policies within 'key' policy definitions. Consolidated two similar tests into one and fixed alignment. 2017-10-03 15:15:56 -05:00
Preetha Appan d5acfc3982 Introduces new 'list' permission that applies to KV store recursive reads, and enforced only when opted in. 2017-10-02 17:10:21 -05:00
Frank Schroeder 6b3a957c5e use ports from derived addresses 2017-09-29 20:26:43 +02:00
Frank Schroeder 8d8e2523eb config: drop advertise_addrs
Fixes #3516
2017-09-29 20:26:43 +02:00
Frank Schroeder f0efe2a3de
Fix tests after config refactor 2017-09-28 12:32:46 +02:00
Patrick Sodré 55c2746963
Implement encodeKVasRFC1464 function 2017-09-28 12:32:46 +02:00
Patrick Sodré d880634cfa
Add RFC1464 tests 2017-09-28 12:32:45 +02:00
Patrick Sodré 7083f9fb14
Turn encodeKVasRFC1464 into a plain function 2017-09-28 12:32:45 +02:00
Patrick Sodré be258a3315
Use verify for NodeLookup CNAME, and TXT tests 2017-09-28 12:32:45 +02:00
Patrick Sodré 8982719f5b
Refactor formatTxtRecords as encodeKVasRFC1464
- Move the logic of rfc1035 out of the encoding function
  - Left basic version of encodingKV as 'k=v'
2017-09-28 12:32:45 +02:00
Patrick Sodré a16e0f7419
Fix editorial suggestions 2017-09-28 12:32:45 +02:00
Patrick Sodré 4b2d1546fa
Remove redundant check of Node.Meta size 2017-09-28 12:32:45 +02:00
Patrick Sodré b8369b54fb
Return Node.Meta info using the DNS interface 2017-09-28 12:32:45 +02:00