Commit Graph

34 Commits

Author SHA1 Message Date
Eliza Weisman 6df55c0059
Update h2 to 0.1.15 (#172)
carllerche/h2#338 fixes a deadlock in stream reference counts that could
potentially impact the proxy. This branch updates our `h2` dependency to a
version which includes this change.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-01-16 15:10:44 -08:00
Eliza Weisman 08b2a23ca8
Update to trust-dns-resolver 0.10.1 (#169)
An upstream bug in the `trust-dns-proto` library can cause
`trust-dns-resolver` to leak UDP sockets when DNS queries time out. This
issue appears to be the cause of the memory leak described in
linkerd/linkerd2#2012.

This branch updates the `trust-dns` dependency to pick up the change in
bluejekyll/trust-dns#635, which fixes the UDP socket leak.

I confirmed that the socket leak was fixed by modifying the proxy to
hard-code a 0-second DNS timeout, sending requests to the proxy's
outbound listener, and using

``` lsof -p $(pgrep linkerd2-proxy) ```

to count the number of open UDP sockets. On master, every request to a
different DNS name that times out leaves behind an additional open UDP
socket, which show up in `lsof`, while on this branch, only TCP sockets
remain open after the request ends.

In addition, I'm running a test in GCP to watch the memory and file
descriptor use of the proxy over a long period of time. This is still in
progress, but given the above, I strongly believe this branch fixes the
leak.

Fixes linkerd/linkerd2#2012.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2019-01-09 16:11:12 -08:00
Sean McArthur 2f2050537d add Route retries to Service Profiles
Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-12-19 18:31:43 -08:00
Sean McArthur 5b00bcf40e Update to latest tower and tower-grpc
Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-12-19 13:18:57 -08:00
Sean McArthur 792c04b7d1 Replace tower-h2 tap service with hyper
This untangles some of the HTTP/gRPC glue, providing services/stacks
that have more specific focuses. The `HyperServerSvc` now *only*
converts to a `tower::Service`, and the HTTP/1.1 and Upgrade pieces were
moved to a specific `proxy::http::upgrade::Service`.

Several stack modules were added to `proxy::grpc`, which can map request
and response bodies into `Payload`, or into `grpc::Body`, as needed.

Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-12-18 12:05:50 -08:00
Sean McArthur b9ffbb7f93 Update h2 to v0.1.14
Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-12-05 11:01:49 -08:00
Oliver Gould 872f78df31
Expose route labels via tap (#147)
Route labels are not queryable by tap, nor are they exposed to in tap
events.

This change uses the newly-added fields in linkerd/linkerd2-proxy-api#17
to make Tap route-aware.
2018-12-03 12:29:39 -08:00
Sean McArthur 88340cadf3 replace proxy::http usage of tower-h2 with hyper
Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-11-27 17:29:18 -08:00
Sean McArthur f37c9e5128 Update all tower pieces to use Service<Request> (#132)
Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-11-16 11:19:17 -08:00
Oliver Gould 7add0db68e
Disable debug symbols for tests (#135)
Our test artifacts end up consuming several GB of disk space, largely
due to debug symbols. This can prevent CI from passing, as CI hosts only
have about 9G of real estate.

By disabling debug symbols, we reduce artifact size by >90% (and total
target directory size from 14G to 4G).
2018-11-16 10:03:42 -08:00
Oliver Gould d5e2ff2cb7
Canonicalize outbound names via DNS for inbound profiles (#129)
When the inbound proxy receives requests, these requests may have
relative `:authority` values like _web:8080_. Because these requests can
come from hosts with a variety of DNS configurations, the inbound proxy
can't make a sufficient guess about the fully qualified name (e.g.
_web.ns.svc.cluster.local._).

In order for the inbound proxy to discover inbound service profiles, we
need to establish some means for the inbound proxy to determine the
"canonical" name of the service for each request.

This change introduces a new `l5d-dst-canonical` header that is set by
the outbound proxy and used by the remote inbound proxy to determine
which profile should be used.

The outbound proxy determines the canonical destination by performing
DNS resolution as requests are routed and uses this name for profile and
address discovery. This change removes the proxy's hardcoded Kubernetes
dependency.

The `LINKERD2_PROXY_DESTINATION_GET_SUFFIXES` and
`LINKERD2_PROXY_DESTINATION_PROFILE_SUFFIXES` environment variables
control which domains may be discovered via the destination service.

Finally, HTTP settings detection has been moved into a dedicated routing
layer at the "bottom" of the stack. This is done do that
canonicalization and discovery need not be done redundantly for each set
of HTTP settings. Now, HTTP settings, only configure the HTTP client
stack within an endpoint.

Fixes linkerd/linkerd2#1798
2018-11-15 11:41:17 -08:00
Sean McArthur 1595b2457d convert several Stack unit errors into Never
Since this stack pieces will never error, we can mark their
`Error`s with a type that can "never" be created. When seeing an `Error
= ()`, it can either mean the error never happens, or that the detailed
error is dealt with elsewhere and only a unit is passed on. When seeing
`Error = Never`, it is clearer that the error case never happens.
Besides helping humans, LLVM can also remove the error branchs entirely.

Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-11-13 11:55:41 -08:00
Oliver Gould 5e0a15b8a7
Introduce outbound route metrics (#117)
The Destination Profile API---provided by linkerd2-proxy-api v0.1.3--
allows the proxy to discovery route information for an HTTP service. As
the proxy processes outbound requests, in addition to doing address
resolution through the Destination service, the proxy may also discover
profiles including route patterns and labels.

When the proxy has route information for a destination, it applies the
RequestMatch for each route to find the first-matching route. The
route's labels are used to expose `route_`-prefixed HTTP metrics (and
each label is prefixed with `rt_`).

Furthermore, if a route includes ResponseMatches, they are used to
perform classification (i.e. for the `response_total` and
`route_response_total` metrics).

A new `proxy::http::profiles` module implements a router that consumes
routes from an infinite stream of route lists.

The `app::profiles` module implements a client that continually and
repeatedly tries to establish a watch for the destination's routes (with
some backoff).

Route discovery does not _block_ routing; that is, the first request to
a destination will likely be processed before the route information is
retrieved from the controller (i.e. on the default route). Route
configuration is applied in a best-effort fashion.
2018-11-05 16:30:39 -08:00
Oliver Gould 0b6e35857b
Upgrade trust-dns-resolver to 0.10.0 (#118) 2018-11-02 11:28:22 -07:00
Oliver Gould 978fed1cf6
refactor: Structure the proxy in terms of `Stack` (#100)
As the proxy's functionality has grown, the HTTP routing functionality
has become complex. Module boundaries have become ill-defined, which
leads to tight coupling--especially around the `ctx` metadata types and
`Service` type signatures.

This change introduces a `Stack` type (and subcrate) that is used as the
base building block for proxy functionality. The `proxy` module now
exposes generic components--stack layers--that are configured and
instantiated in the `app::main` module.

This change reorganizes the repo as follows:
- Several auxiliary crates have been split out from the `src/` directory
  into `lib/fs-watch`, `lib/stack` and `lib/task`.
- All logic specific to configuring and running the linkerd2 sidecar
  proxy has been moved into `src/app`. The `Main` type has been moved
  from `src/lib.rs` to `src/app/main.rs`.
- The `src/proxy` has reusable, generic components useful for building
  proxies in terms of `Stack`s.

The logic contained in `lib/bind.rs`, pertaining to per-endpoint service
behavior, has almost entirely been moved into `app::main`.

`control::destination` has changed so that it is not responsible for
building services. (It used to take a clone of `Bind` and use it to
create per-endpoint services). Instead, the destination service
implements the new `proxy::Resolve` trait, which produces an infinite
`Resolution` stream for each lookup. This allows the `proxy::balance`
module to be generic over the servie discovery source.

Furthermore, the `router::Recognize` API has changed to only expose a
`recgonize()` method and not a `bind_service()` method. The
`bind_service` logic is now modeled as a `Stack`.

The `telemetry::http` module has been replaced by a
`proxy::http::metrics` module that is generic over its metadata types
and does not rely on the old telemetry event system. These events are
now a local implementation detail of the `tap` module.

There are no user-facing changes in the proxy's behavior.
2018-10-11 11:25:03 -07:00
Eliza Weisman 51db6f8be8
Change trust-dns-resolver to a version rather than git dependency (#103)
This branch changes the proxy's `trust-dns-resolver` dependency to a
version dependency rather than a Git dependency, since the
`0.10.0-alpha.3` version has the features that we previously required
the git dependency for.

The only changes to the proxy codebase itself were fixes for deprecation
warnings introduced by the dependency upgrade, since it was necessary to
update the minimum `tokio_timer` version as `trust-dns-proto` uses APIs
added in `tokio-timer` v0.2.6. In particular, `tokio_timer::Deadline`
was deprecated and replaced by `Timeout`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-10-10 13:10:36 -07:00
Oliver Gould a4d4110776
Create a `lib` dir for subcrates (#97)
As we extract subcrates from the `src/` directory, the repository root
becomes a bit cluttered. This change moves these subcrates into a `lib`
directory.
2018-09-18 16:02:31 -07:00
Oliver Gould 53a85f442a
Split the `timeout` module into its own subcrate (#96)
The `timeout` module has very little to do with the proxy, specifically.

This change moves it into a dedicated subcrate. This helps to clarify
dependencies and to minimize generic logic in the main proxy crate.

In doing this, an unused implementation of AsyncRead/AsyncWrite for
Timeout was deleted.

Furthermore, the `HumanDuration` type has been copied into
tests/support/mod.rs so that this type need not be part of the timeout
module's public API.
2018-09-18 15:09:31 -07:00
Oliver Gould 8a9a9bf26b
Move telemetry::metrics into dedicated crate (#84)
The `metrics!` macro is currently local to the telemetry module.
Furthermore, the `telemetry::metrics` module no longer has
proxy-specific logic.

This change moves the `telemetry::metrics` module into a new crate,
`linkerd2_metrics`.

This will enable unifying `telemetry::http` and `telemetry::transport`
into `http` and `transport`, respectively.
2018-08-24 14:53:53 -07:00
Eliza Weisman 1774c87400
Refactor control::destination::background::client module (#38)
This branch should not make any functional changes.

This branch makes two minor refactorings to the `client` module in 
`control::destination::background`:

 1. Remove the `AddOrigin` middleware and replace it with the 
    `tower-add-origin` crate from `tower-http`. These middlewares are
    functionally identical, but the Tower version has tests.
 2. Change `ClientService` from a type alias to a tuple struct. This
    means that some of the middleware that are used only in this module
    (`LogErrors` and `Backoff`) are no longer part of a publicly visible
    type and can be made private to the module.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-08-03 17:00:20 -07:00
Sean McArthur ab1b280de8
Add orig-proto which uses HTTP2 between proxies (#32)
When the destination service returns a hint that an endpoint is another
proxy, eligible HTTP1 requests are translated into HTTP2 and sent over
an HTTP2 connection. The original protocol details are encoded in a
header, `l5d-orig-proto`. When a proxy receives an inbound HTTP2
request with this header, the request is translated back into its HTTP/1
representation before being passed to the internal service.

Signed-off-by: Sean McArthur <sean@buoyant.io>
2018-08-03 15:03:14 -07:00
Eliza Weisman 51e07b2a68
Update h2 version to v0.1.11 (#33)
This branch updates the proxy's `h2` dependency to v0.1.11. This version
removes a busy loop when shutting down an idle server
(carllerche/h2#296), and fixes a potential panic when dropping clients
(carllerche/h2#295).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-07-31 12:12:26 -07:00
Brian Smith e1b4e66836
Upgrade TLS dependencies. (#16)
Fixes linkerd/linkerd2#1330.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-07-17 09:21:59 -10:00
Eliza Weisman 2ac114ba65
Point inotify dependency at master (#14)
Now that inotify-rs/inotify#105 has merged, we will no longer see
rampant CPU use from using the master version of `inotify`. I've 
updated Cargo.toml to depend on master rather than on my branch.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-07-17 10:21:40 -07:00
Oliver Gould c23ecd0cbc
Migrate `conduit-proxy` to `linkerd2-proxy`
The proxy now honors environment variables starting with
`LINKERD2_PROXY_`.
2018-07-07 22:45:21 +00: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
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 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
Eliza Weisman 1b1623dd83 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 20855519d2 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
Brian Smith c359aadfab 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
Oliver Gould 0cd1f65e39 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 b56cc883c1 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
Oliver Gould d2c54b65de 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