105 Commits

Author SHA1 Message Date
Bryan Boreham
c86021ec05 Stop shellcheck warning on 'echo -v'
Non-portability is unlikely to be a problem
2021-01-30 15:37:56 +00:00
Bryan Boreham
9aa9b1ae70 Merge pull request #3797 from weaveworks/update-build-tools
Update build tools
2021-01-18 10:50:31 +00:00
Bryan Boreham
5c09ebac54 Fix Mac probe launch command
Paren in wrong place meant it was running the app and not getting any extra args
2021-01-01 11:54:40 +00:00
Bryan Boreham
b438707a92 Clean up lint errors in shell scripts 2020-12-30 18:30:34 +00:00
Bryan Boreham
4f713984f2 Only mount plugins directory if it exists
This gets over problem with Docker for Mac where /var/run is read-only
2020-12-29 15:44:06 +00:00
Bryan Boreham
7f0334d07b Fix typo in comment 2018-08-10 13:11:55 +00:00
Daniel Holbach
f8f3b3dc2d Minimal fix to make scope start with Docker for Mac again.
@dglaubman found that recent versions of Docker for Mac (Docker version
18.03.0-ce, build 0520e24) don't write out
${HOME}/Library/Containers/com.docker.docker/Data/database any more.

@foot confirmed this. A fresh installation of Docker for Mac (Version
18.03.0-ce-mac60 (23751), Channel: stable) did not create the file.

The result was that installations which had this leftover file could start
scope, whereas newer couldn't. The fix simply changes this check to a path
which actually exists.

Thanks @dglaubman and @foot for the analysis and confirmation.

Fixes #3064
2018-04-13 08:17:23 +02:00
Alfonso Acosta
4be194d236 Small refactoring leftover from 2017-08-15 12:36:43 +00:00
Alfonso Acosta
425033df20 Make sh linter happy 2017-08-14 14:36:02 +00:00
Alfonso Acosta
6b2623b619 Make Scope's URL message more precise 2017-08-14 13:50:21 +00:00
Matthias Radestock
86c9544066 remove superfluous shellchecks 2017-07-14 10:59:27 +01:00
Matthias Radestock
bf8b28ca12 no need to pass CHECKPOINT_DISABLE when not starting probe/app 2017-07-14 10:59:27 +01:00
Matthias Radestock
e19c33b4c2 only pass WEAVESCOPE_DOCKER_ARGS to actual probe/app start
and not all the help, version, etc, etc docker runs.

In particular this allows passing `--restart=...` in
WEAVESCOPE_DOCKER_ARGS. Previously that would break since the
non-probe/app docker runs supply `--rm` (as they should) which is
incompatible with restart settings.
2017-07-14 10:59:26 +01:00
jjqq
8fa771e7d4 fix error when docker DAEMON is running with user namespace enabled.
1:mkdir: can't create directory '/var/run/scope/': Permission denied
2017-06-12 17:55:58 +09:00
Mike Lang
b51385d5f1 scope script: Allow 'user' part of image name to be given by DOCKERHUB_USER env var
This allows alternate scope images to be used, and mirrors the option available for weave net.
2017-04-16 19:46:03 -07:00
Matthias Radestock
bb36067e41 don't lie about reachable address
when app.http.address is specified. Instead just tell the user that
scope is reachable where they said.

Also, complain when the address is specified on D4M since there are
a bunch of hard-coded port 4040 in place for that.

Fixes #1190.
2017-04-14 02:09:03 +01:00
jpellizzari
95c2405b30 Changed --dry-run command to execute after OSX setup 2017-03-20 17:44:38 -07:00
Michael Schubert
5f85256055 scope: use same Docker args for early dry run
`launch` first does a `scope --dry-run` to parse and validate Scope
cmdline arguments before starting the main Scope container and
processes. Use the same Docker args for the dry run to make sure the
container has the same privileges and mount points. Otherwise valid
`$WEAVESCOPE_DOCKER_ARGS` might fail here.
2017-03-14 09:51:11 +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
051884d26a Embed Docker 1.13.1 (but force protocol 1.22) 2017-02-24 13:50:19 +00:00
Alfonso Acosta
0922253cb1 Fix typo 2017-02-03 16:13:17 +01:00
Alfonso Acosta
92c4bc968c Embed and require Docker version 1.10 2017-02-03 14:26:58 +00:00
Alfonso Acosta
36da3cd4e5 Initialize USERNS_HOST variable 2017-02-01 14:47:32 +00:00
q
c9174bb159 fix error when docker DAEMON is running with user namespace enabled.
1:"Privileged mode is incompatible with user namespaces".
2:"Cannot share the host's network namespace when user namespaces are enabled".
2017-01-31 11:23:58 +09:00
Alban Crequy
3d2291093c scope: fix URL
Symptoms: the Scope URL are printed this way:

```
Weave Scope is reachable at the following URL(s):
  * http://10.2.2.1
172.16.28.1
172.16.28.1
192.168.99.1
192.168.35.117
172.16.28.1
172.16.28.1
192.168.122.1:4040/
```

