Commit Graph

47 Commits

Author SHA1 Message Date
Carl Lerche d1168f6f28 Proxy: Bump h2 version to v0.1.8 (#990)
Signed-off-by: Carl Lerche <me@carllerche.com>
2018-05-23 12:45:14 -07:00
Eliza Weisman a067d3918c
proxy: Upgrade Conduit to use the new version of Tokio (#944)
Closes #888.  Closes #867.

This branch upgrades Conduit to use the new Tokio API. It was also necessary to
upgrade some other dependencies (including `hyper`, and `trust-dns`) alongside
this upgrade. 

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-05-17 16:38:15 -07:00
Sean McArthur fb904f0174
proxy: rebind services on connect errors (#952)
Instead of having connect errors destroy all buffered requests,
this changes Bind to return a service that can rebind itself when
there is a connect error.

It won't try to establish the new connection itself, but waits for
the buffer to poll again. Combing this with changes in tower-buffer
to remove canceled requests from the buffer should mean that we
won't loop on connect errors for forever.

Signed-off-by: Sean McArthur <sean@seanmonstar.com>
2018-05-17 14:15:16 -07:00
Carl Lerche d24a3410d8
Proxy: Update h2 dependency. (#948)
This also updates `bytes` as the newest version is required by `h2`.

Signed-off-by: Carl Lerche <me@carllerche.com>
2018-05-14 11:23:25 -07:00
Oliver Gould 63fbbd6931
proxy: Parse units with duration configurations (#909)
Configuration values that take durations are currently specified as
time values with no units.  So `600` may mean 600ms in some contexts and
10 minutes in others.

In order to avoid this problem, this change now requires that
configurations provide explicit units for time values such as '600ms' or
10 minutes'.

Fixes #27.
2018-05-08 13:54:12 -07:00
Oliver Gould 7f16079f64
proxy: Upgrade tower dependencies (#892)
In order to pick up https://github.com/tower-rs/tower-grpc/pull/60,
upgrade tower dependencies. This will reduce the cost of updating
for upcoming tower-h2 improvements.
2018-05-02 13:40:55 -07:00
Brian Smith 0c23ad416b
Proxy: Use trust-dns-resolver for DNS. (#834)
trust-dns-resolver is a more complete implementation. In particular,
it supports CNAMES correctly, which is needed for PR #764. It also
supports /etc/hosts, which will help with issue #62.

Use the 0.8.2 pre-release since it hasn't been released yet. It was
created at our request.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-04-25 10:04:49 -10:00
Carl Lerche 298321a6c1
Bump proxy h2 dependency to v0.1.6. (#845)
This release includes a number of bug fixes related to HTTP/2.0 stream
management.

Signed-off-by: Carl Lerche <me@carllerche.com>
2018-04-25 08:40:42 -07:00
Eliza Weisman a2c60e8fcf
Add optional GZIP compression to proxy /metrics endpoint (#665)
Closes #598.

According to the Prometheus documentation, metrics export endpoints should support serving metrics compressed using GZIP. I've modified the proxy's `/metrics` endpoint to serve metrics compressed with GZIP when an `Accept-Encoding: gzip` request header is sent.

I've also added a new unit test that attempts to get the proxy's metrics endpoint as GZIP, and asserts that the metrics are decompressed successfully.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-04-24 17:42:50 -07:00
Eliza Weisman 79304cdcaf
proxy: Unbreak process_start_time_seconds metric (#825)
The refactoring of how metrics are formatted in 674ce87588 inadvertently introduced a bug that caused the `process_start_time_seconds` metric to be formatted as just a number without the metric name. This causes Prometheus to fail with a parse error rather than accepting the metrics.

I've fixed this issue, and added a unit test to detect regressions in the future.
2018-04-20 15:59:08 -07:00
Eliza Weisman b07b554d2b
Add labels from service discovery to proxy metrics reports (#661)
PR #654 adds pod-based metric labels to the Destination API responses for cluster-local services. 

This PR modifies the proxy to actually add these labels to reported Prometheus metrics for outbound requests to local services. 

It enhances the proxy's `control::discovery` module to track these labels and add a `LabelRequest` middleware to the service stack built in `Bind` for labeled services. Requests transiting `LabelRequest` are given an `Extension` which contains these labels, which are then added to events produced by the `Sensors` for these requests. When these events are aggregated to Prometheus metrics, the labels are added.

I've also added some tests in `test/telemetry.rs` ensuring that these metrics are added correctly when the Destination service provides labels.

Closes #660

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-04-12 12:54:38 -07:00
Sean McArthur 02c6887020
proxy: improve graceful shutdown process (#684)
- The listener is immediately closed on receipt of a shutdown signal.
- All in-progress server connections are now counted, and the process will
  not shutdown until the connection count has dropped to zero.
- In the case of HTTP1, idle connections are closed. In the case of HTTP2,
  the HTTP2 graceful shutdown steps are followed of sending various
  GOAWAYs.
2018-04-10 14:15:37 -07:00
Carl Lerche 288e041b8f proxy: Update h2 to 0.1.3 (#640)
Signed-off-by: Carl Lerche <me@carllerche.com>
2018-03-29 09:22:54 -07:00
Brian Smith a9589ecf99
Update tempdir dependency to improve deps situation. (#596)
Replace an unconditional dependency on windows-specific crates in
tempdir (via its update of its remove_dir_all dependency), which
eliminates the need to download any windows-specific crates during
the build when targetting non-Windows platforms.

Also, when targetting Windows platforms, replace a winapi 0.2.x
dependency with a winapi 0.3.x dependency.

This results in two fewer downloads during Docker builds:

```diff
- Downloading winapi v0.2.8
- Downloading winapi-build v0.1.1
```

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-03-21 10:43:32 -10:00
Brian Smith 000e1fff24
Update codegen and tower-balance to remove indexmap dep. (#594)
```sh
$ cargo update -p codegen -p tower-balance
    [...]
    Removing indexmap v0.4.1
```

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-03-21 08:28:33 -10:00
Sean McArthur cd59465366
proxy: add SIGTERM and SIGINT handlers (#581)
When the proxy is run in a Docker container, it runs as PID 1, with
no default signal handlers setup. In order to react to signals from
Kubernetes about shutting down, we need to set up explicit handlers.

This adds handlers for SIGTERM and SIGINT.

Closes #549
2018-03-16 18:53:20 -07:00
Carl Lerche 35f61dcc56 Proxy: Upgrade h2 and indexmap crates (#572)
In order to pick up a bugfix in h2, upgrade:

h2 0.1.2
indexmap 1.0.0

Signed-off-by: Carl Lerche <me@carllerche.com>
2018-03-14 12:35:38 -07:00
Brian Smith 9cdc485ee4
Proxy: Update deps to improve logging and remove slab 0.3 & ordermap deps. (#550)
Improve per-module logging (reportedly log 0.3 doesn't work with
env_logger 0.5 as well as log 0.4 does in this respect) and eliminate
unnecesary dependencies.

```
cargo update -p mio
cargo update -p tokio-io
cargo update -p tower
cargo update -p tower-h2
cargo update -p tower-grpc
```

This removes (partial output of the above `cargo update` commands):

```
    Removing log v0.3.9
    Removing ordermap v0.2.13
    Removing ordermap v0.3.5
    Removing slab v0.3.0
```

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-03-08 18:38:10 -10:00
Sean McArthur 83d6a1f579
proxy: improve transparency of host headers and absolute-uris (#535)
In some cases, we would adjust an existing Host header, or add one. And in all cases when an HTTP/1 request was received with an absolute-form target, it was not passed on.

Now, the Host header is never changed. And if the Uri was in absolute-form, it is sent in the same format.

Closes #518
2018-03-08 13:15:21 -08:00
Carl Lerche 1b4a426d16
Proxy: Update h2 dependency. (#539)
The h2 crate (HTTP/2.0 client and server) has a new release which
includes bug fixes and stability improvements.

This updates the Cargo.lock file to include the new release.

Closes #538

Signed-off-by: Carl Lerche <me@carllerche.com>
2018-03-08 12:59:27 -08:00
Brian Smith 82f9db7deb
Patch prost-derive 0.3.2 to current master to prune dependencies. (#526)
Pick up https://github.com/danburkert/prost/pull/87, which results in the
following reduction in build dependencies for the proxy:

    Removing failure_derive v0.1.1
      Adding prost-derive v0.3.2 (https://github.com/danburkert/prost#3427352e)
    Removing prost-derive v0.3.2
    Removing quote v0.3.15
    Removing syn v0.11.11
    Removing synom v0.11.3
    Removing synstructure v0.6.1
    Removing unicode-xid v0.0.4

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-03-07 10:27:00 -10:00
Eliza Weisman 569d6939a7
Enforce that requests are mapped to connections for each Host: header values (#492)
This PR ensures that the mapping of requests to outbound connections is segregated by `Host:` header values. In most cases, the desired behavior is provided by Hyper's connection pooling. However, Hyper does not handle the case where a request had no `Host:` header and the request URI had no authority part, and the request was routed based on the SO_ORIGINAL_DST in the desired manner. We would like these requests to each have their own outbound connection, but Hyper will reuse the same connection for such requests. 

Therefore, I have modified `conduit_proxy_router::Recognize` to allow implementations of `Recognize` to indicate whether the service for a given key can be cached, and to only cache the service when it is marked as cachable. I've also changed the `reconstruct_uri` function, which rewrites HTTP/1 requests, to mark when a request had no authority and no `Host:` header, and the authority was rewritten to be the request's ORIGINAL_DST. When this is the case, the `Recognize` implementations for `Inbound` and `Outbound` will mark these requests as non-cachable.

I've also added unit tests ensuring that A, connections are created per `Host:` header, and B, that requests with no `Host:` header each create a new connection. The first test passes without any additional changes, but the second only passes on this branch. The tests were added in PR #489, but this branch supersedes that branch.

Fixes #415. Closes #489.
2018-03-06 16:44:14 -08:00
Brian Smith ab0cf87edc
Update prost to 0.3.2 to remove 29 crate dependencies. (#506)
The main goal with this change is to make it clear, from looking at
Cargo.lock, that the Conduit proxy doesn't depend on OpenSSL. Although
the *ring* crate attempts to avoid conflicts with symbols defined in
OpenSSL, that is a manual process that doesn't have automatic
verification yet.

The secondary goal is to reduce the total number of dependencies to
make (at least) full from-scratch builds, such as those in CI, faster.

As a result of this PR, following the following upstream PRs we
submitted to prost, as well as  some similar PRs in other upstream
projects and in conduit inself, our usage of prost now results in us
depending on many fewer crates:

  * https://github.com/danburkert/prost/pull/78
  * https://github.com/danburkert/prost/pull/79
  * https://github.com/danburkert/prost/pull/82
  * https://github.com/danburkert/prost/pull/84

Here are the crate dependencies that are removed:

  * adler32
  * aho-corasick
  * build_const
  * bzip2
  * bzip2-sys
  * crc
  * curl
  * curl-sys
  * env_logger (0.4)
  * flate2
  * lazy_static
  * libz-sys
  * memchr
  * miniz_oxide
  * miniz_oxide_c_api
  * msdos_time
  * openssl-probe
  * openssl-sys
  * pkg-config
  * podio
  * regex
  * regex-syntax
  * schannel
  * socket2
  * thread_local
  * unreachable
  * utf8-ranges
  * vcpkg
  * zip

Pretty much all of these are build dependencies, but Cargo.lock doesn't
distinguish between build dependencies and regular dependencies.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-03-06 11:03:35 -10:00
Sean McArthur c278228c1b
proxy: preserve body headers in http1 (#457)
As a goal of being a transparent proxy, we want to proxy requests and
responses with as little modification as possible. Basically, servers
and clients should see messages that look the same whether the proxy was
injected or not.

With that goal in mind, we want to make sure that body headers (things
like `Content-Length`, `Transfer-Encoding`, etc) are left alone. Prior
to this commit, we at times were changing behavior. Sometimes
`Transfer-Encoding` was added to requests, or `Content-Length: 0` may
have been removed. While RC 7230 defines that differences are
semantically the same, implementations may not handle them correctly.

Now, we've added some fixes to prevent any of these header changes
from occurring, along with tests to make sure library updates don't
regress.

For requests:

- With no message body, `Transfer-Encoding: chunked` should no longer be
added.
- With `Content-Length: 0`, the header is forwarded untouched.

For responses:

- Tests were added that responses not allowed to have bodies (to HEAD
requests, 204, 304) did not have `Transfer-Encoding` added.
- Tests that `Content-Length: 0` is preserved.
- Tests that HTTP/1.0 responses with no body headers do not have
`Transfer-Encoding` added.
- Tests that `HEAD` responses forward `Content-Length` headers (but not
an actual body).

Closes #447

Signed-off-by: Sean McArthur <sean@seanmonstar.com>
2018-03-05 18:10:51 -08:00
Brian Smith ea9a2c84e9
Proxy: Update domain dep. to remove rand 0.3 dep. (#495)
Signed-off-by: Brian Smith <brian@briansmith.org>
2018-03-01 17:16:21 -10:00
Brian Smith b788daf429
Update abstract-ns and tempdir dependencies to use rand 0.4. (#468)
```
cargo update -p tempdir
cargo update -p abstract-ns
```

The new version of tempdir actually adds a new dependency, but
apparently that is to fix a bug.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 19:40:03 -10:00
Brian Smith 0d14c196f5
Proxy: Upgrade from ordermap 0.2 crate to indexmap 0.4. (#466)
Currently we have to download and build two different versions of
the ordermap crate.

I will submit similar PRs for the dependent crates so that we will
eventually all be using the same version of indexmap.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 19:29:22 -10:00
Brian Smith 6b4d294a40
Reduce memory allocations during logging. (#445)
Stop initializing env_logger in every test. In env_logger 0.5, it
may only be initialized once per process.

Also, Prost will soon upgrade to env_logger 0.5 and this will
(eventually) help reduce the number of versions of env_logger we
have to build. Turning off the regex feature will (eventually) also
reduce the number of dependencies we have to build. Unfortunately,
as it is now, the number of dependencies has increased because
env_logger increased its dependencies in 0.5.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 18:32:47 -10:00
Brian Smith 578cffca22
Turn off the `use_logging` default feature of quickcheck. (#465)
Turning off the default features of quickcheck removes its
`env_logger` and `log` dependencies. It uses older versions of
those packages than conduit-proxy will use, so this will
(eventually) reduce the number of versions of those packages that
get downloaded and built.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 16:04:58 -10:00
Brian Smith 617d7da894
Remove the unused tokio-proto build dependency. (#451)
Hyper depends on tokio-proto with a default feature. By turning off
its default features, we can avoid that dependency. That reduces the
number of dependencies by 4.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 08:56:05 -10:00
Brian Smith 8607875267
Stop using the url crate in the proxy. (#450)
Version 1.7.0 of the url crate seems to be broken which means we cannot
`cargo update` the proxy without locking url to version 1.6. Since we only
use it in a very limited way anyway, and since we use http::uri for parsing
much more, just switch all uses of the url crate to use http::uri for parsing
instead.

This eliminates some build dependencies.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 08:55:48 -10:00
Sean McArthur 381fb3800e
proxy: don't send transfer-encoding for empty GET requests (#410)
This is fixed in hyper v0.11.19.

Closes #402
2018-02-23 16:22:45 -08:00
Eliza Weisman 50103d479a
Remove timestamps from log messages (#399)
As @olix0r requested in https://github.com/runconduit/conduit/issues/56#issuecomment-356771758, I've removed timestamps from the Conduit proxy's log records.

Closes #56

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-02-21 15:17:17 -08:00
Kevin Lingerfelt 383babfae2
Prepare for the v0.3.0 release (#406)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-02-21 11:14:11 -08:00
Carl Lerche 287128885e
Proxy: Limit the max number of in-flight requests. (#398)
Currently, the max number of in-flight requests in the proxy is
unbounded. This is due to the `Buffer` middleware being unbounded.

This is resolved by adding an instance of `InFlightLimit` around
`Buffer`, capping the max number of in-flight requests for a given
endpoint.

Currently, the limit is hardcoded to 10,000. However, this will
eventually become a configuration value.

Fixes #287

Signed-off-by: Carl Lerche <me@carllerche.com>
2018-02-20 19:56:21 -08:00
Oliver Gould a2d537f5c4
Use a load-aware balancer (#251)
Currently, the conduit proxy uses a simplistic Round-Robin load
balancing algorithm. This strategy degrades severely when individual
endpoints exhibit abnormally high latency.

This change improves this situation somewhat by making the load balancer
aware of the number of outstanding requests to each endpoint. When nodes
exhibit high latency, they should tend to have more pending requests
than faster nodes; and the Power-of-Two-Choices node selector can be
used to distribute requests to lesser-loaded instances.

From the finagle guide:

    The algorithm randomly picks two nodes from the set of ready endpoints
    and selects the least loaded of the two. By repeatedly using this
    strategy, we can expect a manageable upper bound on the maximum load of
    any server.

    The maximum load variance between any two servers is bound by
    ln(ln(n))` where `n` is the number of servers in the cluster.

Signed-off-by: Oliver Gould <ver@buoyant.io>
2018-02-07 09:39:31 -08:00
Oliver Gould e2093e37f8
Move the Rust gRPC bindings to a dedicated crate (#275)
The proxy depends on `protoc`-generated gRPC bindings to communicate
with the controller. In order to generate these bindings, build-time
dependencies must be compiled.

In order to support a more granular, cacheable build scheme, a new crate
has been created to house these gRPC bindings,
`conduit-proxy-controller-grpc`.

Because `TryFrom` and `TryInto` conversions are implemented for
protobuf-defined types, the `convert` module also had to be moved to
into a dedicated crate.

Furthermore, because the proxy's tests require that
`quickcheck::Aribtrary` be implemented for protobuf types, the
`conduit-proxy-controller-grpc` crate supports an _arbitrary_ feature
fla protobuf types, the `conduit-proxy-controller-grpc` crate supports
an _arbitrary_ feature flag.

While we're moving these libraries around, the `tower-router` crate has
been moved to `proxy/router` and renamed to `conduit-proxy-router.`
`futures-mpsc-lossy` has been moved into the proxy directory but has not
been renamed.

Finally, the `proxy/Dockerfile-deps` image has been updated to avoid the
wasteful building of dependency artifacts, as they are not actually used
by `proxy/Dockerfile`.
2018-02-06 10:31:48 -08:00
Eliza Weisman eddc37de28 Adopt external tower-grpc and tower-h2 deps #225)
The conduit repo includes several library projects that have since been
moved into external repos, including `tower-grpc` and `tower-h2`.

This change removes these vendored libraries in favor of using the new
external crates.
2018-02-01 11:57:02 -08:00
Dennis Adjei-Baah 01312f9ffe
Prepare for v0.2.0 release (#248)
* prepare for v0.2.0 release

Signed-off-by: Dennis Adjei-Baah <dennis@buoyant.io>
2018-01-31 15:39:48 -08:00
Sean McArthur 54aef56e25
proxy: add transparent protocol detection and handling
The proxy will now try to detect what protocol new connections are
using, and route them accordingly. Specifically:

- HTTP/2 stays the same.
- HTTP/1 is now accepted, and will try to send an HTTP/1 request
  to the target.
- If neither HTTP/1 nor 2, assume a TCP stream and simply forward
  between the source and destination.

* tower-h2: fix Server Clone bounds
* proxy: implement Async{Read,Write} extra methods for Connection

Closes #130 
Closes #131
2018-01-23 16:14:07 -08:00
Andrew Seigner 06c9894c31
Updates for v0.1.3 release (#185)
Signed-off-by: Andrew Seigner <siggy@buoyant.io>
2018-01-19 13:58:52 -08:00
Andrew Seigner e6f17faf28
Updates for v0.1.2 release (#171)
Signed-off-by: Andrew Seigner <siggy@buoyant.io>
2018-01-19 10:56:20 -08:00
Andrew Seigner caeb83a526
Fix Go and Proxy dependency image SHAs (#117)
The image tags for gcr.io/runconduit/go-deps and
gcr.io/runconduit/proxy-deps were not updating to account for all
changes in those images.

Modify SHA generation to include all files that affect the base
dependency images. Also add instructions to README.md for updating
hard-coded SHAs in Dockerfile's.

Fixes #115

Signed-off-by: Andrew Seigner <andrew@sig.gy>
2018-01-08 11:19:49 -08:00
Eliza Weisman 90b5ddfb00
Change Cargo.lock to trigger deps image rebuild (#116)
Because whether or not to build a new deps image is based on the SHA of Cargo.lock, changes to the deps Dockerfile will not cause a new deps image to be built. Because of this, the current proxy deps Docker image is based on the wrong Rust version, breaking the build. See #115 for details on this issue.

I've appended a newline to Cargo.lock to change the lockfile's SHA and trigger a rebuild of the deps Docker image on CI. I've also added a comment in the Dockerfile noting that it is necessary to do this when changing that file.

Signed-off-by: Eliza Weisman eliza@buoyant.io
2018-01-08 10:29:51 -08:00
Kevin Lingerfelt a8e75115ab
Prepare the repo for the v0.1.1 release (#75)
* Prepare the repo for the v0.1.1 release

* Add changelog

* Changelog updates, wrap at 100 characters
2017-12-20 10:51:53 -08:00
Oliver Gould bff3efea3f
Prepare for v0.1.0 (#1)
Update versions in code.

Use default docker tag of v0.1.0
2017-12-04 19:55:56 -08:00
Oliver Gould b104bd0676 Introducing Conduit, the ultralight service mesh
We’ve built Conduit from the ground up to be the fastest, lightest,
simplest, and most secure service mesh in the world. It features an
incredibly fast and safe data plane written in Rust, a simple yet
powerful control plane written in Go, and a design that’s focused on
performance, security, and usability. Most importantly, Conduit
incorporates the many lessons we’ve learned from over 18 months of
production service mesh experience with Linkerd.

This repository contains a few tightly-related components:
- `proxy` -- an HTTP/2 proxy written in Rust;
- `controller` -- a control plane written in Go with gRPC;
- `web` -- a UI written in React, served by Go.
2017-12-05 00:24:55 +00:00