Commit Graph

575 Commits

Author SHA1 Message Date
Eliza Weisman 65585699b6
Fix unbound `DOCKER_TRACE` var in `bin/docker-test-proxy` (#1107)
I forgot to export this since the script no longer sources `. bin/_docker.sh`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-12 13:19:14 -07:00
Risha Mars ea01378090
Upgrade enzyme-context-patch to its latest version (#1108)
https://www.npmjs.com/package/enzyme-context-patch

This is a temporary fix until enzyme releases with the fix for
Error: Enzyme Internal Error: unknown node with tag 12
2018-06-12 12:38:39 -07:00
Kevin Lingerfelt 6e66f6d662
Rename Lister to API and expose informers as well as listers (#1072)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-12 10:27:55 -07:00
Eliza Weisman b7399f484a
Add a script for running proxy tests in Docker (#1102)
When developing features in the proxy, that rely on Linux-only OS features,
developers using other operating systems may find it inconvenient to test
their changes. While we run CI builds on Linux, and may have access to Linux
testing environments, this is not as tightly integrated into the proxy 
development workflow as running a quick `cargo test` on the host OS.

For example, I found it inconvenient to test the `inotify` based filesystem
watch code I've been adding in recent commits, and had to do things like
opening a WIP PR for a branch to get CI to run the tests. This workflow is not
ideal.

This PR adds an (admittedly somewhat hacky) script and Dockerfile for running
the proxy's tests in Docker. This accomplishes approximately the same goal as 
the `PROXY_SKIP_TESTS` flag that we used to have, but with the advantage that 
we no longer include the test dependencies in release builds. 

Of course, this also means that we no longer share any of the dependencies 
between the test docker build and the release docker build, which is a shame. 
It might be worthwhile to re-introduce a dependencies image so that cached
builds of the proxy's dependencies can be shared between the test and release
Dockerfiles. However, I thought that deserved to be discussed separately from
the changes I made in this branch.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-11 16:44:39 -07:00
Thomas Rampelberg c3dc20d64f
Move from /api/stat to /api/tps-reports (#1105)
Common blacklists have `/api/stat` in them. This causes the dashboard to not load.

`/api/tps-reports` is not in any blacklists, suggests what this route does and is slightly tongue in cheek. Fixes #970
2018-06-11 16:39:00 -07:00
Dennis Adjei-Baah 3ae8dcd369 Prepare for v0.4.3 (#1099) 2018-06-11 10:55:12 -07:00
Oliver Gould 68786d85a6
proxy: Update tower-balance (#1093)
To pick up https://github.com/tower-rs/tower/pull/86
2018-06-08 15:52:52 -07:00
Risha Mars 7d4c4aa290
CLI: print resources in the same order every time stat all is run (#1088)
Previously, in conduit stat all we would just print the map of stat results, which 
resulted in the order in which stats were displayed varying between prints.

Fix:
Define an array, k8s.StatAllResourceTypes and use the order in this array to print 
the map; ensuring a consistent print order every time the command is run.
2018-06-08 15:02:17 -07:00
Risha Mars 53b713b2a8
Remove the ⚠️ emoji from non-tlsed grafana stat labels (#1089) 2018-06-08 15:00:56 -07:00
Risha Mars b930bc6b88
Fix conduit health grafana dashboard (#1086)
* Scope health queries to controller namespace

* Add a prometheus query variable to get the conduit namespace
2018-06-08 12:57:05 -07:00
Oliver Gould cea37ee48d
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 c124898a7a
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 dafadedd4b
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 bcd2e55dc3
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
Thomas Rampelberg 33ed167616
Display font-awesome icons no matter what URL is originally loaded (#1078)
* Display font-awesome icons no matter what URL is originally loaded

The URLs in the dashboard need to be relative. Unfortunately, this means that if
you load something that isn't the base route ... font-awesome icons look broken.

There's no real way to solve this from within webpack (or the web server without
some work). Instead, just load font-awesome from a CDN as there's no real
benefit we get from including it in the bundle. Fixes #1019.

* Moving font-awesome to styles
2018-06-07 15:37:35 -07:00
Eliza Weisman 81c370a708
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
Brian Smith 1408c392bf
Proxy: Map Kubernetes Pod Namespace/Name to TLS identity. (#1074)
* Proxy: Map Kubernetes Pod Namespace/Name to TLS identity.

Map the Kubernetes identity into a DNS name that can be used to
validate the peer's certificate. The final mapping is TBD; the
important thing for now is that the mapped name doesn't collide
with any real DNS name.

Encapsulate the mapping logic within the TLS submodule.

Minimize `Arc`ing and `Clone`ing of TLS identities.

This has no effect in default configurations since the settings that
enable the functionality are not set by default.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-07 11:14:57 -10:00
Thomas Rampelberg 9889597c29
Handle an edge case when using bin/web (#1075)
* Handle an edge case when using bin/web

There's a weird error running `bin/web dev` if you don't have conduit installed on a kubernetes cluster. Nothing in the docs mention that you need to work on this.

Output a user friendly error when we can't find a pod and update the docs to remind folks to install conduit first. Fixes #1070

* Wrap text, send to stderr, fail when missing
2018-06-06 16:44:28 -07:00
Eliza Weisman bd6b5d0944
proxy: Canonicalize TLS config paths before polling filesystem metadata (#1076)
This branch changes the polling-based implementation of TLS config file watches
to fully canonicalize the path to each config file prior to polling for its
metadata. Doing so fixes the issues detecting changes when the watched path is
a symbolic link to another symbolic link (see #1061), which is how Kubernetes
implements ConfigMaps mounted as volumes.

I've manually tested this with Conduit running in Docker for Mac Kubernetes,
by volume-mounting a ConfigMap containing the TLS config files, and 
regenerating, deleting, and adding the certificates. Watching the Conduit logs
confirms that the changes are now successfully detected.

Note that we have to re-canonicalize the path every time we poll the filesystem
for metadata. Otherwise, if the file is a symlink and the link target changes,
we will continue polling the _old_ link target's path, and fail to detect any
changes to the _new_ link target.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-06 13:43:17 -07:00
Brian Smith bbe35978be
Implement `dns::Name` using webpki's `DNSName`. (#1071)
webpki's DNSName type does full validation and normalization (lowercasing) of
DNS names, which is exactly what `dns::Name` does. webpki's DNSName type
considers a DNS name to be valid according to the rules for TLS certificates,
which is slightly stricter than what a DNS library might otherwise allow. In
anticipation of possible compatibility issues, introduce separate tls::DnsName
and dns::Name names for this type. In the future, if we find that tls::DnsName
is too strict for non-TLS cases, we can have these types diverge without
affecting TLS validation.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-05 14:23:08 -10:00
Sean McArthur 685e2219d3
proxy: update to released hyper 0.12 (#1069) 2018-06-05 17:05:10 -07:00
Brian Smith 0abb4830fd
Ensure Request IDs are unique & avoid `Arc`ing. (#1066)
Encapsulate HTTP request ID generation logic.

Request IDs need to be globally unique, so there can only be one request ID
sequence per process. Simplify the request ID generation with that in mind,
and make it more efficient.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-05 13:42:46 -10:00
Ivan Sim 11d1d55632 Filter out failed and completed pods from stats summary result (#1010) (#1065)
Both the conduit stat command and web UI are showing failed and completed pods.
This change filters out those pods before returning the result to the client.

Fixes #1010

Signed-off-by: Ivan Sim <ihcsim@gmail.com>
2018-06-05 13:19:48 -07:00
Brian Smith 51e230017e
Stop cloning & hashing HTTP requests & related types. (#1058)
During code review of another change I noticed that a lot of types seem
to derive `Hash` (and `Eq`, `PartialEq`) even though the types should
never (for performance reasons) be used as keys of a hash table, and
where it is kind of questionable what equality should mean for those
types. Then I noticed that similarly many types implement `Clone` even
though I expect we should never be cloning them, again because of our
performance goals.

Because these types derive these traits, then whenever we add a field
to them, that field also has to implement these traits. That means we
then have to expand the problem, deriving implementations of these
traits for types that don't otherwise want/need to implement these
traits. This makes review complicated, because, for example, we have
to decide whether something should be compared case-insensitively or
case-sensitively when really we don't want to compare those things at
all.

To prove that we can get by by doing less, to speed up code review
(particularly related to some stuff related to TLS), stop deriving
`Clone`, `Eq`, `PartialEq`, and `Hash` for these types.

I believe that, in particular, the change to key the Tap hash table
based on request ID, instead of the whole request, should speed up
the tap feature since we don't hash and/or compare every field,
recursively, of requests.

Later more such cleanup of this sort should be done.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-05 08:58:18 -10:00
Kevin Lingerfelt 4584637920
Upgrade web docker build base image to node:10 (#1068)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-05 11:52:01 -07:00
Risha Mars b7da30a293 Upgrade CI node and yarn to latest versions (#1067) 2018-06-05 10:22:07 -07:00
Eliza Weisman 4490db9909
proxy: Add TLS identity to endpoint metadata and wire it through to `Connect::new` (#1008)
Depends on #1006. Depends on #1041.

This PR adds a `tls_identity` field to the endpoint `Metadata` struct, which
contains the `TlsIdentity` metadata sent by the control plane's Destination
service. 

I changed the `ctx::transport::Client` context struct to hold a `Metadata`,
rather than just the labels, so the TLS support determination is always
available. In addition, I've added it as an additional parameter to 
`transport::Connect::new`, so that when we create a new connection, the TLS
code will be able to determine whether or not TLS is supported and, if it is, 
how to verify the endpoint's identity.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-04 20:08:55 -07:00
Risha Mars d5f684542a
Upgrade some of our postcss deps to their latest versions (#1059) 2018-06-04 17:28:07 -07:00
Kevin Lingerfelt eebc612d52
Add install flag for sending tls identity info to proxies (#1055)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-04 16:55:06 -07:00
Kevin Lingerfelt 6ef1204ceb
proxy-init: remove global vars, fix validation, add tests (#1062)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-04 16:43:57 -07:00
Kevin Lingerfelt c646185120
Validate all conduit deployments in stat test (#1048)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-04 16:43:42 -07:00
Oliver Gould 43c16f2407
Release v0.4.2 (#1063) 2018-06-04 15:37:04 -07:00
Eliza Weisman d5d610f542
proxy: Change `DEFAULT_OUTBOUND_ROUTER_CAPACITY` from 10,000 to 100 (#1060)
The proxy can't actually support 10K clients currently (for one, we can't open
10K resolution streams to the destination service). 100 is a more-realistic 
but sufficiently-high default.
2018-06-04 14:34:34 -07:00
Eliza Weisman 7220fb5367
proxy: Reload TLS config on changes (#1056)
This PR modifies the proxy's TLS code so that the TLS config files are reloaded
when any of them has changed (including if they did not previously exist).

If reloading the configs returns an error, we log an error and continue using
the old config.

Currently, this is implemented by polling the file system for the time they
were last modified at a fixed interval. However, I've implemented this so 
that the changes are passed around as a `Stream`, and that reloading and
updating the config is in a separate function the one that detects changes.
Therefore, it should be fairly easy to plug in support for `inotify` (and 
other FS watch APIs) later, as long as we can use them to generate a 
`Stream` of changes.

Closes #369 

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-04 13:36:28 -07:00
Kevin Lingerfelt ec2433e9bd
Update controller to use 'tls' metric label (#1044)
* Update controller to use 'tls' metric label
* Fix meshed column formatter

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-01 16:44:33 -07:00
Eliza Weisman b7a759cb64
proxy: Update `dns` module to use new Trust-DNS `AsyncResolver` API (#1032)
Depends on #974.  Closes #859.

This PR updates the proxy's `dns` module to use the new `AsyncResolver` API I
added to `trust-dns-resolver` in bluejekyll/trust-dns#487. This allows us to 
spawn one `Future` that will drive DNS resolution in the background, rather
than having to repeatedly clone a heavyweight `ResolverFuture` for every 
lookup. It also means that we no longer have to clone the name to resolve in
quite as many places.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-01 14:36:37 -07:00
Eliza Weisman cccebc2b26
proxy: Honor TTLs for DNS responses (#974)
Closes #711. Depends on #967.

This PR changes the proxy's `destination` module to honor the TTLs associated
with DNS lookups, now that bluejekyll/trust-dns#444 has been merged and we can
access this information from the Trust-DNS Resolver API. 

The `destination::background::DestinationSet` type has been modified so that, 
when a successful result is received for a DNS query, the DNS server will be 
polled again after the deadline associated with that query, rather than after
a fixed deadline. The fixed deadline is still used to determine when to poll
again for negative DNS responses or for errors.

Furthermore, Conduit now accepts an optional CONDUIT_PROXY_DNS_MIN_TTL 
environment variable that will configure a minimum TTL for DNS results. If the
deadline of a DNS response gives it a TTL shorter than the configured minimum,
Conduit will not poll DNS again until after that minimum TTL is elapsed. By
default, there is no minimum value set, as this feature is intended primarily
for when Conduit is run locally for development purposes.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-01 12:17:48 -07:00
Sean McArthur cb3bebe0ac
proxy: update h2 to cancel reset requests (#1051)
This includes the changes that should detect when a client sends a `RST_STREAM`, and cancels our pending response future or streaming body.

Closes #986
2018-06-01 02:53:21 +02:00
Brian Smith b114ef6819
Add initial infrastructure for optionally accepting TLS connections (#1047)
* Add initial infrastructure for optinally accepting TLS connections.

If the environment gives us the paths to the certificate chain and private key
then use TLS for all accepted TCP connections. Otherwise, continue on using
plaintext for all accepted TCP connections. The default behavior--no TLS--isn't
changed.

Later we'll make this smarter by adding protocol detection so that when the TLS
configuration is available, we'll accept both TLS and non-TLS connections.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-05-31 12:20:57 -10:00
Kevin Lingerfelt 8b519fb92f
web: Update service mesh overview to include grafana (#1049)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-05-31 14:51:42 -07:00
Kevin Lingerfelt f344421dbd
Web: remove ns column from tables on individual ns page (#1043)
* Web: remove ns column from tables on individual ns page
* Add prop types and tests for MetricsTable component

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-05-31 14:07:33 -07:00
Eliza Weisman 5a42ce357e
proto: Add TLS identity to WeightedAddr message (#1041)
Required for #1008.

This PR adds the `TlsIdentity` message to the Destination service proto,
to describe what strategy the proxy should use for verifying an endpoint's TLS
certificates. It also adds a `TlsIdentity` field to the `WeightedAddr` message.

Currently, there is one possible variant for `TlsIdentity`, `KubernetesPodName`, 
which consists of the Kubernetes pod name of the endpoint, the namespace of
the endpoint, and the namespace of that pod's Conduit control plane. The proxy
should attempt to connect over TLS if the control plane namespace matches its 
own control plane namespace. The pod name and namespace are used to verify 
the endpoint's TLS certificate.

See https://github.com/runconduit/conduit/issues/386#issuecomment-392948046.

This change was initially part of #1008, but I factored it out to make the diff
smaller.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-05-31 11:48:25 -07:00
Thomas Rampelberg 1bcd428680
Add propType validation (#993)
* Add propType validation

When refactoring components, it is hard to know what is required and isn't.

Adds propTypes to the existing components and enables eslint errors for anything
moving forward. This should keep us documenting the API for components.

* Remove extra newline
2018-05-30 17:26:05 -07:00
Eliza Weisman 9dd1a1419b
Add protobuf files to .editorconfig (#1042)
This PR adds an editorconfig rule for `.proto` files indicating that they
should be indented with two spaces. This will prevent problems like
https://github.com/runconduit/conduit/pull/1041#discussion_r191930197
from happening again.
2018-05-30 15:09:38 -07:00
Oliver Gould 294de5b3c4
proxy: Add rich logging contexts (#1037)
While debugging proxy issues, I found it necessary to change how logging contexts are
instrumented, especially for clients.

This change moves away from using `Debug` types to in favor of `Display` types.
Furthermore, the `logging` module now provides a uniform set of logging contexts to be
used throughout the application.  All clients, servers, and background tasks should now be
instrumented so that their log messages contain predictable metadata.

Some small improvements have been made to ensure that logging contexts are correct
when a `Future` is dropped (which is important for some H2 uses, especially).
2018-05-30 13:41:59 -07:00
Oliver Gould db2478f5a2
proxy: Fix bench tests and require bench tests in CI (#1038)
b3170af changed the DstLabels api, but the bench test was not updated
accordingly.

Furthermore, since bench tests require a nightly rust version, we've
avoided running them in CI. This makes it easy for these tests to break, however.

This updates the benches/record.rs. Additionally, in CI, we pin the rust nightly'
version to a known-good version so that we can reliably run these bench test
without the fear of external changes breaking our build.
2018-05-30 07:20:28 -07:00
Oliver Gould 22719a2898
proxy: Ensure labels are reliably ordered (#1030)
The proxy receives a hash map of endpoint labels from the destination
service. As this map is serialized into a string, its keys and values
do not have a stable ordering.

To fix this, we sort the keys for all labels before constructing an
instance of `DstLabels`.

This change was much more difficult to test than it was to fix, so tests
this change was tested manually.

Fixes #1015
2018-05-30 07:13:26 -07:00
Kevin Lingerfelt 423a073930
Update eslint config to extend more default rules (#1035)
* Update eslint config to extend more default rules
* react/no-unused-state rule doesn't recognize _.pick(this.state, ...)

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-05-29 18:23:13 -07:00
Kim Christensen 8cc6eea6a5 Don't show namespace filter on the namespace page (#1026)
On the individual namespace pages, the filter should not be shown, as all results that appear on the that page will be for on namespace.

Added a boolean property, showNamespaceFilter, to MetricsTable that allows you to define if the filter should be shown.

Tested that the filter is not shown on namespace pages.

Fixes #972

Signed-off-by: Kim Christensen <kimworking@gmail.com>
2018-05-29 17:23:49 -07:00
Thomas Rampelberg 6386b832a6
Wrap withREST in context for api reference (#1036)
As part of the HOC + Context merges, ResourceList missed out on the api injection and errors out on the Namespaces tab.

Wrap the returned HOC in `withContext` to make sure it is there, no matter where it is in the tree. (Fixes #1034)
2018-05-29 17:11:40 -07:00