25 Commits

Author SHA1 Message Date
Bryan Boreham
a47cf0a2aa Remove copying Merge() on Report
It was only used in a few places, and all of those were better off
using the Unsafe variant.
2020-03-06 15:03:43 +00:00
Bryan Boreham
c88be40b19 performance: Update plugins to new-style controls data 2019-11-26 11:29:42 +00:00
Marc Carré
2ba50b8b3d Update golang.org/x/net/context to latest
```
$ gvt delete golang.org/x/net/context
$ gvt fetch golang.org/x/net/context
2018/07/23 18:03:49 Fetching: golang.org/x/net/context
$ git grep -l "golang.org/x/net/context" | grep -v vendor | xargs sed -i '' 's:golang.org/x/net/context:context:g'
$ git grep -l "context/ctxhttp" | grep -v vendor | xargs sed -i '' 's:context/ctxhttp:golang.org/x/net/context/ctxhttp:g'
$ gofmt -s -w app
$ gofmt -s -w common
$ gofmt -s -w probe
$ gofmt -s -w prog
$ gofmt -s -w tools
```
fixed a bunch of:
```
cannot use func literal (type func("github.com/weaveworks/scope/vendor/golang.org/x/net/context".Context) error) as type func("context".Context) error
```
2018-07-23 20:10:18 +02:00
Marc Carré
d46c2266ce Change Sirupsen/logrus to sirupsen/logrus
```
$ git grep -l Sirupsen | grep -v vendor | xargs sed -i '' 's:github.com/Sirupsen/logrus:github.com/sirupsen/logrus:g'
$ gofmt -s -w app
$ gofmt -s -w common
$ gofmt -s -w probe
$ gofmt -s -w prog
$ gofmt -s -w tools
```
2018-07-23 20:10:14 +02:00
Matthias Radestock
5b30b668ae refactor: don't return receiver in Topology.AddNode()
This had little use and was obscuring the mutating nature of
AddNode().
2018-02-19 05:10:04 +00:00
Matthias Radestock
e2eef50cda eliminate (out-of-date) list of topologies in plugin code 2017-12-24 22:27:02 +00:00
Jonathan Lange
1020fc5f85 Use test.Diff from common 2016-12-07 11:22:40 +00:00
Jonathan Lange
b5c750ddea Move test & fs 2016-12-07 11:22:39 +00:00
Jonathan Lange
e8085b01b6 Use 'common' library 2016-12-07 11:22:38 +00:00
Krzesimir Nowak
9e092f1a4a Switch to LatestMap-style node controls
This allows plugins to add controls to nodes that already have some
controls set by other plugin. Previously only the last plugin that
sets the controls in the node would have its controls visible. That
was because of NodeControls' Merge function that actually weren't
merging data from two inputs, but rather returning data that was newer
and discarding the older one.
2016-08-12 17:15:43 +02:00
Krzesimir Nowak
0116b963e3 Extend the node control rewriting test
Just to make sure that all the node controls are rewritten, even those
that don't have a counterpart in topology controls.
2016-08-12 17:03:42 +02:00
Krzesimir Nowak
1f5dbb776f Add shortcut reports for plugins.
Plugins are queried for reports two times in a second. That's often
enough to get the shortcut reports. The reports are sent together with
the response.
2016-08-12 17:03:42 +02:00
Krzesimir Nowak
cecf70ecd5 Marshal structs in the plugins registry tests
This is better than writing JSON strings by hand, which is
error-prone.
2016-08-12 17:03:42 +02:00
Krzesimir Nowak
0e06423a37 Forward control requests to plugins
Thanks to that, plugins can react to requests from controls they
exposed.

To make it work, plugins registry modifies each plugin's report by
prepending the plugin ID to the control name the plugin has exposed
before sending it to the app. Then the registry installs the control
request handler for this faked control name, which forwards the
request to the correct plugin.

This adds a new API endpoint to plugins next to "/report" - a
"/control" entry. The body of the request is the JSON-encoded
xfer.Request instance.
2016-08-12 17:03:42 +02:00
Krzesimir Nowak
c6b5d98699 Test the case when a plugin reports more than one plugin 2016-08-12 17:03:42 +02:00
Krzesimir Nowak
993eebeea9 Remove impossible case of an empty plugin ID
Plugin ID must be non-empty when the plugin is created and the
followup reports cannot change it.
2016-08-12 17:03:42 +02:00
Krzesimir Nowak
9d48fdc32c Restrict the set of allowed characters in plugin IDs
We will want to put plugin id in a control id, which is sent to an app
and then to GUI. When we get a control request from GUI, we will want
to extract the plugin ID from the control name. To do it unambiguously
we need some separator made of chars that are not allowed in a plugin
name. This is to avoid the situation when there are two plugins:
"Plugin" and "PluginFoo". "Plugin" exposes a control named
"FooControl" and "PluginFoo" exposes a control named "Control". Faking
the control names which will be sent to the app would result in two
"PluginFooControl".

One possible option for plugin ID and control name separator would be
"/", but that won't work, since the request sent from GUI to the app
to <probe>/<node>/<control> would actually be
<probe>/<node>/<plugin>/<control> and as such wouldn't match the URL
template in RegisterControlRoutes().
2016-08-12 17:03:42 +02:00
Krzesimir Nowak
ccd26fe69d Ban the possibility of changing plugin's ID
Changing plugin's ID only complicates control handling in plugins so
let's ban it.
2016-08-12 17:03:42 +02:00
Paul Bellamy
f17c8e6bae Better error message when plugin responses are too large 2016-04-18 12:43:40 +01:00
Paul Bellamy
72518e7036 iowait example plugin should remove the socket when done 2016-04-12 17:22:40 +01:00
Paul Bellamy
16c497d30a ditch plugin handshake endpoint 2016-04-12 17:22:39 +01:00
Alfonso Acosta
9f219badab Stop using the httputil client for plugins
* It sends unexpected TCP RSTs (causing connection reset by peer errors in the python plugin)

  Exception happened during processing of request from
  Traceback (most recent call last):
    File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
      self.process_request(request, client_address)
    File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
      self.finish_request(request, client_address)
    File "./http-requests.py", line 145, in finish_request
      self.RequestHandlerClass(request, '-', self)
    File "/usr/lib/python2.7/SocketServer.py", line 658, in __init__
      self.handle()
    File "/usr/lib/python2.7/BaseHTTPServer.py", line 349, in handle
      self.handle_one_request()
    File "/usr/lib/python2.7/BaseHTTPServer.py", line 312, in handle_one_request
      self.raw_requestline = self.rfile.readline(65537)
    File "/usr/lib/python2.7/socket.py", line 480, in readline
      data = self._sock.recv(self._rbufsize)
  error: [Errno 104] Connection reset by peer

* It doesn't reuse connections
2016-04-12 17:22:39 +01:00
Paul Bellamy
333d32fbe5 Review Feedback 2016-04-12 17:22:38 +01:00
Paul Bellamy
fcfd42e5d5 Review feedback - adding plugin status field 2016-04-12 17:22:38 +01:00
Paul Bellamy
7632e0b3c5 Adding support for plugins, with basic example of iowait, and ebpf
Squash of:
* Include plugins in the report
* show plugin list in the UI
* moving metric and metadata templates into the probe reports
* update js for prime -> priority
* added retry to plugin handshake
* added iowait plugin
* review feedback
* plugin documentation
2016-04-12 17:22:14 +01:00