Regression from https://github.com/weaveworks/scope/pull/2068
2017-01-30 14:39:31 +01:00
Iago López Galeiras
5cb5c7d42e Fix shfmt issues 2017-01-18 11:51:41 +01:00
Iago López Galeiras
43d9f38c5e Fix various linter issues
Found via shellcheck.
2017-01-18 11:51:41 +01:00
Michael Schubert
c3bd60b544 scope launcher script: allow setting SCOPE{_APP,}_CONTAINER_NAME
Helpful when you want to run multiple instances of scope on your system,
e.g. for testing.

Signed-off-by: Michael Schubert <michael@kinvolk.io>
2016-12-19 11:12:28 +01:00
Simon Howe
71e04a27ba Fixes ./scope launch starting probe under d4m 2016-12-15 15:26:20 +01:00
Mike Lang
2562567de4 scope launch script: Don't try to detect if listing scope binary args worked
We can't easily do this since scope exits failure when -h is passed, so we
can't distinugish between success and failure.
2016-12-12 11:26:01 -08:00
Mike Lang
3000adfb9a scope launch script: Don't print container id
It's not useful and it's confusing.
Replaced with a generic "it worked" message.
2016-12-12 11:26:01 -08:00
Mike Lang
7333b99b89 scope launch script: Make the default port clear 2016-12-12 11:26:01 -08:00
Mike Lang
0e4e95e4fa scope launch script: Edit help text to make positional args clearer 2016-12-12 11:26:01 -08:00
Mike Lang
3a69c19d6e scope launch script: Also recongize -h, -help and --help 2016-12-12 11:26:01 -08:00
Mike Lang
90709b61aa scope launch script: Fix and consolidate usage info
Instead of different usage info for "scope help", show the same always.
Also correct it for what the script actually does,
and always display the scope binary args.
2016-12-12 11:26:01 -08:00
Mike Lang
b1a1c7d427 scope launch script: Attempt to quote args in "scope command"
As indicated by the TODO, any args passed into the command do not get escaped
when output, so for example:
	scope command "foo bar"
would output results like:
	foo bar
instead of
	"foo bar"
or
	foo\ bar

The "right" way to do this seems to be printf %q, which prints a quoted version of the string.
However this format specifier is not available in POSIX sh (though it does work in many
implementations of it, such as the ones provided by bash which make up the likely majority of
real-world usage).
This code is a compromise that uses the added functionality where available,
while still falling back to the old behaviour when it isn't.
2016-12-12 11:26:00 -08:00
Mike Lang
21431bb4b0 scope launch script: Fix shellcheck linter warnings
By far the majority of these were variables which were not quoted.
While, yes, right now we can guarentee most of these variables will never contain spaces,
this could someday change and applying quoting as a universal rule prevents future mistakes.

The ARGS="$@" -> "$*" change is purely stylistic and mainly is used to indicate the intent that
we actually wanted to concatenate all the args by spaces, not keep them seperated as "$@" would
in many situations, but not this one.

Several warnings remain, in places where we intentionally want to split a variable on whitespace,
or otherwise do what shellcheck is warning us against.

Of note is shellcheck warning SC2166, which says to prefer [ foo ] || [ bar ] over [ foo -o bar ]
as the -a and -o flags have differing behaviour on some systems.
I've opted to keep these for now, since the version check test command would need to be replaced by
a LOT of subshells to achieve the same effect, which feels dirtier.
2016-12-12 11:26:00 -08:00
Alfonso Acosta
f7c0b75eff Quote properly 2016-10-31 19:29:05 +00:00
Alfonso Acosta
5433c256c7 Fix argument escaping in Scope
By naively using echo and cat to print to serialize/deserealize arguments we were garbling
arguments with special characters and whitespaces
2016-10-25 15:35:48 +00:00
Alessandro Puccetti
5b67adc137 scope: fix stop command for OSX
Before this patch, `scope stop` was not stopping scope-app
2016-08-17 14:09:58 +02:00
Alfonso Acosta
0a1232ec3c Don't complain when stopping Scope if it wasn't running 2016-08-11 15:21:06 +00:00
Mike Lang
7aec1e172d launcher script: Fix inconsistent whitespace 2016-08-09 09:57:12 -07:00
Alfonso Acosta
9740fcca40 Merge pull request #1765 from weaveworks/release-0.16
Release 0.16.2
2016-08-05 16:38:43 +01:00
Ilya Dmitrichenko
d7c40827c8 Docker for Mac 1.12 has only one network mode (close #1755) 2016-08-05 15:06:07 +01:00
Matthias Radestock
1ffdafdf8c cosmetic: remove trailing whitespace 2016-07-27 08:27:18 +01:00
Ilya Dmitrichenko
70b3f32e9c Check if app and probe are running first (fix #1679) 2016-07-14 14:47:33 +01:00
Alfonso Acosta
5c3ac511bc Use exit instead of return 2016-07-13 16:43:58 +00:00
Alfonso Acosta
93c4e4537b Review feedback 2016-07-13 14:25:57 +00:00
Alfonso Acosta
7367b60428 Review feedback 2016-07-13 14:23:28 +00:00
Alfonso Acosta
95a45f991d Review feedback 2016-07-13 14:17:04 +00:00