Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consul prepared queries #1389

Merged
merged 55 commits into from
Nov 17, 2015
Merged

Consul prepared queries #1389

merged 55 commits into from
Nov 17, 2015

Conversation

slackpad
Copy link
Contributor

@slackpad slackpad commented Nov 7, 2015

This isn't quite ready for a full review but I thought I'd post it so you guys can take a quick look to see where it's going. Here's a todo list:

  • Create unit tests for query_endpoint and test/iterate
  • Create a new HTTP endpoint with unit tests
  • Finish up FSM snapshot/restore for prepared queries
  • Add a few small unit tests marked as todos in the code (fsm, etc.)
  • Integrate with DNS and add unit tests
  • Resolve some small DNS TODOs
  • Add 404 return codes to HTTP endpoints for missing queries
  • Add Go API client support
  • Write docs

Most of these should be pretty quick once the first item is checked off. I'm going to rebase the last commit on there / force push, though the state store changes and the other commits up to the WIP one should be complete.

@slackpad
Copy link
Contributor Author

We decided query-specific TTLs aren't needed since we have session integration, so took that off for now.

if err := structs.Decode(buf, &req); err != nil {
panic(fmt.Errorf("failed to decode request: %v", err))
}
defer metrics.MeasureSince([]string{"consul", "fsm", "query", string(req.Op)}, time.Now())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change "query" to "prepared-query" to avoid confusion?

@slackpad slackpad force-pushed the f-prepared-queries branch 7 times, most recently from f90cc4e to 4a15584 Compare November 14, 2015 18:28
@slackpad
Copy link
Contributor Author

There's a TODO in there about using the new limit capability. It didn't pan out like I'd hoped because I forgot about the de-duping we do down in the DNS server. We could de-dup up in the query, or we could just set the limit to something "pretty large" for UDP-based queries which should work ok in practice (gives a reasonable cut of nodes to de-dup if you've got thousands of nodes to choose from). Right now I just don't set the limit so that it's equivalent to what we had before.

@slackpad slackpad added this to the 0.6.0 milestone Nov 16, 2015
@armon
Copy link
Member

armon commented Nov 17, 2015

Why did the Sort parameter get removed from the Query?

@slackpad
Copy link
Contributor Author

@armon For the Sort option, with the failover options also using RTT it seemed too confusing/crazy UX-wise. I plumbed it as a Source parameter to the endpoint so it works like all the others with a ?near= argument over HTTP (like all the other coordinate-aware endpoints), but his does preclude it over DNS since there's no way to activate that. It's an advanced feature that's possible to use if you are building on the HTTP API, but not part of the DNS response anymore.

It seems very tricky to use via DNS properly (no load balancing and the agent you are sorting based on can be unclear if you are proxying Consul's DNS, recursing, etc.) so WAN-only use of RTT seemed like the clear winner and less of a foot shooter. I'm definitely open to adding it back in the query definition if you think it's useful for DNS as well. It would be a minor change, might even be doable as an agent option. It might even be clearer as an agent option so it can be explained as "if I serve a prepared query, sort the results relative to me".

@@ -0,0 +1,175 @@
package api

import ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this since it is empty

@ryanuber
Copy link
Member

@slackpad looking good, I left some minor feedback and questions throughout.

@slackpad
Copy link
Contributor Author

Alright - I've addressed all the comments. Lemme know if you guys have any more concerns before I merge.

slackpad added a commit that referenced this pull request Nov 17, 2015
@slackpad slackpad merged commit fed1458 into master Nov 17, 2015
@slackpad slackpad deleted the f-prepared-queries branch November 17, 2015 19:36
@armon
Copy link
Member

armon commented Nov 17, 2015

🚀 🚀 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants