Commit Graph

300 Commits

Author SHA1 Message Date
Hector Sanjuan
6d77954327 Fix multiple problems with state migration
Additionally, remove persisting the state version to the go-datastore. In the
future versions of the state, there is not a global format anymore (with a
global version). Instead, every pin element can potentially be stored in a
different version.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-19 19:46:03 +00:00
Hector Sanjuan
d57b81490f State: Use go-datastore to implement the state interface
Since the beginning, we have used a Go map to store the shared state (pinset)
in memory. The mapstate knew how to serialize itself so that libp2p-raft would
know how to write to disk when it:

* Saved snapshots of the state on shutdown
* Sent the state to a newcomer peer

hashicorp.Raft assumes an in-memory state which is snapshotted from time to
time and read from disk on boot.

This commit adds a `dsstate` implementation of the state interface using
`go-datastore`. This allows to effortlessly switch to a disk-backed state in
the future (as we will need), and also have at our disposal the different
implementations and utilities of Datastore for fine-tuning (caching, batching
etc.).

`mapstate` has been reworked to use dsstate. Ideally, we would not even need
`mapstate`, as it would suffice to initialize `dsstate` with a
`MapDatastore`. BUT, we still need it separate to be able to auto-migrate to
the new format.

This will be the last migration with the current system. Once this has been
released and users have been able to upgrade we will just remove `mapstate` as
it is now.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-02-19 18:31:14 +00:00
Hector Sanjuan
3059ab387a
Merge pull request #663 from roignpar/issue_656
Read config values from env on init command
2019-02-19 17:48:47 +00:00
Adrian Lanzafame
6509dfff56
Release 0.9.0
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-02-18 20:31:07 +10:00
Robert Ignat
523e109ef1 Create LoadJSONFileAndEnv config method for convenience
License: MIT
Signed-off-by: Robert Ignat <robert.ignat91@gmail.com>
2019-02-15 19:32:48 +02:00
Robert Ignat
47252f8e62 Merge remote-tracking branch 'upstream/master' into issue_656
License: MIT
Signed-off-by: Robert Ignat <robert.ignat91@gmail.com>
2019-02-15 16:45:32 +02:00
Adrian Lanzafame
17ffcf2b1c
Release 0.9.0-rc1
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-02-12 21:01:50 +10: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
c37beea1ae
Release 0.8.0
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-16 13:27:03 +01:00
Hector Sanjuan
19191cf13f
Release 0.8.0-rc1
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-14 14:53:30 +01:00
Hector Sanjuan
7cd936f5ee Issue #632: Fix wrong name for flag. Address review comments
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-10 11:13:21 +01:00
Hector Sanjuan
f936e52f71 Fix #632: Add --no-stream to ipfs-cluster-ctl
tl;dr: this solves the user's immediate need and, even if not tne strictest
solution, it is the simplest one.

I think we should not have the server buffer output when we can do it rather
easily client side and have the clients use their own memory for the task even
if `stream-channels=false` would do this.

We can always change the approach, but this is the minimal solution to
json array with all the AddedOutput things.

We might not buffer at all and hack a `[`, `,` separating elements and `]`
at the end, when json encoding is enabled, etc. But that would not be clean,
specially if we mean to support more output formats at some point.

Enabling supporting stream-channels=false in the api/rest/client means adding
new methods, with tests, modifying the interface etc etc. for what is
essentially a presentation issue in "ctl" in the end. Similarly we could
buffer inside the client, but it is so trivial that I don't see advatange.
We should also start thinking about moving to streaming API endpoints and
when that moment arrives we shall revisit this discussion.

I have removed the hacky manual output parts by declaring a custom
addedOutputQuiet type which wraps added output and is understood by
the formatters.go helpers.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-09 18:53:22 +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
fa5906cc19 Feat #445: Catch invalid filter strings in ipfs-cluster-ctl.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-08 12:28:29 +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
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
02af6c121f Fix #445: Reduced length of filter help string
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
99638cddb2 Fix #632: Apply -Q option to --enc=json when adding.
This will only print the latest JSON update when adding
with -Q.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-01-04 19:31:32 +01:00
Hector Sanjuan
862c1eb3ea Fix #382: Extract headers from IPFS API requests & apply them to hijacked ones.
This commit makes the proxy extract useful fixed headers (like CORS) from
the IPFS daemon API responses and then apply them to the responses
from hijacked endpoints like /add or /repo/stat.

