Commit Graph

168 Commits

Author SHA1 Message Date
Alfonso Acosta
7ca8749b18 Enable eBPF tracking by default 2017-05-31 10:04:52 +00:00
Alban Crequy
d715ccc391 ebpf: handle fd_install events from tcptracer-bpf
Since https://github.com/weaveworks/tcptracer-bpf/pull/39, tcptracer-bpf
can generate "fd_install" events when a process installs a new file
descriptor in its fd table. Those events must be requested explicitely
on a per-pid basis with tracer.AddFdInstallWatcher(pid).

This is useful to know about "accept" events that would otherwise be
missed because kretprobes are not triggered for functions that were
called before the installation of the kretprobe.

This patch find all the processes that are currently blocked on an
accept() syscall during the EbpfTracker initialization.
feedInitialConnections() will use tracer.AddFdInstallWatcher() to
subscribe to fd_install  events. When a fd_install event is received,
synthesise an accept event with the connection tuple and the network
namespace (from /proc).
2017-05-19 14:49:38 +02:00
Matthias Radestock
bf02eb0cc7 fix typos in usage info 2017-05-16 09:15:42 +01:00
Bryan Boreham
0281d4aeef Fix typo 2017-04-23 16:58:15 +00:00
Matthias Radestock
413dbc7f0c allow disabling of weaveDNS advertising/lookup
...while keeping other weave integrations, by setting
--weave.hostname=

Addresses a suggestion in #1550.
2017-04-15 00:02:07 +01:00
Paul Bellamy
e68ffd467e Add app/multitenant/billing_emitter to emit billing events 2017-03-22 10:41:34 +00:00
Alfonso Acosta
3431d64f77 Adapt middleware logger to upstream changes 2017-03-21 15:20:17 +00:00
Michael Schubert
22ae6c45a0 Implement ebpf proc fallback 2017-03-14 13:59:09 +01:00
Iago López Galeiras
9920c4ea48 Add eBPF connection tracking without dependencies on kernel headers
Based on work from Lorenzo, updated by Iago, Alban, Alessandro and
Michael.

This PR adds connection tracking using eBPF. This feature is not enabled by default.
For now, you can enable it by launching scope with the following command:

```
sudo ./scope launch --probe.ebpf.connections=true
```

This patch allows scope to get notified of every connection event,
without relying on the parsing of /proc/$pid/net/tcp{,6} and
/proc/$pid/fd/*, and therefore improve performance.

We vendor https://github.com/iovisor/gobpf in Scope to load the
pre-compiled ebpf program and https://github.com/weaveworks/tcptracer-bpf
to guess the offsets of the structures we need in the kernel. In this
way we don't need a different pre-compiled ebpf object file per kernel.
The pre-compiled ebpf program is included in the vendoring of
tcptracer-bpf.

The ebpf program uses kprobes/kretprobes on the following kernel functions:
- tcp_v4_connect
- tcp_v6_connect
- tcp_set_state
- inet_csk_accept
- tcp_close

It generates "connect", "accept" and "close" events containing the
connection tuple but also pid and netns.
Note: the IPv6 events are not supported in Scope and thus not passed on.

probe/endpoint/ebpf.go maintains the list of connections. Similarly to
conntrack, it also keeps the dead connections for one iteration in order
to report short-lived connections.

The code for parsing /proc/$pid/net/tcp{,6} and /proc/$pid/fd/* is still
there and still used at start-up because eBPF only brings us the events
and not the initial state. However, the /proc parsing for the initial
state is now done in foreground instead of background, via
newForegroundReader().

NAT resolution on connections from eBPF works in the same way as it did
on connections from /proc: by using conntrack. One of the two conntrack
instances is only started to get the initial state and then it is
stopped since eBPF detects short-lived connections.

The Scope Docker image size comparison:
- weaveworks/scope in current master:  22 MB (compressed),  68 MB
  (uncompressed)
- weaveworks/scope with this patchset: 23 MB (compressed), 69 MB
  (uncompressed)

Fixes #1168 (walking /proc to obtain connections is very expensive)

Fixes #1260 (Short-lived connections not tracked for containers in
shared networking namespaces)

Fixes #1962 (Port ebpf tracker to Go)

Fixes #1961 (Remove runtime kernel header dependency from ebpf tracker)
2017-03-08 22:11:12 +01:00
Alfonso Acosta
052ff39bf1 Merge pull request #2309 from weaveworks/2258-fix-kubelet-access
Fix kubelet failure fallback and make port configurable
2017-03-08 10:15:21 -08:00
Alfonso Acosta
8bf753a51b Revert "Revert "Add options to hide args and env vars (#2306)"" (#2311)
* Revert "Revert "Add options to hide args and env vars (#2306)""

* Make linter happy
2017-03-08 02:16:42 -08:00
Alfonso Acosta
dcc7389127 Revert "Add options to hide args and env vars (#2306)"
This reverts commit 764afb6301.
2017-03-07 17:51:27 +01:00
Mike Bryant
764afb6301 Add options to hide args and env vars (#2306)
* Add options to hide args and env vars

To allow for use of weave-scope in an unauthenticated environment,
add options to the probe to hide comand line arguments and
environment variables, which might contain secret data.

Fixes #2222

* Change docker.NewRegistry arguments to be a struct

* Remove redundant declarations of default values

* Move registry options outside to improve readability
2017-03-07 08:51:18 -08:00
Alfonso Acosta
c1fa5bb665 Fix kubelet failure fallback and make port configurable 2017-03-07 13:29:02 +00:00
Matthias Radestock
a391ae8a3d Merge pull request #2301 from weaveworks/report-playback
report playback
2017-03-05 13:03:53 +00:00
Matthias Radestock
289b4c63af report playback
Now you can launch the scope app with something like

./prog/scope --mode=app --weave=false --app.collector=file:///tmp/reports

and if the specified dir contains reports with filenames in the form
<timestamp>.{msgpack|json}[.gz],
e.g. "1488557088545489008.msgpack.gz", then these reports are replayed
in a loop at a sequence and speed determined by the timestamps.
2017-03-04 22:04:50 +00:00
Matthias Radestock
df41a808c2 parse probe-only flag as intended 2017-03-04 11:22:00 +00:00
Mike Lang
ed19e7a34b Merge pull request #2197 from weaveworks/mike/ecs/scale-controls
Add ECS Service scale up/down controls
2017-02-21 11:03:01 -08:00
Alfonso Acosta
eb4027a97c Reintroduce probe checkpoint flags for kernel version and OS
Removed unintentionally in https://github.com/weaveworks/scope/pull/2148
2017-02-09 17:29:15 +00:00
Mike Lang
7d58e6a9c3 awsecs: Add dummy scale up and scale down controls for services
These controls do nothing for now, this was just to get the control buttons working
2017-02-07 14:57:31 -08:00
Mike Lang
dee274e438 Merge pull request #2065 from weaveworks/mike/ecs/caching
ECS reporter: Minimize API calls by caching task and service data
2017-01-24 11:03:51 -08:00
Iago López Galeiras
f0d9876258 probe: refactor probeMain 2017-01-23 12:11:35 +01:00
Mike Lang
685af493bf ecs probe: Allow cache settings to be tweaked 2017-01-12 11:37:23 -08:00
Alfonso Acosta
ab28a0bfac Fix linter errors in ignored file 2016-12-22 11:12:16 +00:00
Alfonso Acosta
a2d09b4c23 Run gofmt (file was ignored by linter) 2016-12-22 10:04:35 +00:00
Alfonso Acosta
bae1533b12 Add comment regarding loopback address hardcoding 2016-12-21 10:10:00 +00:00
Alfonso Acosta
8b45525305 Hardcode 127.0.0.1 as loopback IP for default target 2016-12-20 11:18:13 +00:00
Alfonso Acosta
06ff64d477 Forward OS/Kernel version to checkpoint
Useful to prioritize ebpf testing

Also:
* Make treatment of kernel release and version consistent across Darwin/Linux
2016-12-19 20:08:08 +00:00
Michael Schubert
3f969f20f2 prog/main: use flags.app.port for default target
User can control the webserver listen address with `-app.http.address`.
If they do, `scope --mode probe ...` should use the port part of address
in the default target and not ':4040'. Otherwise we encounter a
`dial tcp 127.0.0.1:4040: getsockopt: connection refused` error and
`scope-probe` cannot report.

Signed-off-by: Michael Schubert <michael@kinvolk.io>
2016-12-16 17:15:03 +01:00
Mike Lang
7d845f9130 ecs reporter: Review feedback, some trivial renames 2016-12-15 14:11:58 -08:00
Mike Lang
9d1e46f81b ECS reporter: Use persistent client objects across reports
Not only does this allow us to re-use connections, but vitally it allows us
to make use of the new task and service caching within the client object.
2016-12-15 14:11:57 -08:00
Jonathan Lange
626e8a3e9f Neater way of doing it 2016-12-12 17:40:15 +00:00
Jonathan Lange
4fcf9a1e36 Add flag for logging headers 2016-12-12 17:12:28 +00:00
Jonathan Lange
e8085b01b6 Use 'common' library 2016-12-07 11:22:38 +00:00
Mike Lang
d0caee4748 Add some basic metadata to the ECS task/service details panels 2016-11-29 07:18:08 -08:00
Mike Lang
b06fee8c0f Review feedback 2016-11-29 07:18:08 -08:00
Alfonso Acosta
ab1d2d2c6d Add checkpoint flag for ECS 2016-11-29 07:18:08 -08:00
Mike Lang
88499b4e9d Add --probe.ecs flag to enable running the ECS probe tagger 2016-11-29 07:17:16 -08:00
CarltonSemple
a5859ba218 Addressed final comments 2016-11-15 22:18:55 +00:00
CarltonSemple
9833a854b1 Added container filters as CLI arguments
gofmt load_container_filters.go

removed the environment variable for container label filters

Added the --app.container-label-filter command line argument, and load_container_filters.go now uses the results from that

Changed init() to InitializeTopologies()

Changed init() to InitializeTopologies() so that it can be called after the container filters are loaded from the command line argument. init() executes before main() in prog/main.go, so the flag parsing isn't finished before init() is called

Applied lint fixes

fixed lint issues

brought back the init function for api_topologies.go

Addressed many of the PR comments, except escaping colons

Renamed IsDesired to HasLabel in render/filters.go

Allows for the user to escape colons

added registry function for modifying the container filters

created a separate function that parses the container filter flags

simplified registry.addContainerFilters()

addressed review comments

switched API Topology Description IDs to constants

addressed review comments

joined constants

added test functions

addressed most of the review comments

Changed containerLabelFilters to an array of APItopologyOptions, placing the parsing in the Set() function. Removed parsing from HasLabel in render/filters.go

refactored code

added test that applies to the container filtering by labels

applied golint

made Registry items private and added a MakeRegistry() function

fixed usage of topologyRegistry.RendererForTopology

Added container label filters by exclusion

minor update to report_fixture

Modified container labels test to use existing report

I added labels to the existing containers in the fixed report for testing.

refactored code

refactored code

further code refactoring

addressed @ijsnellf's review comments

unexported Registry, and reduced duplicate code

addressed @ijsnellf's review comments

Addressed review comments

Addressed final review comments
2016-11-15 19:13:35 +00:00
Alfonso Acosta
3ba83ddd53 Merge pull request #1973 from weaveworks/1938-enrich-weave-details-panel
Extend metadata in details panel for Weave Net nodes
2016-11-04 09:44:27 +01:00
Alfonso Acosta
0884955c95 Extend metadata in details panel for Weave Net nodes 2016-11-03 15:57:23 +00:00
Mike Lang
03661f309a Merge pull request #1917 from weaveworks/1916-dont-leak-goroutines
Timeout reads and writes in the http server.
2016-11-02 15:25:55 -07:00
Tom Wilkie
e8126faedd Review feedback 2016-10-12 17:29:29 +01:00
Tom Wilkie
7d88279758 Add prometheus metrics endpoint to probes. (#1915) 2016-10-10 14:30:34 -07:00
Tom Wilkie
0bde1b62e1 Timeout reads and writes in the http server. 2016-10-10 14:22:18 -07:00
Tom Wilkie
727404c9b8 Extend logging middleware to optionally only log failed HTTP requests (#1909)
* Extend logging middleware to optionally only log failed HTTP requests

* Add a preconfigured logger for logging failed requests, use it in the app.

* Wide definition of success
2016-10-07 18:03:36 -07:00
Mike Lang
ec37214778 Add flag to allow using external ui, and ability to upload to bucket during CI 2016-10-05 17:27:18 -07:00
Mike Lang
2c9f6c197f Split prog/static.go into two versions, and have a shim choose between them
This allows us to have both normal and external resource versions of static content
in the same binary, and switch with a flag
2016-10-05 17:26:57 -07:00
Tom Wilkie
2a00fd2d78 Allow user to specify URLs on the command line, and use that to allow per-target tokens. (#1901)
Also:
- Parse targets on startup and catch badly formed ones before Scope can start.
- If no port is specified, use default port for scheme; if no scheme is specificed, use 4040.
- Use username as probe token
2016-10-05 10:59:56 -07:00