Commit Graph

878 Commits

Author SHA1 Message Date
James Phillips fa60d575bf Integrates templates into state store and endpoint (sans tests). 2016-03-07 10:45:39 -08:00
James Phillips 62405110dc Wraps the prepared query to also store the compiled template. 2016-03-07 10:45:39 -08:00
James Phillips 98281be7df Adds basic query template compiler and renderer. 2016-03-07 10:45:39 -08:00
Mike Cowgill 25613895e3 one line schema change to not allow missing for sessions Table node index, Fixes #1774 2016-03-02 21:19:53 -08:00
James Phillips f0150ff5ce Adds missing token redact in the GET path. 2016-02-26 15:59:00 -08:00
James Phillips 48f2089d7f Merge pull request #1757 from hashicorp/f-revert-1667
Reverts server connection rebalancing changes from #1667
2016-02-24 18:07:13 -08:00
James Phillips c75256ac8b Adds a check for users re-submitting the redacted token. 2016-02-24 17:35:26 -08:00
James Phillips 2f7eac8b86 Renames "prepared_query" ACL policy to "query". 2016-02-24 17:02:06 -08:00
James Phillips 3b91618d7d Changes to more idiomatic "ok" pattern for prefix getter. 2016-02-24 16:26:43 -08:00
James Phillips 1c7ee582f9 Renames a unit test. 2016-02-24 16:17:20 -08:00
James Phillips d660311fbb Revert "Merge pull request #1667 from hashicorp/b-redistribute-clients"
This reverts commit 8f30dea4209491ebbe4ef9ab94dd8052d17bdbe9, reversing
changes made to eb27a02956e7e052c0bec6f96a0c0f7f6675f6a6.
2016-02-24 15:38:03 -08:00
James Phillips 54f0b7bbb6 Completes switch of prepared_query ACLs to govern query names. 2016-02-24 01:26:16 -08:00
James Phillips 633c231d67 Creates new "prepared-query" ACL type and new token capture behavior.
Prior to this change, prepared queries had the following behavior for
ACLs, which will need to change to support templates:

1. A management token, or a token with read access to the service being
   queried needed to be provided in order to create a prepared query.

2. The token used to create the prepared query was stored with the query
   in the state store and used to execute the query.

3. A management token, or the token used to create the query needed to be
   supplied to perform and CRUD operations on an existing prepared query.

This was pretty subtle and complicated behavior, and won't work for
templates since the service name is computed at execution time. To solve
this, we introduce a new "prepared-query" ACL type, where the prefix
applies to the query name for static prepared query types and to the
prefix for template prepared query types.

With this change, the new behavior is:

1. A management token, or a token with "prepared-query" write access to
   the query name or (soon) the given template prefix is required to do
   any CRUD operations on a prepared query, or to list prepared queries
   (the list is filtered by this ACL).

2. You will no longer need a management token to list prepared queries,
   but you will only be able to see prepared queries that you have access
   to (you get an empty list instead of permission denied).

3. When listing or getting a query, because it was easy to capture
   management tokens given the past behavior, this will always blank out
   the "Token" field (replacing the contents as <hidden>) for all tokens
   unless a management token is supplied. Going forward, we should
   discourage people from binding tokens for execution unless strictly
   necessary.

4. No token will be captured by default when a prepared query is created.
   If the user wishes to supply an execution token then can pass it in via
   the "Token" field in the prepared query definition. Otherwise, this
   field will default to empty.

