Commit Graph

173 Commits

Author SHA1 Message Date
Robert Ignat
168cf76224 Change ApplyEnvVars strategy for all config components
Get jsonConfig from Config, apply env vars to it, load jsonConfig
back into Config.

License: MIT
Signed-off-by: Robert Ignat <robert.ignat91@gmail.com>
2019-02-15 19:07:20 +02:00
Robert Ignat
21a539159f Remove json config overriding with env vars
in LoadJSON for restapi and cluster Config

License: MIT
Signed-off-by: Robert Ignat <robert.ignat91@gmail.com>
2019-02-09 00:00:58 +02:00
Robert Ignat
ed30ac1ab4 Add ApplyEnvVars() to ComponentConfig interface
* cluster and restapi configs can also get values from environment variables
* other config components don't read any values from the environment

License: MIT
Signed-off-by: Robert Ignat <robert.ignat91@gmail.com>
2019-02-07 20:51:20 +02:00
Adrian Lanzafame
3b3f786d68
add opencensus tracing and metrics
This commit adds support for OpenCensus tracing
and metrics collection. This required support for
context.Context propogation throughout the cluster
codebase, and in particular, the ipfscluster component
interfaces.

The tracing propogates across RPC and HTTP boundaries.
The current default tracing backend is Jaeger.

The metrics currently exports the metrics exposed by
the opencensus http plugin as well as the pprof metrics
to a prometheus endpoint for scraping.
The current default metrics backend is Prometheus.

Metrics are currently exposed by default due to low
overhead, can be turned off if desired, whereas tracing
is off by default as it has a much higher performance
overhead, though the extent of the performance hit can be
adjusted with smaller sampling rates.

License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-02-04 18:53:21 +10:00
Hector Sanjuan
c9151f0048 Fix #639: Enforce basic auth for all requests when enabled
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-11 15:49:12 +01:00
Hector Sanjuan
efafe9b7b5 Fix #639: Do not break start by complaining of unset CORSMaxAge
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-11 15:32:37 +01:00
Hector Sanjuan
a3720c29c2 restapi: minor codeclimate issue
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-11 13:40:07 +01:00
Hector Sanjuan
adb290ed2d Fix #639: restapi: Handle CORS preflight requests (OPTIONS)
This adds support for handling preflight requests in the REST API
and fixes currently mostly broken CORS.

Before we just let the user add custom response headers to the
configuration "headers" key but this is not the best way because
CORs headers and requests need special handling and doing it wrong
has security implications.

Therefore, I have added specific CORS-related configuration options
which control CORS behavour. We are forced to change the "headers"
defaults and will notify the users about this in the changelog.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-11 13:25:21 +01:00
Hector Sanjuan
7067745f1a Fix #639: Add CORS options to restapi
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-11 12:36:25 +01:00
Hector Sanjuan
d80f3ee05d
Merge pull request #627 from ipfs/issue_445
Added filter option to `ipfs-cluster-ctl status`
2019-01-08 18:26:53 +01:00
Hector Sanjuan
595db7a7c5
Merge pull request #633 from ipfs/feat/632-stream-channels
Feat/632: support stream-channels query parameter when adding
2019-01-08 13:31:39 +01:00
Hector Sanjuan
75702c21c9 Feat #445: Clarify about 0 filter value.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-07 19:47:44 +01:00
Hector Sanjuan
7de930b796 Feat #445: Use TrackerStatus as filter. Simplify and small misc.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-07 19:45:07 +01:00
Hector Sanjuan
596c1f5096 Fix #632: Make sure StreamChannels is enabled in rest/client.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-07 14:05:30 +01:00
Kishan Mohanbhai Sagathiya
706558cdc9 Status filters for ipfs-cluster-ctl status
Optimized filter to tracker status matching by using bitwise
comparisions

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-01-05 15:44:54 +05:30
Kishan Mohanbhai Sagathiya
2c364ddf5e Status filters for ipfs-cluster-ctl status
Improved matching of filters and tracker status

