Commit Graph

43 Commits

Author SHA1 Message Date
James Phillips 28f8aa5559
Removes remoteConsuls in favor of the new router.
This has the next wave of RTT integration with the router and also
factors some common RTT-related helpers out to lib. While we were
in here we also got rid of the coordinate disable config so we don't
need to deal with the complexity in the router (there was never a
user-visible way to disable coordinates).
2017-03-16 16:42:19 -07:00
James Phillips 8fcf695fa1
Pass state store pointer into the blocking query work function.
Previously the blocking functions all closed over the state store from
their first query, with would not have worked properly when a restore
occurred. This makes sure they get a frest state store pointer each time,
and that pointer is synchronized with the abandon watch.
2017-01-25 09:58:23 -08:00
James Phillips 997934c94f
Adds fine-grained watches to prepared query endpoints. 2017-01-25 09:58:22 -08:00
James Phillips 635afd1924
Adds fine-grained watches to health endpoints. 2017-01-25 09:58:22 -08:00
Kyle Havlovitz 3cd054e81f
Add tests for node meta in prepared queries and update docs 2017-01-23 19:17:30 -05:00
Kyle Havlovitz fdf2a10835
First pass at adding node meta filter to prepared queries 2017-01-18 16:23:33 -05:00
James Phillips 99a5ae2737
Bans anonymous queries that aren't tied to a session.
This gets us coverage of PQ creation under the existing service
policy or the soon-to-be-added session policy.
2016-12-12 14:52:27 -08:00
Ryan Uber 577523fc73 consul: sort source node first if at position <= 10 in PQ's 2016-07-01 14:28:58 -07:00
Ryan Uber ebacaa2d67 consul: send agent source data as separate query source 2016-06-30 16:51:18 -07:00
Ryan Uber 782a081925 consul: use source parameter for near prepared queries 2016-06-30 12:11:20 -07:00
Ryan Uber 270270a33a consul: send origin node + dc when executing prepared queries 2016-06-21 15:34:26 -07:00
Ryan Uber 114e57fff1 consul: use the Near field instead of PreferLocal 2016-06-21 12:39:40 -07:00
Ryan Uber 1fef85cd2e consul: support PreferLocal in PQ's 2016-06-20 14:24:40 -07:00
James Phillips 275c84a0cc Renames "debug" endpoint and structures to "explain". 2016-03-07 10:45:39 -08:00
James Phillips 8493640b09 Adds a prepared query debug endpoint. 2016-03-07 10:45:39 -08:00
James Phillips 2a9a5f823e Factors rendering down into the resolve function. 2016-03-07 10:45:39 -08:00
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 f0150ff5ce Adds missing token redact in the GET path. 2016-02-26 15:59:00 -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 3b91618d7d Changes to more idiomatic "ok" pattern for prefix getter. 2016-02-24 16:26:43 -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
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 533c79bd2b Cleans up some small `go vet` findings. 2015-12-18 22:14:48 -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 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
James Phillips 7762a828d3 Adds query metadata to prepared query execute response. 2015-11-15 17:06:00 -08:00
James Phillips 124410b66c Adds an HTTP endpoint for prepared queries. 2015-11-15 17:06:00 -08:00
James Phillips 4051db4e88 Changes Lookup to Get since we don't need it (only Execute does). 2015-11-15 17:06:00 -08:00
James Phillips 095806584d Always increments the failovers counter, even for error-ed DCs. 2015-11-15 17:06:00 -08:00
James Phillips 07361d3e96 Adds test for remote datacenter selection and query logic. 2015-11-15 17:06:00 -08:00
James Phillips 9428f025f9 Adds tag filter tests. 2015-11-15 17:06:00 -08:00
James Phillips 7c8404df4c Adds status information about failovers to query results. 2015-11-15 17:06:00 -08:00
James Phillips bb0f136412 Adds tests for query lookup and list endpoints. 2015-11-15 17:06:00 -08:00
James Phillips 76a55eed53 Completes non-ACL version of apply test. 2015-11-15 17:06:00 -08:00
James Phillips bc0fba43d8 Adds lookup and list endpoints and basic end-to-end apply test. 2015-11-15 17:06:00 -08:00
James Phillips 61e6cbc560 Skips unknown DCs during queries and chugs along in the face of errors. 2015-11-15 17:06:00 -08:00
James Phillips 0141438e6c Moves sort to a query-time decision and adds back the limit. 2015-11-15 17:06:00 -08:00
James Phillips 25fac70924 Adds an explicit ACL check that will fail vs. trying other DCs. 2015-11-15 17:06:00 -08:00
James Phillips 347bb847c2 Changes "not" prefix from "~" to "!". 2015-11-15 17:06:00 -08:00
James Phillips 09034a84bd Adds prefix "prepared" to everything prepared query-related. 2015-11-15 17:06:00 -08:00
Renamed from consul/query_endpoint.go (Browse further)