5. At execution time, we will use the captured token if it exists with the
   prepared query definition, otherwise we will use the token that's passed
   in with the request, just like we do for other RPCs (or you can use the
   agent's configured token for DNS).

6. Prepared queries with no name (accessible only by ID) will not require
   ACLs to create or modify (execution time will depend on the service ACL
   configuration). Our argument here is that these are designed to be
   ephemeral and the IDs are as good as an ACL. Management tokens will be
   able to list all of these.

These changes enable templates, but also enable delegation of authority to
manage the prepared query namespace.
2016-02-23 17:12:43 -08:00
James Phillips f398e1880e Adds a test for node registration and tagged addresses. 2016-02-07 13:15:22 -08:00
James Phillips f163522f0c Moves tagged wan address to be managed by anti-entropy, not serf. 2016-02-07 13:12:42 -08:00
James Phillips 3f50d2ae7e Adds an FSM persist and restore test for tagged addresses. 2016-02-07 11:36:39 -08:00
James Phillips 79bd1fd4bb Sets up config for more address tags down the road, renames struct members. 2016-02-07 10:37:34 -08:00
Evan Gilman 71cf39b5f8 Use a map for additional node addresses 2016-02-06 23:01:45 -08:00
Evan Gilman e166d2a4c7 Use idiomatic name for wan_addr serf tag 2016-02-06 23:01:45 -08:00
James Phillips 1a828e3927 Store WanAddress during Service/Check sync 2016-02-06 23:01:45 -08:00
Evan Gilman fc61143b46 Store WanAddress during node registration 2016-02-06 23:01:45 -08:00
Evan Gilman 369e501dd5 Store WanAddress on Node 2016-02-06 23:01:45 -08:00
Sean Chittenden fc82b351b8 Use the server's address in debug logging, not the c.lastServer, which may be nil 2016-02-02 15:51:28 -08:00
Sean Chittenden 58225e0ee3 Remove unnecessary check, test was moved further up in scope 2016-02-02 11:13:58 -08:00
Sean Chittenden 6452b498e1 Use panic instead of returning a sentinel UUID values in unit tests 2016-02-01 23:15:19 -08:00
Sean Chittenden ef8bbca48f Continually rebalance client connections
Introduce a low-level background connection expiration mechanism wherein connections will be recycled periodically based on the size and health of the cluster.

For the vast majority of consul users, this will mean an average connection age of 150s.  For 10K node clusters it will take ~3min for clusters to rebalance their connections.  In the pathological case for a 100K cluster where 99K clients are in the minority talking to 1x server it will take ~26min to rebalance all connections.

It's possibe for clients recovering from a parititon to become fixated on a single server until the server or agent is restarted.  This is of particular interest to long-running environments with stable agents, where `allow_stale` is true, and partitions occur periodically.
2016-01-30 17:13:50 -08:00
Sean Chittenden 8a37e76cb0 Use rand.Int31n() vs unconditionally using modulus 2016-01-30 15:47:58 -08:00
Sean Chittenden 727bb42b1d Merge branch 'f-consul-lib' of ssh://github.com/hashicorp/consul into b-redistribute-clients 2016-01-30 15:40:54 -08:00
Sean Chittenden b216d4c11f Rename clientRPCCache to clientRPCConnMaxIdle, change value
Increase the max idle time for agents talking to servers from 30s to 127s in order to allow for the reuse of connections that are being initiated by cron.

127s was chosen as the first prime above 120s (arbitrarily chose to use a prime) with the intent of reusing connections who are used by once-a-minute cron(8) jobs *and* who use a 60s jitter window (e.g. in vixie cron job execution can drift by up to 59s per job, or 119s for a once-a-minute cron job).
2016-01-30 15:27:46 -08:00
Sean Chittenden e83a5b7a70 Reuse the results from gettimeofday(2)...
Inside of a single RPC call, reuse time.Now().
2016-01-30 14:39:17 -08:00
Sean Chittenden c470553b6b Factor out duplicate functions into a lib package
Consolidate code duplication and tests into a single lib package.  Most of these functions were from various **/util.go functions that couldn't be imported due to cyclic imports.  The consul/lib package is intended to be a terminal node in an import DAG and a place to stash various consul-only helper functions.  Pulled in hashicorp/go-uuid instead of consolidating UUID access.
2016-01-29 16:57:45 -08:00
James Phillips 0010b788ed Prevents watches from being orphaned when KVS blocking queries loop. 2016-01-20 07:18:47 -08:00
James Phillips e0ae4878f6 Merge pull request #948 from hashicorp/iface-down-fix
Don't try to bind on address from inactive interface
2016-01-14 17:00:54 -08:00
Ryan Uber e3ac96679e consul: address comments 2016-01-05 09:45:36 -08:00
Ryan Uber 689698eefa consul: disable serf snapshots in dev mode 2015-12-26 20:39:49 -05:00
Ryan Uber ce4cf8a542 consul: dev mode works 2015-12-26 20:19:36 -05:00
James Phillips 533c79bd2b Cleans up some small `go vet` findings. 2015-12-18 22:14:48 -08:00
James Phillips 92531812b6 Adds source address logging on RPC errors. 2015-12-16 14:03:03 -08:00
James Phillips 38bdcc9907 Adds a check to make sure query names can't be registered twice. 2015-12-02 09:04:51 -08:00
Armon Dadgar a033d7aed2 consul: shrink yamux recv buffer on idle streams 2015-11-27 17:20:57 -08:00
James Phillips 0e3f4af4ac Makes all the query ops the correct type. 2015-11-17 09:27:10 -08:00
James Phillips 86bc3db7b3 Returns a zero index for a lookup error case. 2015-11-17 09:25:20 -08:00
James Phillips bc60491890 Removes a useless empty import and fixes some stale comments. 2015-11-17 08:29:20 -08:00
James Phillips f4943c1613 Makes UUID regex case-insensitive. 2015-11-16 22:57:47 -08:00
James Phillips a1e02996e5 Moves conversion of nil slices up to HTTP layer for prepared queries. 2015-11-15 17:06:00 -08:00
James Phillips c032dee945 Adds a paranoia set of the nodes slice to nil. 2015-11-15 17:06:00 -08:00
James Phillips a0211db3b9 Adds a test to ensure we don't return a nil slice. 2015-11-15 17:06:00 -08:00
James Phillips 375312f07a Gets rid of some unused constants. 2015-11-15 17:06:00 -08:00
James Phillips e6ccf5b9ed Returns a 404 from a get or execute of a nonexistent query. 2015-11-15 17:06:00 -08:00
James Phillips c9ef552385 Plumbs the service name back and uses agent-specific TTL settings as a fallback. 2015-11-15 17:06:00 -08:00