It does this by caching a list of headers from the first IPFS API
response which has them. If we have not performed any proxied request or
managed to obtain the headers we're interested in, this will try triggering a
request to "/api/v0/version" to obtain them first.

This should fix the issues with using Cluster proxy with IPFS Companion and
Chrome.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-12-18 16:05:12 +01:00
Kishan Sagathiya
411eea664c Merge branch 'master' of github.com:ipfs/ipfs-cluster into issue_453 2018-11-03 20:24:15 +05:30
Hector Sanjuan
7e1ddd90a7
Release 0.7.0
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-11-01 19:49:07 +01:00
Kishan Sagathiya
3a5ad6111a Issue #453 Extract the IPFS Proxy from ipfshttp
Changes as requieed
Rename IPFSProxy struct to Server

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-11-01 15:54:05 +05:30
Hector Sanjuan
7c90e550dc
Release 0.7.0-rc1
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-29 18:03:04 +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
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
c370e86cca Issue #532 -f init should clean up state
Cosmetic changes

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
687f49d1b7 Issue #532 -f init should clean up state
Cosmetic changes

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
5f52cc60a8 Issue #532 -f init should clean up state
Change to more appropriate prompt message

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
7fd42cff44 Issue #532 -f init should clean up state
Remove force from global flags and use it as a local flag

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
dbc5f97d5e Issue #532 -f init should clean up state
Prompt on init and skip the prompt in init -f (and not have a -y flag)
This would be in line with other state subcommands which ask by default
and -f skips the prompt.

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
d599ef891b Issue #532 -f init should clean up state
Prompt before cleaning up the state

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
d80532d032 Issue #532 -f init should clean up state
Do cleanup after configuration in service.json is created

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Kishan Sagathiya
96944d0ffb Issue #532 -f init should clean up state
ipfs-cluster-service -f init` should clean up state

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-18 19:06:07 +05:30
Hector Sanjuan
80baf7d00a Fix changed peer ID String() output.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-17 14:08:56 +02:00
Kishan Sagathiya
fdb573c96f Issue #453 Extract the IPFS Proxy from ipfshttp
Adding more missing pieces in config
Use the right package(not the inbuilt one)
Setup rpc client for proxy in the cluster
Add back SetClient and Shutdown into Connector as they are required to
implement Component interface
Add `ipfsproxy` as into list of logging identifier and add its default
log level

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-14 22:42:50 +05:30
Kishan Sagathiya
d338f8de53 Issue #453 Extract the IPFS Proxy from ipfshttp
Added config
Change functions accordingly to add new `ipfsproxy` component

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-10-14 16:07:42 +05:30
Hector Sanjuan
b6306a6e61 Add endpoints output: improvements and compliance
This straigthens some mistakes with the outputs of the /add endpoints.

Currently, we had exactly the same output format which:

* was not exactly the ipfs API output format but was sort of similar
* made some weird concessions to be compatible (like having a string-type "size")
* was not aligned with Cluster API conventions (lowercase keys)

This corrects all this:

* The Cluster API /add output format now uses the right types and lowercase keys.
* `Hash` is now `Cid`, because the field carries a Cid.
* We copy error handling with request trailers from IPFS, and avoid carrying the
  errors in the output objects.
* The proxy now returns exactly the types as ipfs would
* We add the X-Chunked-Output: 1 header, which is custom and redundant, but
otherwise breaks js-ipfs-api integrations with the /add endpoint.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-04 00:57:36 +02:00
Hector Sanjuan
d327155c65
Release 0.6.0
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-03 15:21:30 +02:00
Hector Sanjuan
2e0f008dff
Release 0.6.0-rc1
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-01 16:34:58 +02:00
Hector Sanjuan
e86fefb808 ctl: Make remaining changes from *cid.Cid to cid.Cid in ipfs-cluster-ctl
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-10-01 12:53:42 +02:00
Joseph Lukasik
b98e549d92 Add Client interface, implemented by defaultClient
License: MIT
Signed-off-by: Joseph Lukasik <joseph@jgl.me>
2018-09-27 16:51:34 -07:00
Kishan Sagathiya
79481f83dc Move ipfs-cluster-service and ipfs-cluster-ctl to cmd/
This commit moves `ipfs-cluster-service` and `ipfs-cluster-ctl` to
`cmd/` directory to follow "standard" project structure.

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2018-09-27 20:56:09 +02:00