Fixes #445

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-01-05 14:44:37 +05:30
Kishan Mohanbhai Sagathiya
bed9672a74 Status filters for ipfs-cluster-ctl status
Added a fail case where an invalid filter is passed in.
Update `api.rpcClient.Call` to `api.rpcClient.CallContext` and pass
in the Request context r.Context() so that context can be cancelled
when the request is cancelled by caller

Fixes #445

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-01-05 14:44:37 +05:30
Kishan Mohanbhai Sagathiya
02e129fbfe Status filters for ipfs-cluster-ctl status
Added clients tests

Fixes #445

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-01-05 14:44:37 +05:30
Kishan Mohanbhai Sagathiya
f0321afd54 Status filters for ipfs-cluster-ctl status
Added filter option to `ipfs-cluster-ctl status`

When the --filter is passed, it will only fetch the peer information
where status of the pin matches with the filter value.
Valid filter values are tracker status types(i.e., "pinned",
"pin_error", "unpinning" etc), an alias of tracker status type (i.e.,
"queued" or "error"), comma separated list of tracker status type
and/or it aliases(i.e., "error,pinning")

On passing invalid filter value no status information will be shown

In particular, the filter would remove elements from []GlobalPinInfo
when none of the peers in GlobalPinInfo match the filter. If one peer
in the GlobalPinInfo matches the filter, the whole object is returned,
including the information for the other peers which may or not match it.

filter option works on statusAll("GET /pins"). For fetching pin status
for a CID("GET /pins/<cid>"), filter option would have no effect

Fixes #445

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-01-05 14:44:37 +05:30
paul
ed20241b3d Fix #445:
-Changed some 'snake case' to 'camel case' in accordance with code climate

License: MIT
Signed-off-by: Paul Jewell <sona1111@zoho.com>
2019-01-05 14:44:37 +05:30
paul
bda9633e82 Fix #445:
-Fixed logic issue in match condition of 'filterStatus' function
-Added and verified success of test provided by @lanzafame
-Attempted to condense code and apply other cleanup provided by @lanzafame

License: MIT
Signed-off-by: Paul Jewell <sona1111@zoho.com>
2019-01-05 14:44:37 +05:30
paul
7c04dd1acc Fix #445: Implemented status filter for ipfs-cluster-ctl
License: MIT
Signed-off-by: Paul Jewell <sona1111@zoho.com>
2019-01-05 14:44:37 +05:30
Hector Sanjuan
a426d75978 Fix $632: Test stream-channels=false in /add endpoint
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-04 19:31:10 +01:00
Hector Sanjuan
b44c7fb990
Merge pull request #622 from ipfs/issue_587
Added tests for /monitor/metrics/{metrics_type}
2019-01-04 18:17:05 +01:00
Kishan Mohanbhai Sagathiya
fc678242fb Added tests for /monitor/metrics/{metrics_type}
Move ctl-health sharness tests to apprpriate file

Since the API is using the RPC mock to request metrics and it always
returns a mocked test metric we might just do c.Metrics("somemetricstype")
and check that there is no error. Here we just want to check that the
client is hitting an API endpoint (and understands the response).

Fixes #587

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-12-21 08:24:40 +05:30
Kishan Sagathiya
6049b216bb Sharness tests for ipfs-cluster-ctl health metrics
Added sharness tests for `ipfs-cluster-ctl health metrics <metricname>`

Fixes #587

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-12-21 08:24:40 +05:30
Kishan Sagathiya
e9cf8abb3a Added tests for /monitor/metrics/{metrics_type}
Added API and client tests for GET /monitor/metrics/{metrics_type}

Fixes #587

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-12-21 08:24:40 +05:30
Hector Sanjuan
b93b2fedd4 Fix interpreting Host parameter correctly.
We should deprecate passing in Host/Port in the config,
but in the meantime, it hardcoded /dns4/, meaning that if
someone placed an ipv6 address in there things would break badly
and weirdly.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-12-19 21:19:47 +01:00
Hector Sanjuan
7c26f1ecb8 Fix HTTPs with DNS multiaddresses
Before we resolved all /dns*/ multiaddresses before we used them.

