Commit Graph

545 Commits

Author SHA1 Message Date
Hector Sanjuan
3ba7d79d0a restapi: allocationsHandler: skip filtering pins when not needed.
The restapi component supports filters for the pinset. This was done to keep
expected output when sharding was fully supported by filtering out "internal"
pins.

However this filter requires looping on the full pinset and re-allocating  and
usually does nothing. The useless copy is significant for really big pinsets.

Additionally, ipfs-cluster-ctl set the filter by default to "pins". By setting
it to "all" instead we can skip the whole filtering step and, in practice, get the
same results.
2021-07-08 23:27:55 +02:00
Hector Sanjuan
54c3608899
Merge pull request #1377 from ipfs/fix/1360-efficient-pin-status
Fix #1360: Efficient pinset status with filters
2021-07-06 11:57:09 +02:00
Hector Sanjuan
edfcfa3fb0 Fix #1360: Efficient pinset status with filters
This commit modifies the pintracker StatusAll call to take a status filter.

This allows to skip a PinLs call to ipfs when checking status for items that
are queued, pinning, unpinning or in error. Those status come directly from
the operation tracker. This should result in a significant performance
increase for those calls, particularly in nodes with several hundred thousand
pins and more, where the call to IPFS is very expensive.

A new TrackerStatusUnexpectedlyUnpinned status has been introduce to
differentiate between pin errors (tracked by the operation tracker) and "lost"
items (which before were pin errors too). This new status is handled by the
Recover() operation as before.
2021-07-06 11:34:19 +02:00
Hector Sanjuan
e07f30b2ab Feat #1374: Only accept Origins that have a p2p component 2021-07-02 01:49:30 +02:00
Hector Sanjuan
7e26ca8fc6 Feat #1374: Add Origins option to pins
This adds a new pin option called Origins, consisting of a slice of multiaddresses.
2021-07-02 01:42:51 +02:00
Hector Sanjuan
81d5759cc8 Fix #1366: IPFS Proxy API serializes wrong error types
The errors returned by the IPFS Proxy API are not understood by IPFS.

This was caused by go-ipfs-cmds setting an API error format which requires the
errors to have a type: "error" field.

This commit brings this up to speed.
2021-06-28 22:42:47 +02:00
Hector Sanjuan
55516fe7c6
Fix #1358: Set RawLeaves to true when unset and CidVersion=1 (#1359)
Fixes #1358. Mimics go-ipfs defaults.

Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
2021-05-19 23:56:30 +02:00
Hector Sanjuan
072f0bc722 Feat: support adding CAR files
This commit adds a new add option: "format".

This option specifies how IPFS Cluster is expected to build the DAG when
adding content. By default, it takes a "unixfs", which chunks and DAG-ifies as
it did before, resulting in a UnixFSv1 DAG.

Alternatively, it can be set to "car". In this case, Cluster will directly
read blocks from the CAR file and add them.

Adding CAR files or doing normal processing is independent from letting
cluster do sharding or not. If sharding is ever enabled, Cluster could
potentially shard a large CAR file among peers.

Currently, importing CAR files is limited to a single CAR file with a single
root (the one that is pinned). Future iterations may support multiple CARs
and/or multiple roots by transparently wrapping them.
2021-04-21 13:55:06 +02:00
Hector Sanjuan
d1700dbe81 Fixes #1319: Status wrongly shows pins as REMOTE
The Allocations of a pin that has been added with default replication factor
are kept even when the replication factor turns out to be -1.

This resulted in the Status(cid) code skipping calls to a number of peers
and setting the pin directly as REMOTE.

The fix, on one side makes sure Allocations is always nil when the replication
factor is -1. On the other size, lets the globalPinInfoCid method check the
replication factor value, rather than the number of allocations to decide if
any nodes are bound to be remote.

