Commit Graph

412 Commits

Author SHA1 Message Date
Eliza Weisman 5a3b1cdb3a proxy: Add TLS label in `transparency::retry_reconnect_errors` test (#1258) 2018-07-03 12:27:08 -07:00
Oliver Gould 866167a955 tap: Support `tls` labeling (#1244)
The proxy's metrics are instrumented with a `tls` label that describes
the state of TLS for each connection and associated messges.

This same level of detail is useful to get in `tap` output as well.

This change updates Tap in the following ways:
* `TapEvent` protobuf updated:
  * Added `source_meta` field including source labels
  * `proxy_direction` enum indicates which proxy server was used.
* The proxy adds a `tls` label to both source and destination meta indicating the state of each peer's connection
* The CLI uses the `proxy_direction` field to determine which `tls` label should be rendered.
2018-07-02 17:19:20 -07:00
Oliver Gould 051a7639c5 proxy: Always inlcude `tls` label in metrics (#1243)
The `tls` label could sometimes be formatted incorrectly, without a
preceding comma.

To fix this, the `TlsStatus` type no longer formats commas so that they
must be provided in the context in which they are used (as is done
otherwise in this file).
2018-07-02 16:21:06 -07:00
Eliza Weisman 91108a2d53 proxy: Fall back to plaintext communication when a TLS handshake fails (#1173)
This branch modifies the proxy's logic for opening a connection so
that when an attempted TLS handshake fails, the proxy will retry that
connection without TLS.

This is implemented by changing the `UpgradeToTls` case in the `Future`
implementation for `Connecting`, so that rather than simply wrapping
a poll to the TLS upgrade future with `try_ready!` (and thus failing
the future if the upgrade future fails), we reset the state of the
future to the `Plaintext` state and continue looping. The `tls_status`
field of the future is changed to `ReasonForNoTls::HandshakeFailed`,
and the `Plaintext` state is changed so that if its `tls_status` is
`HandshakeFailed`, it will no longer attempt to upgrade to TLS when the
plaintext connection is successfully established.

Closes #1084 

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-29 17:08:03 -07:00
Brian Smith da61aace6c Proxy: Skip TLS for control plane loopback connections. (#1229)
If the controller address has a loopback host then don't use TLS to connect
to it. TLS isn't needed for security in that case. In mormal configurations
the proxy isn't terminating TLS for loopback connections anyway.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-28 17:24:09 -10:00
Brian Smith 03814c18eb Proxy: Get identity of pod & controller from configuration. (#1221)
Instead of attempting to construct identities itself, have the proxy
accept fully-formed identities from whatever configures it. This allows
us to centralize the formatting of the identity strings in the Go code
that is shared between the `conduit inject`, `conduit install`, and CA
components.

One wrinkle: The pod namespace isn't necessarily available at
`conduit inject` time, so the proxy must implement a simple variable
substitution mechanism to insert the pod namespace into its identity.

This has the side-effect of enabling TLS to the controller since the
controller's identity is now available.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-27 17:17:34 -10:00
Brian Smith c67546653a Proxy: Use new destination service TLS identity scheme. (#1222)
Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-27 14:47:57 -10:00
Eliza Weisman af7b56f963 proxy: Replace >=100,000 ms latency buckets with 1, 2, 3, 4, and 5 ms (#1218)
This branch adds buckets for latencies below 10 ms to the proxy's latency
histograms, and removes the buckets for 100, 200, 300, 400, and 500 
seconds, so the largest non-infinity bucket is 50,000 ms. It also removes
comments that claimed that these buckets were the same as those created
by the control plane, as this is no longer true (the metrics are now scraped
by Prometheus from the proxy directly).

Closes #1208

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-27 16:53:42 -07:00
Kevin Lingerfelt 26d2bce656 Update dest service with a different tls identity strategy (#1215)
* Update dest service with a different tls identity strategy
* Send controller namespace as separate field

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-27 11:40:02 -07:00
Eliza Weisman 0cf3a231a2 proxy: Fix ConditionallyUpgradeServerToTls not being notified (#1209)
#1203 introduced a bug in the implementation of `Future` for 
`connection::ConditionallyUpgradeServerToTls`. If the attempt to match
the current peek buffer was incomplete, the `Future` implementation
would return `Ok(Async::NotReady)`. This results in the task yielding.
However, in this case the task would not be notified again, as the 
`NotReady` state wasn't from an underlying IO resource. Instead, the
would _never_ be ready.

This branch fixes this issue by simply continuing the loop, so that 
we instead try to read more bytes from the socket and try to match
again, until the match is successful or the _socket_ returns `NotReady`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-26 16:55:55 -07:00
Sean McArthur ead3495d4a proxy: enable HTTP CONNECT request support (#1200)
When the proxy receives a `CONNECT` request, the HTTP Upgrade pieces
are used since a CONNECT is very similar to an Upgrade. If the CONNECT
response back from the proxied client request is successful, the
connection is converted into a TCP proxy, just like with Upgrades.
2018-06-26 16:45:06 -07:00
Eliza Weisman ae8b7d7391 proxy: Fix false positives in polling-based fs watches (#1140)
There are currently two issues which can lead to false positives (changes being
reported when files have not actually changed) in the polling-based filesystem
watch implementation. 

The first issue is that when checking each watched file for changes, the loop
iterating over each path currently short-circuits as soon as it detects a 
change. This means that if two or more files have changed, the first time we
poll the fs, we will see the first change, then if we poll again, we will see
the next change, and so on. 

This branch fixes that issue by always hashing all the watched files, even if a
change has already been detected. This way, if all the files change between one
poll and the next, we no longer generate additional change events until a file
actually changes again.

The other issue is that the old implementation would treat any instance of a 
"file not found" error as indicating that the file had been deleted, and 
generate a change event. This leads to changes repeatedly being detected as
long as a file does not exist, rather than a single time when the file's 
existence state actually changes.

This branch fixes that issue as well, by only generating change events on
"file not found" errors if the file existed the last time it was polled. 
Otherwise, if a file did not previously exist, we no longer generate a new 
event.

I've verified both of these fixes through manual testing, as well as a new
test for the second issue. The new test fails on master but passes on this
branch.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-26 15:56:21 -07:00
Brian Smith 72761d4552 Proxy: Allow non-Conduit-bound TLS and non-TLS through. (#1203)
On the server (accept) side of TLS, if the traffic isn't targetting the
proxy (as determined by the TLS ClientHello SNI), or if the traffic
isn't TLS, then pass it through.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-26 10:16:00 -10:00
Brian Smith ba3b40f546 Proxy: Add `transport::prefixed::Prefixed`. (#1196)
Copy most of the implementation of `connection::Connection` to create
a way to prefix a `TcpStream` with some previously-read bytes. This
will allow us to read and parse a TLS ClientHello message to see if it
is intended for the proxy to process, and then "rewind" and feed it
back into the TLS implementation if so.

This must be in the `transport` submodule in order for it to implement
the private `Io` trait.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-25 12:12:53 -10:00
Brian Smith 04007755f6 Proxy: Add parser to distinguish proxy TLS traffic from other traffic. (#1197)
* Proxy: Add parser to distinguish proxy TLS traffic from other traffic.

Distinguish incoming TLS traffic intended for the proxy to terminate
from TLS traffic intended for the proxied service to terminate and from
non-TLS traffic.

The new version of `untrusted` is required for this to work.

Signed-off-by: Brian Smith <brian@briansmith.org>

* More tests

Signed-off-by: Brian Smith <brian@briansmith.org>

* Stop abusing `futures::Async`.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-25 12:12:25 -10:00
Eliza Weisman 42dd8b86a4 proxy: Remove TLS client config from Process context (#1201)
As the TLS client config watch stored in `ctx::Process` is used only in
`Bind`, it's not necessary for it to be part of the process context.
Instead, it can be explicitly passed into `Bind`.

The resultant code is simpler, and resolves a potential cyclic 
dependency caused when adding `Sensors` to the watch (see 
https://github.com/runconduit/conduit/pull/1141#issuecomment-400082357).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-25 15:12:03 -07:00
Eliza Weisman a8e54fbd7d proxy: Rebind controller client on TLS configuration changes (#1192)
This branch adds the rebinding logic added to outbound clients in #1185
to the controller client used in the proxy's `control::destination::background`
module. Now, if we are communicating with the control plane over TLS, we will
rebind the controller client stack if the TLS client configuration changes, 
using the `WatchService` added in  #1177.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Brian Smith <brian@briansmith.org>
Co-authored-by: Brian Smith <brian@briansmith.org>
2018-06-25 12:44:51 -07:00
Oliver Gould 7f84c66474 proxy: Move contrul utils into module (#1198)
control/mod.rs contains a variety of miscelaneous utilities. In
preparation of adding other types into the root of `control`, this
change creates a `control::util` module that holds them.
2018-06-25 11:05:48 -07:00
Brian Smith 6e793f3ef4 Refactor TLS configuration tests. (#1194)
Rearrange the TLS configuration loading tests to enable them to be
extended outside the tls::config submodule.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-24 21:45:56 -10:00
Brian Smith e0a9d9cba9 Report disabled TLS as "disabled" not "no_config". (#1190)
This fixes a regression introduced in PR #1187.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-22 21:48:24 -10:00
Brian Smith 7f7bc1edb8 Proxy: use `Conditional` inside TLS configuration watches. (#1187)
Simplify the code and make it easier to report finer-grained
reasoning about what part(s) of the TLS configuration are
missing.

This is based on Eliza's PR #1186.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-21 17:59:41 -10:00
Eliza Weisman 684c4d6d6d proxy: Add process stats to proxy metrics (on Linux) (#1128)
This branch adds process stats to the proxy's metrics, as described in
https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics.

In particular, it adds metrics for the process's total CPU time, number of 
open file descriptors and max file descriptors, virtual memory size, and 
resident set size.

This branch adds a dependency on the `procinfo` crate. Since this crate and the
syscalls it wraps are Linux-specific, these stats are only reported on Linux.
On other operating systems, they aren't reported.

Manual testing

Metrics scrape:
```
eliza@ares:~$ curl http://localhost:4191/metrics
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 19
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1024
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 45252608
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 12132352
# HELP process_start_time_seconds Time that the process started (in seconds since the UNIX epoch)
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1529017536
```
Note that the `process_cpu_seconds_total` stat is 0 because I just launched this conduit instance and it's not seeing any load; it does go up after i sent a few requests to it.

Confirm RSS & virtual memory stats w/ `ps`, and get Conduit's pid so we can check the fd stats
(note that `ps` reports virt/rss in kb while Conduit's metrics reports them in bytes):
```
eliza@ares:~$ ps aux | grep conduit | grep -v grep
eliza    16766  0.0  0.0  44192 12956 pts/2    Sl+  16:05   0:00 target/debug/conduit-proxy
```

Count conduit process's open fds:
```
eliza@ares:~$ cd /proc/16766/fd
eliza@ares:/proc/16766/fd$ ls -l | wc -l
18
```

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-21 17:50:10 -07:00
Eliza Weisman 1c5524ff21 proxy: Rebind endpoint stacks on TLS config changes using WatchService (#1185)
This branch changes the proxy's `Bind` module to add a middleware layer 
which watches for TLS cliend configuration changes and rebinds the 
endpoint stacks of any endpoints with which it is able to communicate with over 
TLS (i.e. those with `TlsIdentity` metadata) when the client config changes. The 
rebinding is done at the level of individual endpoint stacks, rather than for the
entire service stack for the destination.

This obsoletes my previous PRs #1169 and #1175.

Closes #1161

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-21 17:49:19 -07:00
Oliver Gould 432695a77d proxy: Implement a WatchService (#1177)
WatchService is a middleware that rebinds its inner service
each time a Watch updates.

This is planned to be used to rebind endpoint stacks when TLS
configuration changes. Later, it should probably be moved into
the tower repo.
2018-06-21 15:41:41 -07:00
Oliver Gould c0fd7a9577 proxy: Document tls::config::watch_for_config_changes (#1176)
While investigating TLS configuration, I found myself wanting a
docstring on `tls::config::watch_for_config_changes`.

This has one minor change in functionality: now, `future::empty()`
is returned instead of `future:ok(())` so that the task never completes.
It seems that, ultimately, we'll want to treat it as an error if we lose
the ability to receive configuration updates.
2018-06-21 11:05:03 -07:00
Brian Smith 71ea2c1b59 Proxy: Implement TLS conditional accept more like TLS conditional connect. (#1166)
* Proxy: Implement TLS conditional accept more like TLS conditional connect.

Clean up the accept side of the TLS configuration logic.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-20 19:46:31 -10:00
Sean McArthur 757ccd8fc9 proxy: add HTTP/1.1 Upgrade support automatically (#1126)
Any HTTP/1.1 requests seen by the proxy will automatically set up
to prepare such that if the proxied responses agree to an upgrade,
the two connections will converted into a standard TCP proxy duplex.

Implementation
-----------------

This adds a new type, `transparency::Http11Upgrade`, which is a sort of rendezvous type for triggering HTTP/1.1 upgrades. In the h1 server service, if a request looks like an upgrade (`h1::wants_upgrade`), the request body is decorated with this new `Http11Upgrade` type. It is actually a pair, and so the second half is put into the request extensions, so that the h1 client service may look for it right before serialization. If it finds the half in the extensions, it decorates the *response* body with that half (if it looks like a response upgrade (`h1::is_upgrade`)).

The `HttpBody` type now has a `Drop` impl, which will look to see if its been decorated with an `Http11Upgrade` half. If so, it will check for hyper's new `Body::on_upgrade()` future, and insert that into the half. 

When both `Http11Upgrade` halves are dropped, its internal `Drop` will look to if both halves have supplied an upgrade. If so, the two `OnUpgrade` futures from hyper are joined on, and when they succeed, a `transparency::tcp::duplex()` future is created. This chain is spawned into the default executor.

The `drain::Watch` signal is carried along, to ensure upgraded connections still count towards active connections when the proxy wants to shutdown.

Closes #195
2018-06-20 16:41:43 -07:00
Sean McArthur 016d748653 proxy: re-enabled vectored writes through our dynamic Io trait object. (#1167)
This adds `Io::write_buf_erased` that doesn't required `Self: Sized`, so
it can be called on trait objects. By using this method, specialized
methods of `TcpStream` (and others) can use their `write_buf` to do
vectored writes.

Since it can be easy to forget to call `Io::write_buf_erased` instead of
`Io::write_buf`, the concept of making a `Box<Io>` has been made
private. A new type, `BoxedIo`, implements all the super traits of `Io`,
while making the `Io` trait private to the `transport` module. Anything
hoping to use a `Box<Io>` can use a `BoxedIo` instead, and know that
the write buf erase dance is taken care of.

Adds a test to `transport::io` checking that the dance we've done does
indeed call the underlying specialized `write_buf` method.

Closes #1162
2018-06-20 16:31:48 -07:00
Brian Smith 983faeb779 Proxy: More carefully keep track of the reason TLS isn't used. (#1164)
* Proxy: More carefully keep track of the reason TLS isn't used.

There is only one case where we dynamically don't know whether we'll
have an identity to construct a TLS connection configuration. Refactor
the code with that in mind, better documenting all the reasons why an
identity isn't available.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-20 07:40:49 -10:00
Brian Smith f22d39c280 Proxy: Add TLS client infrastructure. (#1158)
Move TLS cipher suite configuration to tls::config.

Use the same configuration to act as a client and a server.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-19 14:26:42 -10:00
Oliver Gould 902b7efac1 proxy: Clarify Outbound::recognize (#1144)
The comments in Outbound::recognize had become somewhat stale as the
logic changed. Furthermore, this implementation may be easier to
understand if broken into smaller pieces.

This change reorganizes the Outbound:recognize method into helper
methods--`destination`, `host_port`, and `normalize`--each with
accompanying docstrings that more accurately reflect the current
implementation.

This also has the side-effect benefit of eliminating a string clone on
every request.
2018-06-19 14:01:27 -07:00
Eliza Weisman 10f327ebc0 proxy: Add `tls="true"` metric label to connections accepted with TLS (#1050)
Depends on #1047.

This PR adds a `tls="true"` label to metrics produced by TLS connections and
requests/responses on those connections, and a `tls="no_config"` label on 
connections where TLS was enabled but the proxy has not been able to load
a valid TLS configuration.

Currently, these labels are only set on accepted connections, as we are not yet
opening encrypted connections, but I wired through the `tls_status` field on 
the `Client` transport context as well, so when we start opening client 
connections with TLS, the label will be applied to their metrics as well.

Closes #1046

Signed-off-by: Eliza Weisman <eliza@buoyanbt.io>
2018-06-19 12:30:11 -07:00
Brian Smith 2750ddb77f Proxy: Make TLS server aware of its own identity. (#1148)
* Proxy: Make TLS server aware of its own identity.

When validating the TLS configuration, make sure the certificate is
valid for the current pod. Make the pod's identity available at that
point in time so it can do so. Since the identity is available now,
simplify the validation of our own certificate by using Rustls's API
instead of dropping down to the lower-level webpli API.

This is a step towards the server differentiating between TLS
handshakes it is supposed to terminate vs. TLS handshakes it is
supposed to pass through.

This is also a step toward the client side (connect) of TLS, which will
reuse much of the configuration logic.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-18 12:53:10 -10:00
Oliver Gould 9c55d40081 proxy: Upgrade h2 to 0.1.10 (#1149)
This picks up a fix for https://github.com/carllerche/h2/pull/285
2018-06-18 14:56:54 -07:00
Brian Smith dfe3b31c5e Update Rustls to the latest Git version to fix a bug. (#1143)
Using MS Edge and probably other clients with the Conduit proxy when
TLS is enabled fails because Rustls doesn't take into consideration
that Conduit only supports one signature scheme (ECDSA P-256 SHA-256).
This bug was fixed in Rustls when ECDSA support was added, after the
latest release. With this change MS Edge can talk to Conduit.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-16 08:09:42 -10:00
Brian Smith 4e1b0634b9 Proxy: Make the control plane completely optional. (#1132)
Proxy: Make the control plane completely optional.
2018-06-16 08:09:12 -10:00
Eliza Weisman 45622744e8 Attempt to load TLS settings immediately prior to starting watch (#1137)
Previously, the proxy would not attempt to load its TLS certificates until a fs
watch detected that one of them had changed. This means that if the proxy was
started with valid files already at the configured paths, it would not load 
them until one of the files changed.

This branch fixes that issue by starting the stream of changes with one event
_followed_ by any additional changes detected by watching the filesystem.

I've manually tested that this fixes the issue, both on Linux and on macOS, and
can confirm that this fixes the issue. In addition, when I start writing 
integration tests for certificate reloading, I'll make sure to include a test
to detect any regressions.

Closes #1133.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-15 17:32:55 -07:00
Brian Smith 2322dc955a Add optional TLS client certificate authentication. (#1135)
Refactor the way the TLS trust anchors are configured in preparation
for the client and server authenticating each others' certificates.

Make the use of client certificates optional pending the implementation
of authorization policy.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-15 14:26:26 -10:00
Brian Smith d50a65ba3f Keep accepting new connections after TLS handshake error. (#1134)
When a TLS handshake error occurs, the proxy just stops accepting
requests. It seems my expectations of how `Stream` handles errors
were wrong.

The test for this will be added in a separate PR after the
infrastructure needed for TLS testing is added. (This is a chicken
and egg problem.)

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-15 14:22:58 -10:00
Eliza Weisman 24d54dc2d2 proxy: Fix Inotify falling back to polling when files don't exist yet (#1119)
This PR changes the proxy's Inotify watch code to avoid always falling back to
polling the filesystem when the watched files don't exist yet. It also contains
some additional cleanup and refactoring of the inotify code, including moving
the non-TLS-specific filesystem watching code out of the `tls::config` module
and into a new `fs_watch` module.

In addition, it adds tests for both the polling-based and inotify-based watch
implementations, and changes the polling-based watches to hash the files rather
than using timestamps from the file's metadata to detect changes. These changes
are originally from #1094 and #1091, respectively, but they're included here
because @briansmith asked that all the changes be made in one PR.

Closes #1094. Closes #1091. Fixes #1090. Fixes #1097. Fixes #1061.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-15 11:40:04 -07:00
Brian Smith a5cf4c2db9 Simplify & clarify "No TLS" server configuration (#1131)
The same pattern will be used for the "No TLS" client configuration.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-14 19:10:03 -10:00
Oliver Gould 3aa5ac0453 proxy: Update prost to 0.4.0 (#1127)
prost-0.4.0 has been released, which removes unnecessary dependencies.
tower-grpc is being updated simultaneously, as this is the proxy's
primary use of prost.

See: https://github.com/danburkert/prost/releases/tag/v0.4.0
2018-06-14 16:29:41 -07:00
Oliver Gould 8becd7bfa1 proxy: Update `rand` to 0.5.1 (#1125)
* proxy: Update `rand` to 0.5.1

The proxy depends on rand-0.4, which is superceded by newer APIs in
rand-0.5. Since we're already using rand-0.5 via the tower-balance
crate, it seems appropriate to upgrade the proxy.

* Expand lock files in reviews
2018-06-14 15:09:58 -07:00
Oliver Gould e8e163a2e9 proxy: Convert `convert` from crate to module (#1115)
In e2093e3, we created a `convert` crate when refactoring the proxy's
gRPC bindings into a dedicated crate.

It's not really necessary to handle `convert` as a crate, given that it
holds a single 39-line file that's mostly comments. It's possible to
"vendor" this file in the proxy, and controller-grpc crate doesn't
even need this trait (in fact, the proxy probably doesn't either).
2018-06-13 16:18:51 -07:00
Oliver Gould 72cd70bef2 proxy: Update tower-balance (#1093)
To pick up https://github.com/tower-rs/tower/pull/86
2018-06-08 15:52:52 -07:00
Oliver Gould 2ed7c4ad40 proxy: Use a PeakEWMA outbound load balancer (#1080)
`tower-balance` has been updated with a Peak-EWMA load balancer; and a
new crate, `tower-h2-balance` has been introduced to make the load
balancer aware of some H2 stream events.

The Peak-EWMA balancer is designed to reduce tail latency by maintaining
an Exponentially Weighted Moving Average of latencies to each endpoint
which decay over a 10s window.
2018-06-07 22:06:12 -07:00
Eliza Weisman 0687665444 proxy: Forward TLS config to client watches (#1087)
This commit adds the initial wiring to forward TLS config changes to the 
watches used by TLS clients as well as TLS servers. As the TLS clients
are not yet implemented, the config type is currently `()`, but once
the client config is implemented, we should be able to drop it in 
seamlessly.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Co-authored-by: Brian Smith <brian@briansmith.org>
2018-06-07 19:16:54 -07:00
Eliza Weisman d70bb6d06c proxy: More DNS cleanup (#1052)
Depends on #1032. 

This branch makes some additional changes to the proxy's DNS code. In
particular, since we no longer need to clone the resolver on every lookup,
it removes some `clone()` calls in `DestinationSet::reset_dns_query`.
I've also changed the DNS futures to use the new contextual logging code 
on master.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-07 17:16:07 -07:00
Brian Smith c5b13fb3f7 Proxy: Better encapsulate the details of TLS config watching. (#1082, #1083)
* Fix non-Linux builds.

The change to signal.rs is needed for Windows.
The change to config.rs is needed for Windows and maybe other platforms.

Signed-off-by: Brian Smith <brian@briansmith.org>

* Proxy: Better encapsulate the details of TLS config watching.

Encapsulate more of the TLS configuration logic in the TLS submodule. This allows
for easier refactoring. In particular, this will make adding the client TLS configuration
easier.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-07 13:08:37 -10:00
Eliza Weisman fbbab10c6e proxy: detect TLS configuration changes using inotify on Linux (#1077)
This branch adds an inotify-based implementation of filesystem watches
for the TLS config files. On Linux, where inotify is available, this is
used instead of the polling-based code I added in #1056 and #1076.

In order to avoid the issues detecting changes to files in Kubernetes 
ConfigMaps described in #1061, we watch the directory _containing_ the
files we care about rather than the files themselves. I've tested this 
manually in Docker for Mac Kubernetes and can confirm that ConfigMap
changes are detected successfully.

Closes #1061. Closes #369.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-07 14:45:20 -07:00