Commit Graph

715 Commits

Author SHA1 Message Date
Risha Mars 5963b2ac24
Better format empty errors (#1202) 2018-06-28 14:52:04 -07:00
Risha Mars 68586fe697
Add the ability to query stats by authority (#1181)
Adds the ability to query by a new non-kubernetes resource type, "authorities",
in the StatSummary api.

This includes an extensive refactor of stat_summary.go to deal with non-kubernetes 
resource types.

- Add documentation to Resource in the public api so we can use it for authority
- Handle non-k8s resource requests in the StatSummary endpoint
- Rewrite stat summary fetching and parsing to handle non-k8s resources
- keys stat summary metric handling by Resource instead of a generated string
- Adds authority to the CLI
- Adds /authorities to the Web UI
- Adds some more stat integration and unit tests
2018-06-28 14:31:44 -07:00
Kevin Lingerfelt ef9c890505 Fix issue with injected resource name, add test (#1226)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-28 10:23:38 -10:00
Oliver Gould 9f274526d6
cli: tap: Use safe accessors (#1224)
The `tap` command is prone to panic due to use of `nil` values.
This is  because we don't use the safe `Get*()` field accessors
provided by protobuf.

This change fixes several unsafe field access paths.

Fixes #47
2018-06-28 11:10:56 -07:00
Thomas Rampelberg fafce1b8b3
Add important comment back (#1219) 2018-06-28 08:18:52 -07:00
Brian Smith afbc88ac44
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 cca8e7077d
Add TLS support to `conduit inject`. (#1220)
* Add TLS support to `conduit inject`.

Add the settings needed to enable TLs when `--tls=optional` is passed on the
commend line. Later the requirement to add `--tls` will be removed.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-06-27 16:04:07 -10:00
Kevin Lingerfelt f502596577
Update go bindings for destination.proto change (#1223)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-27 18:26:13 -07:00
Brian Smith 06d3c09ca5
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 06d0209d0b
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
Thomas Rampelberg 97868f654f
Add Pod to injectable types (#1213)
* Add Pod to injectable types

* Remove the pod label for pods
2018-06-27 14:37:05 -07:00
Kevin Lingerfelt b8ba627ee5
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
Kevin Lingerfelt d265e8d942
Add integration tests for pod and service stats (#1214)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-27 10:19:52 -07:00
Risha Mars 15718de2de
Change the icon for Documentation in the sidebar (#1211) 2018-06-26 17:00:21 -07:00
Andrew Seigner e70d62dc9f
Introduce Proxy process telemetry in Grafana (#1199)
PR #1128 introduced new proxy process stats.

Introduce Grafana graphs that expose these new proxy process stats.

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
2018-06-27 00:58:28 +01:00
Eliza Weisman 5bba831f9b
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 e3d61c9a70
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 ace187d7e7
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 f44a59da33
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
Sean McArthur ff8ec8abe0
proxy: update Rust compiler to 1.27.0 (#1207)
Signed-off-by: Sean McArthur <sean@seanmonstar.com>
2018-06-26 13:12:17 -07:00
Franziska von der Goltz 7ee56b0177
update TEST.md to reflect changes in testing: (#1193)
- the current test setup requires a NODE_ENV variable to be set for the tests to work, that is not yet documented. Following the test docs will cause the tests to fail.
- The env is set either thorugh a test script that was added or manually setting.
- This commit addresses the documentation fix

Signed-off-by: Franziska von der Goltz <franziska@vdgoltz.eu>
2018-06-26 10:00:40 -07:00
Brian Smith 75034ef09d
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 140f246624
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 c204441ecb
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
Risha Mars 269714ab35
Re-add sidebar links to individual resource pages (#1191)
Add Sidebar links to Pods, Deployments, and Replication Controllers

In #1016 we removed the sidebar links to individual resource pages in favour of a namespace
page that lists all resources. These resource pages require no additional code so they're still 
in our UI (accessible under /pods, /deployments etc), just not easily findable. I find them 
useful to check when in development mode, or when debugging something, so I'd like to 
re-add links.

If we don't want them in permanently, we can gate them behind `NODE_ENV=development`
2018-06-25 14:37:16 -07:00
Eliza Weisman 8a513af862
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 8b0b681ee6
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 31c753aafc
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 4678cf7159
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
Kevin Lingerfelt 1f1968ad4d
Add --registry flag support for inject command (#1188)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-22 12:52:42 -07:00
Brian Smith a04a289f90
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 2f0ad66257
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 aee845e40f
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
Kevin Lingerfelt 5cf8ab00df
Switch to multi-value --tls flag, add to inject (#1182)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-21 15:52:14 -07:00
Oliver Gould 44d7ee06ca
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
Andrew Seigner c4d570aa26
Revert usage of parallel in docker-build (#1183)
PR #978 introduced usage of parallel in docker-build. Unfortunately this
breaks if the system has non-GNU parallel.

Remove usage of parallel until we can do at least one of the following:
- detect version of parallel installed
- make usage of parallel optional and off by default
- confirm this speeds up builds for a majority of use cases

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
2018-06-21 23:13:29 +01:00
Kevin Lingerfelt af85d1714f
Add probes and log termination policy for distributor (#1178)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-21 14:02:41 -07:00
Kevin Lingerfelt 12f869e7fc
Add CA certificate bundle distributor to conduit install (#675)
* Add CA certificate bundle distributor to conduit install
* Update ca-distributor to use shared informers
* Only install CA distributor when --enable-tls flag is set
* Only copy CA bundle into namespaces where inject pods have the same controller
* Update API config to only watch pods and configmaps
* Address review feedback

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-21 13:12:21 -07:00
Oliver Gould 5f7067c864
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
Kevin Lingerfelt e80356de34
Upgrade prometheus to v2.3.1 (#1174)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-21 11:02:21 -07:00
Brian Smith bc6eb34469
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
Eliza Weisman 9bf1e60a61 bin: Remove unused script (#1153)
Committed in error.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2018-06-20 18:01:14 -07:00
Kevin Lingerfelt 682b0274b5
Add controller admin servers and readiness probes (#1168)
* Add controller admin servers and readiness probes
* Tweak readiness probes to be more sane
* Refactor based on review feedback

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-20 17:32:44 -07:00
Sean McArthur c52385dd42
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 8dcb95d39f
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
Thomas Rampelberg ad659874bd
Enable optional parallel build of docker images (#978)
* Enable optional parallel build of docker images

By default, docker does image builds in a single thread. For our containers, this is a little slow on my system. Using `parallel` allows for *optional* improvements in speed there.

Before: 41s
After: 22s

* Move parallel help text to stderr
2018-06-20 15:57:29 -07:00
Risha Mars 0ff1bb4ad8
Don't allow stat requests for named resources in --all-namespaces (#1163)
Don't allow the CLI or Web UI to request named resources if --all-namespaces is used.

This follows kubectl, which also does not allow requesting named resources
over all namespaces.

This PR also updates the Web API's behaviour to be in line with the CLI's. 
Both will now default to the default namespace if no namespace is specified.
2018-06-20 12:59:31 -07:00
Brian Smith 33ff1a33ab
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 8ece9c4508
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
Kevin Lingerfelt 9bfd8898e0
Fix dashboard integration test (#1160)
Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
2018-06-19 17:01:47 -07:00