When using HTTPs, the Go HTTP Client only sees the resolved IP address
and it is unable to negotiate TLS with a cerficate because the request
is not going to the hostname the certificate is signed for, but to
the IP. This leverages a recent feature in go-multiaddr-net
and uses directly the user-provided hostname.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-12-19 21:15:37 +01:00
Hector Sanjuan
11cc0485c7 API/client: Do not clean folders mid-test.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-12-17 14:55:34 +01:00
Hector Sanjuan
ced9f2f7f1 Update to go-ipfs-files 2.0.3
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-12-17 14:29:44 +01:00
Hector Sanjuan
15413edbc6 Unrewrite deps
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-12-17 14:16:38 +01:00
Łukasz Magiera
406d2b53f8 files2.0: Close subfiles in adder
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-12-17 14:16:38 +01:00
Łukasz Magiera
c6944e4376 files2.0: update for no errors from NewMultiFileReader
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-12-17 14:16:38 +01:00
Łukasz Magiera
00df384e1c go-ipfs-files 2.0 updates
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
2018-12-17 14:16:38 +01:00
Adrian Lanzafame
e115021fa7
add envcfg to rest api
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2018-11-09 13:20:25 +10:00
Hector Sanjuan
1d924bfc49 Remove shard testing folders
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-11-01 19:15:08 +01:00
Hector Sanjuan
19b1124999 Make metrics human
Issue #572 exposes metrics but they carry the peer ID in binary.

This was ok with our internal codecs but it doesn't seem to work
very well with json, and makes the output format unusable.

This makes the Metric.Peer field a string.

Additinoally, fixes calling the command without arguments and displaying
the date in the right format.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-26 14:11:30 +02:00
Hector Sanjuan
9330ac82e2 Fix tests with latest libp2p
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-25 14:55:01 +02:00
Hector Sanjuan
b86f3cedb4 Files package has been extracted from cmdkit
Related: https://github.com/ipfs/go-ipfs-cmdkit/pull/31

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-24 01:28:05 +02:00
Hector Sanjuan
79fe5919d2 Fix: escape filter parameter query
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-22 23:45:33 +02:00
Hector Sanjuan
48c89fbe4d
Merge pull request #572 from kishansagathiya/issue_449
Issue #449 API endpoint for Peer Monitor metrics
2018-10-22 23:32:50 +02:00
Kishan Sagathiya
ec4588a5ce Issue #449 API endpoint for Peer Monitor metrics
Rename method PeerMonitorLatestMetrics to Metrics
Addressing first round of comment as in
https://github.com/ipfs/ipfs-cluster/pull/572#pullrequestreview-165367171

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-21 13:36:20 +05:30
Kishan Sagathiya
3ac7d6c9cc Issue #449 API endpoint for Peer Monitor metrics
Support the new endpoint for later metrics in `rest/api/client`

Support the new method created in `rest/api/client` in
ipfs-cluster-ctl. i.e. `ipfs-cluster-ctl health metrics <name>` would
show the peers and the last list of metrics logged for each as returned
by the Peer Monitor, in a friendly way.

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-21 12:49:56 +05:30
Kishan Sagathiya
fafbf7b929 Issue #449 API endpoint for Peer Monitor metrics
Opened new endpoint `GET /health/metrics/<name>` which would respond
with metrics of type <name>

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-21 12:49:56 +05:30
Hector Sanjuan
4e3553fb1f Fix: escape the add query parameters correctly in the client
When adding something that has a name with spaces, things fail
very badly.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-19 20:19:52 +02:00
Hector Sanjuan
b0b826de39
Merge pull request #580 from ipfs/libp2p-6.0.19
Upgrade to libp2p-6.0.19. Update deps.
2018-10-18 12:07:46 +02:00
Hector Sanjuan
7d16108751 Start using libp2p/go-libp2p-gorpc
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-17 15:28:03 +02:00
Hector Sanjuan
86b74c059a Fix using new libp2p-http
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-17 13:47:23 +02:00
Hector Sanjuan
562ad713fc Update docs for sendResponse
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-17 13:43:57 +02:00