On the plus side, the pin tracker used the IsRemotePin method, which uses the
replication factor, so things were pinned even if the Status(cid) method shows
them as remote.
2021-03-24 00:47:15 +01:00
Hector Sanjuan
328af47dc8
Restapi: API libp2p host and client should no longer use secio. (#1316)
Instead they should use noise, and fallback to tls.

This should not break compatibility with previous versions as both old and new
are able to speak tls.

Fixes #1315
2021-02-24 16:10:44 +01:00
Hector Sanjuan
3adc43204a Merge branch 'master' into feat/alerts 2021-01-14 00:05:20 +01:00
Hector Sanjuan
90208b45f9 health/alerts endpoint: brush up old PR 2021-01-13 22:09:21 +01:00
Hector Sanjuan
4bcb91ee2b Merge branch 'master' into feat/alerts 2021-01-13 21:08:49 +01:00
Hector Sanjuan
e41a1b94ee Remove unexistent linter directive 2021-01-13 20:59:16 +01:00
Hector Sanjuan
a39ee13834 ipfsproxy: fix 'undefined cid' string appeareance in progress output
Fixes #1286. Some AddedOutput objects carry an undefined CID. This was getting
stringified as 'b', making the proxy responses include this rather than
skipping setting the field.
2021-01-13 16:32:08 +01:00
Omkar Prabhu
fa8b0845d0 hosts input format changed 2020-10-08 22:44:03 +05:30
Omkar Prabhu
dc5ca5bd2b simplifies resolveaddr, multiple hosts as input 2020-10-07 10:21:04 +05:30
Omkar Prabhu
a1f2c648cd removed ctx with cancel 2020-10-05 09:18:30 +05:30
Omkar Prabhu
2fd2412b20 integrated lb client in ipfs-cluster-ctl 2020-10-04 16:36:58 +05:30
Hector Sanjuan
0dfa9ca185
(chore) Upgrade dependencies
Upgrade dependencies and bump to go1.15.
2020-08-27 14:10:58 +02:00
Hector Sanjuan
e967238848
Merge pull request #1129 from ipfs/fix/1013-follow-list
Improvements to ipfs-cluster-follow * list
2020-05-16 02:31:06 +02:00
Hector Sanjuan
c026299b95 Include Name as GlobalPinInfo key and consolidate redundant keys
GlobalPinInfo objects carried redundant information (Cid, Peer) that takes
space and time to serialize.

This has been addressed by having GlobalPinInfo embed PinInfoShort rather than
PinInfo. This new types ommits redundant fields.
2020-05-16 02:27:24 +02:00
Hector Sanjuan
2ea11bad7b
Merge pull request #959 from ipfs/log/config
print full working configuration at startup
2020-05-15 02:09:27 +02:00
Kishan Mohanbhai Sagathiya
ae8e74453b Fix #937: Print full working configuration at startup
Only when using debug mode

Co-authored-by: Hector Sanjuan <code@hector.link>
2020-05-15 01:33:04 +02:00
Hector Sanjuan
7e9cece29c Include pin Names in PinInfo objects
Fixes #1013 by avoiding to have to make a specific request to allocations.
2020-05-15 00:18:14 +02:00
Hector Sanjuan
2e49d522ec Fix latest staticcheck errors and let travis test it 2020-05-14 23:54:11 +02:00
Hector Sanjuan
edd91f35ae Types: make MaxDepth a PinDepth type and add helpers to convert to Mode 2020-04-21 17:23:55 +02:00
Hector Sanjuan
6c60097421 ipfsproxy: support direct pin mode 2020-04-21 17:23:55 +02:00
Hector Sanjuan
68db5027e1 Fix #1009: Add Mode={direct,recursive} PinOption
This adds a new pin option: Mode that can be set to "direct" or "recursive".

The Mode is used to set the MaxDepth Pin field accordingly. When set to 0, we
will call pin/add using the type=direct.
2020-04-21 17:23:55 +02:00
Hector Sanjuan
cba3e9fae1 api/pb: declare enum before fields for clarity 2020-04-17 13:05:50 +02:00
Hector Sanjuan
717ed85823 gofmt -s fixes 2020-04-14 23:44:18 +02:00
Hector Sanjuan
97401443f3 Update to newest golang protobuf 2020-04-14 20:41:43 +02:00
Hector Sanjuan
f83ff9b655 staticcheck: fix all staticcheck warnings in the project 2020-04-14 20:16:10 +02:00
Hector Sanjuan
b3853caf36 Dependency ugprade: changes needed
* Libp2p protectors no longer needed, use PSK directly
* Generate cluster 32-byte secret here (helper gone from pnet)
* Switch to go-log/v2 in all places
* DHT bootstrapping not needed. Adjust DHT options for tests.
* Do not rely on dissappeared CidToDsKey and DsKeyToCid functions fro dshelp.
* Disable QUIC (does not support private networks)
* Fix tests: autodiscovery started working properly
2020-03-22 14:50:25 +01:00
Hector Sanjuan
19aff486c4
Merge pull request #1016 from ipfs/fix/1006-blake
Adder: fix #1006: Specify block format, hash and length when adding
2020-03-13 22:12:46 +01:00
Hector Sanjuan
ede1b89252 Adder: fix #1006: Specify block format, hash and length when adding
Currently we were only specifying the block format. When adding with
a custom hash function, even though we produced the right cids, IPFS
did not know the hash function and ended up storing them using SHA256.

Additionally, since NodeWithMeta serializes the CID, we do not need
to carry a Format parameter (which specifies the Codec): it is already
embedded.

Tests have been added and BlockPut in ipfshttp now checks that the
response's CID matches the data sent. This will catch errors like
what was happening, but also any data corruption between cluster and
IPFS during the block upload.
2020-03-13 14:43:58 +01:00
Hector Sanjuan
45ca4305d2 API/client: add context to http requests 2020-03-13 14:26:39 +01:00
Hector Sanjuan
531379b1d9
Feature: Support multiple listeners in configuration
* add ipv6 listening addresses to the default config

* ipfsproxy: support multiple listeners. Add default ipv6.

* mm

* restapi: support multiple listen addresses. enable ipv6

* cluster_config: format default listen addresses

* commands: update for multiple listeners. Fix randomports for udp and ipv6.

* ipfs-cluster-service: fix randomports test

* multiple listeners: fix remaining tests

* golint

* Disable ipv6 in defaults

It is not supported by docker by default. It is not supported in travis-CI
build environments. User can enable it now manually.

* proxy: disable ipv6 in test

* ipfshttp: fix test

Co-authored-by: @RubenKelevra <cyrond@gmail.com>
2020-02-28 11:16:16 -05:00
Yang Hau
7986d94242
fix: Fix typos (#1001)
Fix typos in files
2020-02-03 10:30:04 +01:00
Kishan Mohanbhai Sagathiya
68abae9287 Merge branch 'master' into feat/alerts 2019-12-23 12:45:22 +05:30
Kishan Mohanbhai Sagathiya
a3b8767e87 Added tests for Alerts
- tests for related cluster method, rest api, client method etc
- clean expired alerts everytime a new alerts come in
2019-12-23 12:42:38 +05:30
Hector Sanjuan
9c61bf6f26 Fix #983: Correctly print paths when adding 2019-12-17 23:01:25 +01:00
Kishan Mohanbhai Sagathiya
d21860eee7 Merge branch 'master' into feat/alerts 2019-12-13 10:22:06 +05:30
Kishan Sagathiya
5258a4d428 Remove map pintracker (#944)
This removes mappintracker and sets stateless tracker as the default (and only) pintracker component.

Because the stateless tracker matches the cluster state with only ongoing operations being kept on memory, and additional information provided by ipfs-pin-ls, syncing operations are not necessary. Therefore the Sync/SyncAll operations are removed cluster-wide.
2019-12-12 21:22:54 +01:00
Kishan Mohanbhai Sagathiya
04069b8c81 Introduction of ctl alerts
- basic version, just alerts if peers are down
2019-12-13 00:21:28 +05:30
Kishan Sagathiya
e1faf12bae ipfsproxy: hijack repo/gc and trigger cluster-wide GC
This adds hijacking of the repo/gc endpoint to the proxy to do cluster-wide gc.
2019-12-06 13:08:57 +01:00
Hector Sanjuan
ba021e8bb4 restapi: fix logging
Logging with Infof when there is nothing to format.
2019-12-02 11:56:25 +01:00
Hector Sanjuan
71217ac5d1 restapi client: support talking to unix sockets
Setting APIAddr to a Unix socket multiaddress will just work.
2019-12-02 11:56:16 +01:00
Kishan Sagathiya
a178e5988a Avoid out of index error in failover (#951)
Fixes panic when using the load balancing client.
2019-11-13 12:15:29 +01:00
Hector Sanjuan
f788a83d23 Fix lbclient test with new multiaddresses 2019-11-07 20:19:07 +01:00
Hector Sanjuan
249d9007d2 Merge branch 'master' into feat/cluster-gc 2019-11-07 18:35:42 +01:00
Kishan Mohanbhai Sagathiya
4d8ef92b3d health/graph: Improve graph
Mark local, trusted peers. Add peernames. Improve display.
2019-11-07 10:47:29 +01:00
Hector Sanjuan
e34bddd3ab Do not start Autonat when not used
Avoid chaining options as not necessary.

Add functions for common options and protector creation.
2019-11-05 12:51:18 +01:00
Kishan Mohanbhai Sagathiya
c7f37ce9f4 Use quic and use tls by default in restapi and restapi client
(cherry picked from commit 7ab1cd66ed17fda923b149628cae18ea96d1cf45)
2019-11-05 12:51:18 +01:00
Hector Sanjuan
af29bbc944 Pin-expiration: error when pinning expired pins 2019-11-05 12:22:52 +01:00
Kishan Mohanbhai Sagathiya
e4e1cbea6e Fix #481: Pin expiration
This adds a new PinOption: ExpireAt.

The StateSync ticker will check and unpin expired pins from the Cluster.

ipfs-cluster-ctl supports an "expire-in" which gives a duration.
2019-11-05 10:40:48 +01:00
Kishan Sagathiya
31534a429b Fix #374: health metrics improvements
- Human-sizes for freespace metrics. Display whether if metric is
expires in something like "expires in 3m".
- When not passing metric name `ipfs-cluster-ctl health metrics` hits
the the metrics endpoint which returns a list of available metrics and
displays to user
- Humanize metrics output
- Sort metrics output
2019-10-24 16:37:26 +02:00
Kishan Mohanbhai Sagathiya
492b5612e7 Add ability to run Garbage Collector on all peers
- cluster method, ipfs connector method, rpc and rest apis,
command, etc for repo gc
    - Remove extra space from policy generator
    - Added special timeout for `/repo/gc` call to IPFS
    - Added `RepoGCLocal` cluster rpc method, which will be used to run gc
    on local IPFS daemon
    - Added peer name to the repo gc struct
    - Sorted with peer ids, while formatting(only affects cli
    results)
    - Special timeout setting where timeout gets checked from last update
    - Added `local` argument, which would run gc only on contacted peer
2019-10-22 11:13:19 +05:30
Hector Sanjuan
582968f44e
Merge pull request #915 from ipfs/feat/proxy-logging
API logs for IPFS Proxy
2019-09-27 12:07:34 +02:00
Hector Sanjuan
ce20e86fdb
Merge pull request #907 from ipfs/feat/local-add
`--local` flag for `ctl add`
2019-09-23 13:13:59 -04:00
Hector Sanjuan
a98292bfa6
Merge pull request #893 from ipfs/feat/recover-all
Pin recover on all peers
2019-09-23 13:13:48 -04:00
Kishan Mohanbhai Sagathiya
adc7c5b131 Merge branch 'master' of github.com:ipfs/ipfs-cluster into test2 2019-09-10 20:03:05 +07:00
Kishan Mohanbhai Sagathiya
7f6c45812f Fix test 2019-09-10 15:27:47 +07:00
Kishan Mohanbhai Sagathiya
bc357400f6 API logs for IPFS Proxy 2019-09-10 13:59:03 +07:00
Hector Sanjuan
12141a562e
Merge pull request #913 from ipfs/fix/add-params
Fix: consolidate parsing of PinOptions
2019-09-09 14:52:26 +02:00
Hector Sanjuan
963bf8877f
Merge pull request #894 from ipfs/feat/http-logging
Logging for Cluster HTTP APIs
2019-09-09 10:30:01 +02:00
Hector Sanjuan
18dad223b2
Merge pull request #912 from ipfs/fix/allocations
Fix: handling allocations
2019-09-09 10:22:14 +02:00
Kishan Mohanbhai Sagathiya
9cb1cdeaff Merge branch 'master' into feat/recover-all 2019-09-08 17:06:43 +07:00
Kishan Mohanbhai Sagathiya
b1748d13c4 Use absolute path 2019-09-07 19:05:57 +07:00
Hector Sanjuan
11d5f6a3f2 Fix: consolidate parsing of PinOptions
This removes duplicated code to parse PinOptions.
2019-09-06 18:38:55 +02:00
Hector Sanjuan
96752e4e58 Fix: handling allocations
* pin() should not allocate if allocations are already provided
* pin() should not skip pinning if the exact same pin exists
  * Additionally this was unreliable as it allocated it before
    so the pin may have existed but the allocations may have been
    artificially changed.
* pin() re-uses existing pin when pin options are the same and thus
  avoids changing the allocations of a pin.

As a side effect, this fixes re-allocations which were broken: peers
called `shouldPeerRepinCid()` and instead of repinning that single
cid proceeded to repin the full state. For every pin.

Additionally tests have been adapted. It may be that some re-alloc tests
were very unreliable for the problems above.
2019-09-06 17:56:00 +02:00
Hector Sanjuan
9eb0deee4e
Merge pull request #891 from ipfs/feat/metadata
Metadata can be set and shown from `ctl`
2019-09-06 15:46:29 +02:00
Hector Sanjuan
2d389428cd Merge branch 'master' into feat/metadata 2019-09-06 15:17:05 +02:00
Hector Sanjuan
81ea1e76bc Merge branch 'master' into feat/sort-responses 2019-09-06 15:13:54 +02:00
Hector Sanjuan
f45c8544a7
Merge pull request #890 from ipfs/feat/allocations-for-add
Added UserAllocations support for `add`
2019-09-06 15:03:22 +02:00
Hector Sanjuan
d63a7fd641
Merge pull request #877 from ipfs/fix/ipfs-to-p2p
Use `p2p` protocol name over `ipfs` for multiaddr
2019-09-06 15:00:36 +02:00
Kishan Mohanbhai Sagathiya
5f57feab54 Addressed reviews on tests 2019-08-31 11:15:16 +05:30
Kishan Mohanbhai Sagathiya
db11f77396 Remove unwanted configs 2019-08-30 09:13:18 +05:30
Kishan Mohanbhai Sagathiya
6c863df9fe Merge branch 'master' of github.com:ipfs/ipfs-cluster into feat/http-logging 2019-08-29 21:37:04 +05:30
Kishan Mohanbhai Sagathiya
d43c8fb4a4 Make api logger work 2019-08-29 20:49:53 +05:30
Kishan Mohanbhai Sagathiya
49af782444 Use custom io.Writer for logging, Use go test instead of sharness tests 2019-08-28 22:13:23 +05:30
Kishan Mohanbhai Sagathiya
a684c9567d Add with option --local
This commit introduces `--local` option for `ctl add` which would add
content only the local ipfs peer and then pin it according to pin
options (fetching from the local peer)
For achieving this, a new local dag service is introduced
2019-08-28 18:39:30 +05:30
Kishan Mohanbhai Sagathiya
62a998a694 Use custom log formatter when logging to stdout
- Instead of using a boolean config element(send logs to std out or
file), use a string element that would store path of the log file.
That way user has freedom to choose the filepath. Use std out if this
path is empty.
2019-08-27 14:41:15 +05:30
Kishan Mohanbhai Sagathiya
7b35524779 Addressed reviews 2019-08-26 14:30:45 +05:30
Hector Sanjuan
9c73c2bdbd
Merge pull request #887 from ipfs/fix/small-issues
Fixes for some small issues
2019-08-24 14:24:38 +02:00
Hector Sanjuan
aab5f9bd0b Enable p2p addresses in a single place 2019-08-23 22:45:32 +02:00
Kishan Mohanbhai Sagathiya
c32281f9e0 Logging for Cluster HTTP APIs
This commit introduces logging for Cluster HTTP APIs.
It adds a config element `send_logs_to_file`, which tells whether logs
should be saved in a file or shown in standard output.

Requests are logged as per Apache Common Log Format (CLF)
http://httpd.apache.org/docs/2.2/logs.html#common

Fixes #574
2019-08-21 21:03:38 +05:30
Kishan Mohanbhai Sagathiya
512bf6a13b Pin recover on all peers
- recover works without `--local` flag as well (recovers all pins on all
peers)
- remove extra space from rpc policy

Fixes #763
2019-08-21 11:19:07 +05:30
Kishan Mohanbhai Sagathiya
e6d183fd70 Addressed reviews 2019-08-20 10:49:28 +05:30
Kishan Mohanbhai Sagathiya
0b6c376bad Metadata can be set and shown from ctl
This commit adds
- `metadata` option to `pin add` and `add` commands
- ability to set metadata from `/add` rest API
2019-08-19 10:29:06 +05:30
Kishan Mohanbhai Sagathiya
6bd897ac47 Added UserAllocations support for add 2019-08-16 18:13:06 +05:30
Kishan Mohanbhai Sagathiya
6656b80a00 Some more occurences of /ipfs
and use  SwapToP2pMultiaddrs (very helpful since ipfs still send
addresses with `/ipfs` tag)
2019-08-16 11:56:09 +05:30
Kishan Sagathiya
edd5e33a1b
Update api/rest/restapi.go 2019-08-14 19:49:15 +05:30
Hector Sanjuan
6743f92e51 Fix: do not set PinUpdate when cid is Undef
It gets set to 'b' and then prints an error when parsing.
2019-08-14 14:09:46 +02:00
Kishan Mohanbhai Sagathiya
229953f943 Merge branch 'master' of github.com:ipfs/ipfs-cluster into fix/api-improvements 2019-08-14 09:05:56 +05:30
Kishan Mohanbhai Sagathiya
06729def89 Use router.NotFoundHandler instead 2019-08-13 22:55:43 +05:30
Kishan Mohanbhai Sagathiya
935c824b33 Merge branch 'master' of github.com:ipfs/ipfs-cluster into fix/api-improvements 2019-08-13 22:34:51 +05:30
Kishan Mohanbhai Sagathiya
70e429f925 Fix #852: Improve error handling on add
Keep sending blocks while adding as long as one destination works.
2019-08-13 16:06:20 +02:00
Kishan Mohanbhai Sagathiya
f022a70f4c Make sure all API errors are in JSON
This commit introduces a catchAllHandler(which returns error not found),
which will be used if path doesn't match with any other pattern.
2019-08-12 13:00:11 +05:30
Kishan Mohanbhai Sagathiya
c6192cebf4 Use p2p protocol name over ipfs for multiaddr 2019-08-11 19:06:45 +05:30
Hector Sanjuan
80ed3ebced Use go:generate to generate the protobuf 2019-08-09 16:12:28 +02:00
Hector Sanjuan
1eade4ae58 Fix #732: Introduce native pin/update
This introduces a pin/update operation which allows to Pin a new item to
cluster indicating that said pin is an update to an already-existing pin.

When this is the case, all the configuration for the existing pin is copied to
the new one (including allocations). The IPFS connector will then trigger
pin/update directly in IPFS, allowing an efficient pinning based on
DAG-differences. Since the allocations where the same for both pins,
the pin/update can proceed.

PinUpdate does not unpin the previous pin (it is not possible to do this
atomically in cluster like it happens in IPFS). The user can manually do it
after the pin/update is done.

Internally, after a lot of deliberations on what the optimal way for this is,
I opted for adding a `PinUpdate` option to the `PinOptions` type (carries the
CID to update from). In order to carry this option from the REST API to the
IPFS Connector, it is serialized in the Protobuf (and stored in the
datastore). There is no other way to do this in a simple fashion since the Pin
object is piece of information that is sent around.

Additionally, making it a PinOption plays well with the Pin/PinPath APIs which
need little changes. Effectively, you are pinning a new thing. You are just
indicating that it should be configured from an existing one.

Fixes #732
2019-08-09 16:11:52 +02:00
Kishan Sagathiya
c0b8301525 Fix #854: 404 on deleting a pin that isn't part of pinset (#854)
With this commit
- If cid in `DELETE /pins/{cid}` isn't part of the pinset, it would
return 404
- If path in `DELETE /pins/{keyType}/{path}` resolves to a cid that
isn't part of the pinset, it would return 404
2019-07-29 13:26:53 +02:00
Hector Sanjuan
7a78620017
Fix #853: Make a more orderly shutdown of rest api libp2p host (#855)
Cancelling its context before closing the listeners and de-registering
protocols is ground for panics on libp2p.
2019-07-26 17:32:11 +02:00
Hector Sanjuan
7c636061bd
Improve pin/unpin method signatures (#843)
* Improve pin/unpin method signatures:

These changes the following Cluster Go API methods:

* -> Cluster.Pin(ctx, cid, options) (pin, error)
* -> Cluster.Unpin(ctx, cid) (pin, error)
* -> Cluster.PinPath(ctx, path, opts) (pin,error)

Pin and Unpin now return the pinned object.

The signature of the methods now matches that of the API Client, is clearer as
to what options the user can set and is aligned with PinPath, UnpinPath, which
returned pin methods.

The REST API now returns the Pinned/Unpinned object rather than 204-Accepted.

This was necessary for a cleaner pin/update approach, which I'm working on in
another branch.

Most of the changes here are updating tests to the new signatures

* Adapt load-balancing client to new Pin/Unpin signatures

* cluster.go: Fix typo

Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>

* cluster.go: Fix typo

Co-Authored-By: Kishan Sagathiya <kishansagathiya@gmail.com>
2019-07-22 15:39:11 +02:00
Kishan Sagathiya
b6ba67804f Fix #448: rest api client: Load balancing client implementations
This adds a LoadBalancing rest client implementation which is initialized with a set of client configurations and can use two strategies: failover and roundrobin (more strategies can be added by implementing the LBStrategy interface).
2019-07-19 15:17:51 +02:00
Kishan Mohanbhai Sagathiya
586253a2ce JSON Config object key should match JSON tags
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-07-15 17:47:35 +05:30
Protocol Labs
4c8738f585 Fix #765 Added needed gx references 2019-07-04 13:57:52 +01:00
Hector Sanjuan
b804e61ef0 Update deps along with go-libp2p-core refactor
Lots of rewrites in imports...
2019-06-14 13:10:45 +02:00
Adrian Lanzafame
5a61d5bef8
add IPFSPinStatusFromString benchmark
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-06-05 11:48:39 +10:00
Michael Muré
5515bdd7d7
Fix: api: replace two regex with strings.HasPrefix()
Those regex were compiled with each call to the function. As it's
called by PinLs, this resulted in a significant amount of memory used,
500MB in my case after a single call.

License: MIT
Signed-off-by: Michael Muré <batolettre@gmail.com>
2019-06-04 20:13:35 +02:00
Hector Sanjuan
99be078548 Fix: ipfsproxy: fix test failing with empty multiaddresses
This is a recent change in the multiaddress library to disallow
empty addresses.
2019-05-27 14:27:23 +02:00
Hector Sanjuan
196aa23f34 Fix #787: Connectivity fixes
Currently, unless doing Join() (--bootstrap), we do not connect to any peers on startup.

We however loaded up the peerstore file and Raft will automatically connect
older peers to figure out who is the leader etc. DHT bootstrap, after Raft
was working, did the rest.

For CRDTs we need to connect to people on a normal boot as otherwise, unless
bootstrapping, this does not happen, even if the peerstore contains known peers.

This introduces a number of changes:

* Move peerstore file management back inside the Cluster component, which was
already in charge of saving the peerstore file.
* We keep saving all "known addresses" but we load them with a non permanent
TTL, so that there will be clean up of peers we're not connected to for long.
* "Bootstrap" (connect) to a small number of peers during Cluster component creation.
* Bootstrap the DHT asap after this, so that other cluster components can
initialize with a working peer discovery mechanism.
* CRDT Trust() method will now:
  * Protect the trusted Peer ID in the conn manager
  * Give top priority in the PeerManager to that Peer (see below)
  * Mark addresses as permanent in the Peerstore

The PeerManager now attaches priorities to peers when importing them and is
able to order them according to that priority. The result is that peers with
high priority are saved first in the peerstore file. When we load the peerstore
file, the first entries in it are given the highest priority.

This means that during startup we will connect to "trusted peers" first
(because they have been tagged with priority in the previous run and saved at
the top of the list). Once connected to a small number of peers, we let the
DHT bootstrap process in the background do the rest and discover the network.

All this makes the peerstore file a "bootstrap" list for CRDTs and we will attempt
to connect to peers on that list until some of those connections succeed.
2019-05-27 14:27:23 +02:00
Hector Sanjuan
c59873e076 update deps 2019-05-21 11:34:33 +02:00
Hector Sanjuan
d51c2a0377 Merge branch 'master' into feat/monitor-ring 2019-05-16 15:46:30 +02:00
Hector Sanjuan
a86c7cae2b rpc auth: handle some auth errors gracefully
particuarly we will ignore authorization errors for some broadcasts and somply
not include those responses in the assembled one.
2019-05-09 21:23:49 +02:00
Hector Sanjuan
949e6f2364 RPC auth: Support Trusted Peers in CRDT consensus component.
TrustedPeers are specified in the configuration. Additional peers
can be added at runtime with Trust/Distrust functions.

Unfortunately we cannot use consensus.PeerAdd as a way to trust a peer as
cluster.PeerAdd+Join can be called by any peer and this calls
consensus.PeerAdd.

The result is consensus.PeerAdd doing a lot in Raft while consensus.Trust does
nothing, while in CRDTs consensus.Trust does something but consensus.PeerAdd
does nothing. But this is more or less consistent.
2019-05-09 19:48:40 +02:00
Adrian Lanzafame
e69f440523
add String method for Pin type
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-05-07 18:50:03 +10:00
Adrian Lanzafame
ff6e559744
add String method for GlobalPinInfo type
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-05-07 12:04:59 +10:00
Hector Sanjuan
3d49ac26a5 Feat: Split components into RPC Services
I had thought of this for a very long time but there were no compelling
reasons to do it. Specifying RPC endpoint permissions becomes however
significantly nicer if each Component is a different RPC Service. This also
fixes some naming issues like having to prefix methods with the component name
to separate them from methods named in the same way in some other component
(Pin and IPFSPin).
2019-05-04 21:36:10 +01:00
Hector Sanjuan
036e3da7f1 Proxy pin/update: Respond with BadRequest when arguments missing 2019-05-02 10:32:13 +01:00
Hector Sanjuan
da24114ae0 Proxy: hijack pin/update
The IPFS pin/update endpoint takes two arguments and usually
unpins the first and pins the second. It is a bit more efficient
to do it in a single operation than two separate ones.

This will make the proxy endpoint hijack pin/update requests.

First, the FROM pin is fetched from the state. If present, we
set the options (replication factors, actual allocations) from
that pin to the new one. Then we pin the TO item and proceed
to unpin the FROM item when `unpin` is not false.

We need to support path resolving, just like IPFS, therefore
it was necessary to expose IPFSResolve() via RPC.
2019-04-29 16:36:40 +02:00
Hector Sanjuan
2144f4bd42 Types: make UserAllocations []peer.ID instead of string
It seems we forgot to convert this after peer.IDs became serializable. This
fixes it.
2019-04-29 16:24:38 +02:00
Kishan Mohanbhai Sagathiya
fa8d5c973c Invalid filter should throw BadRequest
- for GET `/allocations` and GET `/pins` an invalid filter now result
in BadRequest
- Added tests for the same
2019-04-24 21:54:12 +05:30
Kishan Mohanbhai Sagathiya
b2796b951a Default allocations filter should be all
Currently `curl -X GET http://localhost:9094/allocations` results in an
empty array, because no filter is provided. Solution to this would be
either 1) to consider filter as all if no filter is provided by the user
or 2) to make the `filter` parameter mandatory and reply with BadRequest
if no filter is provided

This commit makes the default filter as all
2019-04-24 20:24:08 +05:30
Adrian Lanzafame
ebcf40cf7d
rename TS to ReceivedAt
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-04-18 16:09:18 +10:00
Hector Sanjuan
7711ab8cfd
Replace underlying slice with ring.Ring in metrics window
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-04-18 16:09:18 +10:00
Hector Sanjuan
acbd7fda60 Consensus: add new "crdt" consensus component
This adds a new "crdt" consensus component using go-ds-crdt.

This implies several refactors to fully make cluster consensus-component
independent:

* Delete mapstate and fully adopt dsstate (after people have migrated).
* Return errors from state methods rather than ignoring them.
* Add a new "datastore" modules so that we can configure datastores in the
   main configuration like other components.
* Let the consensus components fully define the "state.State". Thus, they do
not receive the state, they receive the storage where we put the state (a
go-datastore).
* Allow to customize how the monitor component obtains Peers() (the current
  peerset), including avoiding using the current peerset. At the moment the
  crdt consensus uses the monitoring component to define the current peerset.
  Therefore the monitor component cannot rely on the consensus component to
  produce a peerset.
* Re-factor/re-implementation of "ipfs-cluster-service state"
  operations. Includes the dissapearance of the "migrate" one.

The CRDT consensus component defines creates a crdt-datastore (with ipfs-lite)
and uses it to intitialize a dssate. Thus the crdt-store is elegantly
wrapped. Any modifications to the state get automatically replicated to other
peers. We store all the CRDT DAG blocks in the local datastore.

The consensus components only expose a ReadOnly state, as any modifications to
the shared state should happen through them.

DHT and PubSub facilities must now be created outside of Cluster and passed in
so they can be re-used by different components.
2019-04-17 19:14:26 +02:00
Hector Sanjuan
a25f4ecb10 Fix #743: Use lowercase "version" in json version object
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2019-04-10 11:15:56 +02:00
Hector Sanjuan
94a781ef21
Merge pull request #735 from jmank88/url-nocopy
support --nocopy when adding URLs
2019-03-27 15:18:08 +01:00
jmank88
76c798e313 support --nocopy when adding URLs 2019-03-26 10:22:37 -05:00
chenminjian
36d78e55c6 refact: remove duplicative package
License: MIT
Signed-off-by: chenminjian <727180553@qq.com>
2019-03-26 20:17:03 +08:00
Kishan Mohanbhai Sagathiya
be50543fef Omitempty IPFSID 2019-03-19 22:23:02 +05:30
Kishan Mohanbhai Sagathiya
99a7528d85 Make make check pass 2019-03-18 19:50:42 +05:30
Kishan Mohanbhai Sagathiya
660109c147 Merge branch 'master' into issue_715 2019-03-18 18:25:22 +05:30
Kishan Mohanbhai Sagathiya
226953dd26 Make IPFSID pointer
Make IPFSID pointer so that it can be made nil when empty
2019-03-18 18:24:56 +05:30
Kishan Mohanbhai Sagathiya
8a06936ccd Bug fix: input isn't valid multihash
Some command were failing with `input isn't valid multihash`, due to
empty peer.ID. This commit omit peer id from IPFSID when empty, thus
avoiding the error state
2019-03-14 18:28:36 +05:30
Alexey Novikov
a586548e62 fix #636: review nitpicks
License: MIT
Signed-off-by: Alexey Novikov <alexey@novikov.io>
2019-03-11 05:25:26 +00:00
Alexey Novikov
53d624e701 fix #636: mitingate long header attack
License: MIT
Signed-off-by: Alexey Novikov <alexey@novikov.io>
2019-03-10 21:16:26 +00:00
Hector Sanjuan
a9bd43575f types/AddedOutput: remove omitempty in cid 2019-03-07 11:30:08 +00:00
Hector Sanjuan
374ec59256 Fix tests 2019-03-06 19:29:41 +00:00
Hector Sanjuan
0008f69162 Types: make AddedOutput carry a cid.Cid
This was a leftover. For consisency, all CIDs coming out of the API
should have the canonical cid form ( { "/": "cid" } ), otherwise
we are inconsistent.
2019-03-06 18:48:25 +00:00
Kishan Mohanbhai Sagathiya
27a59991f6 Hide extract_headers_path, extract_headers_ttl
proxy: "extract_headers_path" and "extract_headers_ttl" should be
hidden options in the config
2019-03-06 17:55:06 +05:30
Hector Sanjuan
23db807b87 ipfsproxy: use PinPath to match IPFS behaviour
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-03-04 15:54:34 +00:00
Hector Sanjuan
6a37c5c7f8
Merge pull request #694 from alekswn/fix/645-BasicAuthTest
fix #645: Basic Authentication test in REST API
2019-03-03 23:21:48 +00:00
Alexey Novikov
d1c0729a5e fix #645: fix error messages
License: MIT
Signed-off-by: Alexey Novikov <alexey@novikov.io>
2019-03-02 14:08:53 +00:00
Alexey Novikov
b4cb46fc5b fix #645: golint
License: MIT
Signed-off-by: Alexey Novikov <alexey@novikov.io>
2019-03-02 08:35:09 +00:00
Alexey Novikov
d49bfff8c4 fix #645: Basic Authentication test in REST API
License: MIT
Signed-off-by: Alexey Novikov <alexey@novikov.io>
2019-03-02 07:28:40 +00:00
Hector Sanjuan
a7db3a9f9b Remove leftover debugging init() function
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-03-01 14:20:35 +00:00
Hector Sanjuan
ea85cf7805 Rename "test.Test*" to "test.*" (test.TestCid1 -> test.Cid1)
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-27 20:19:10 +00:00