Commit Graph

118 Commits

Author SHA1 Message Date
Wyatt Daviau
ae38d09208 Beginning add UX improvements--
1. Refactored importer endpoint, including writing cluster-specific
file adder, to get print info from importer
2. Refactored importer consumption to select equally from
channels of different output signals and manage context
timeouts correctly (only in local add here, sharding to follow)
3. Added output streaming and an error/termination handling protocol
4. Discovered that naive eager response streaming cuts off
reads from request data stream and breaks behavior, for
now all responses come after file ingestion.
5. Added ipfs add style flags (trickle, rawleaves etc.) and
refactored importer endpoint to take in these parameters
to provide identicle behavior to ipfs

License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
edb38b2830 fixing make check errors
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
92dff3462d Initial unit tests
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
504d08d06c Addressing first round of comments
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
77a61890ff Sharding rough draft:
sharding passes manual tests on single node cluster,
adding the shards of a directory and pinning the
clusterDAG to cluster/ipfs state

License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
fa74bc230d ipfs block put call now format aware
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
ef3b149419 sharding component rough draft:
A sharder config provides a default shard size
getAllocations calls newly exposed rpcs
ipld cbor cluster dag node construction
logic to handle Flushing final shard
logic to initialize and finalize shard sessions

License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
4a5a613d94 rpc call and config added
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
11e8e9d62c Addressing second round of comments
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
9696336491 addressing first round of feedback
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
d3bca1f022 context cancellation on error
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
40f8eeedb5 cluster-ctl add to ipfs
RPC call to put a block in ipfs
IPFSConnector method to implement the RPC call
cluster restapi reads from channel and puts
blocks into IPFS via RPC in ctl add handler

License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
c12685a518 Bring importer interface to cluster
dependence on dex replaced with ipld-importer subpackage
slight improvement to importer tests and formatting
gx deps update: new raft, ipld format and ipfs added

License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
029ee3454e addressing feedback
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
65eb7b3775 printing importer works
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
20b81f9f3d calling into dex importer
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
5725e34e3d polishing up print on restapi
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
9025baa12a streaming bugs fixed
dummy echo server implemented on cluster service api
manual tests with files work
wireshark examination shows transfer-encoding = chunked

License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Wyatt Daviau
9e3e42b19d client streams files
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
2018-08-07 20:11:23 +02:00
Hector Sanjuan
218ee0260b Fix: API constants should explicit their type
Otherwise, they are int. This forces API users to do manual variable
type declaration when initializing something to one of these constants

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-06-01 17:27:21 +02:00
Adrian Lanzafame
c89508035a Maptracker: extract optracker and make improvements
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-05-28 11:59:26 +02:00
Laevos
a3c77dafb8 fixed formatting issues
License: MIT
Signed-off-by: Lilith McMullen <iggnsthe@live.com>
2018-05-25 20:38:47 -05:00
Laevos
e62c4171ef fix #428: Use a regexp to match for indirect status in IPFSPinStatusFromString()
Since indirect pins are of the form `indirect through <cid>`, let's use
a regexp to match them instead of an equality operator.

License: MIT
Signed-off-by: Lilith McMullen <iggnsthe@live.com>
2018-05-25 20:08:45 -05:00
Hector Sanjuan
aa1f74e69b Fix: some govet warnings
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-05-11 19:59:10 +02:00
Hector Sanjuan
bb8c20b2fb Enable pubsubmon in cluster e2e tests
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-05-07 18:47:05 +02:00
Hector Sanjuan
a9d6fe3479 Types: rename metric.SetTTLDuration to metric.SetTTL
GetTTL returns duration. SetTTL should take duration too, not seconds.
This removes the original SetTTL method which used seconds.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-05-07 14:26:06 +02:00
Hector Sanjuan
029cd77c27
Merge pull request #398 from ipfs/feat/promote-consensus
Emancipate the consensus component
2018-05-07 08:29:14 +02:00
Hector Sanjuan
33d9cdd3c4 Feat: emancipate Consensus from the Cluster component
This commit promotes the Consensus component (and Raft) to become a fully
independent thing like other components, passed to NewCluster during
initialization. Cluster (main component) no longer creates the consensus
layer internally. This has triggered a number of breaking changes
that I will explain below.

Motivation: Future work will require the possibility of running Cluster
with a consensus layer that is not Raft. The "consensus" layer is in charge
of maintaining two things:
  * The current cluster peerset, as required by the implementation
  * The current cluster pinset (shared state)

While the pinset maintenance has always been in the consensus layer, the
peerset maintenance was handled by the main component (starting by the "peers"
key in the configuration) AND the Raft component (internally)
and this generated lots of confusion: if the user edited the peers in the
configuration they would be greeted with an error.

The bootstrap process (adding a peer to an existing cluster) and configuration
key also complicated many things, since the main component did it, but only
when the consensus was initialized and in single peer mode.

In all this we also mixed the peerstore (list of peer addresses in the libp2p
host) with the peerset, when they need not to be linked.

By initializing the consensus layer before calling NewCluster, all the
difficulties in maintaining the current implementation in the same way
have come to light. Thus, the following changes have been introduced:

* Remove "peers" and "bootstrap" keys from the configuration: we no longer
edit or save the configuration files. This was a very bad practice, requiring
write permissions by the process to the file containing the private key and
additionally made things like Puppet deployments of cluster difficult as
configuration would mutate from its initial version. Needless to say all the
maintenance associated to making sure peers and bootstrap had correct values
when peers are bootstrapped or removed. A loud and detailed error message has
been added when staring cluster with an old config, along with instructions on
how to move forward.

* Introduce a PeerstoreFile ("peerstore") which stores peer addresses: in
ipfs, the peerstore is not persisted because it can be re-built from the
network bootstrappers and the DHT. Cluster should probably also allow
discoverability of peers addresses (when not bootstrapping, as in that case
we have it), but in the meantime, we will read and persist the peerstore
addresses for cluster peers in this file, different from the configuration.
Note that dns multiaddresses are now fully supported and no IPs are saved
when we have DNS multiaddresses for a peer.

* The former "peer_manager" code is now a pstoremgr module, providing utilities
to parse, add, list and generally maintain the libp2p host peerstore, including
operations on the PeerstoreFile. This "pstoremgr" can now also be extended to
perform address autodiscovery and other things indepedently from Cluster.

* Create and initialize Raft outside of the main Cluster component: since we
can now launch Raft independently from Cluster, we have more degrees of
freedom. A new "staging" option when creating the object allows a raft peer to
be launched in Staging mode, waiting to be added to a running consensus, and
thus, not electing itself as leader or doing anything like we were doing
before. This additionally allows us to track when the peer has become a
Voter, which only happens when it's caught up with the state, something that
was wonky previously.

* The raft configuration now includes an InitPeerset key, which allows to
provide a peerset for new peers and which is ignored when staging==true. The
whole Raft initialization code is way cleaner and stronger now.

* Cluster peer bootsrapping is now an ipfs-cluster-service feature. The
--bootstrap flag works as before (additionally allowing comma-separated-list
of entries). What bootstrap does, is to initialize Raft with staging == true,
and then call Join in the main cluster component. Only when the Raft peer
transitions to Voter, consensus becomes ready, and cluster becomes Ready.
This is cleaner, works better and is less complex than before (supporting
both flags and config values). We also backup and clean the state whenever
we are boostrapping, automatically

* ipfs-cluster-service no longer runs the daemon. Starting cluster needs
now "ipfs-cluster-service daemon". The daemon specific flags (bootstrap,
alloc) are now flags for the daemon subcommand. Here we mimic ipfs ("ipfs"
does not start the daemon but print help) and pave the path for merging both
service and ctl in the future.

While this brings some breaking changes, it significantly reduces the
complexity of the configuration, the code and most importantly, the
documentation. It should be easier now to explain the user what is the
right way to launch a cluster peer, and more difficult to make mistakes.

As a side effect, the PR also:

* Fixes #381 - peers with dynamic addresses
* Fixes #371 - peers should be Raft configuration option
* Fixes #378 - waitForUpdates may return before state fully synced
* Fixes #235 - config option shadowing (no cfg saves, no need to shadow)

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-05-07 07:39:41 +02:00
Hector Sanjuan
bfcf700fa8
Merge pull request #383 from ipfs/feat/pintracker-revamp
Feat: pintracker revamp
2018-05-07 07:38:15 +02:00
LeonGGGG
50dd729a52 Fix #191: Add go HTTPs tests
Added https server and client in restapi_test.go, with a sample unit test in TestRestAPIIDEndpoint

License: MIT
Signed-off-by: Liang Gao lianggao91@hotmail.com
2018-05-04 18:31:29 -07:00
Adrian Lanzafame
f68c7f5354 ipfshttp: add pin/unpin specific timeouts
and get the tests passing and add Pin/UnpinQueued
tracker statuses back in.

License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2018-05-02 15:24:26 +02:00
Hector Sanjuan
cd32daf4d7 Fix: do not generate "listen_multiaddress" deprecated option in config
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-04-27 10:24:39 +02:00
Hector Sanjuan
0069c0062f Fix metric expire type. Do not discard metrics in Allocate().
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-04-05 17:57:24 +02:00
Hector Sanjuan
41433298f5 Fix: --wait flag. Address comments
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-29 11:25:15 +02:00
Hector Sanjuan
851e78ad02 Add test for WaitFor
Actually test that WaitFor waits

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-29 11:23:40 +02:00
Hector Sanjuan
4da2458db9 Fix: WaitFor never returning
Since no-one is reading sf.Out, sending blocks and everything hangs.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-29 11:23:40 +02:00
Hector Sanjuan
018e5dbaea Fix: --wait flag in ipfs-cluster-ctl
The --wait flag was being completely ignored unless --no-status was passed
too, which makes no sense because then it would print the wait status.

This waits when --wait and prints the status when --no-status is not passed.

If we have been waiting, the status comes from that. Otherwise we request it.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-29 11:23:40 +02:00
Hector Sanjuan
53b0b86e52
Merge pull request #365 from ipfs/fix/type-errors
api/types: do not print some errors
2018-03-28 20:06:32 +02:00
Hector Sanjuan
403a4cf6e0 api/types: do not print some errors
The rest/client does things like "return id.ToID(), err" which is nice.
But when there's an error the ID has Cid set to nil etc. This is now
causing error messages on the console which are very misleading because
they do not correspond to the actual error of the request.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-28 19:16:49 +02:00
Hector Sanjuan
9c40d971f6 api/rest: PrivateKey -> private_key for the json config
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-28 18:23:12 +02:00
Hector Sanjuan
3da9776408 api/rest: ID -> id. All keys in the json config should be downcase
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-28 18:20:21 +02:00
Adrian Lanzafame
4d48504779 rest/client: Add WaitFor utility function
address feedback and add WaitForPinnedStatus

address feedback and rework WaitFor

implement StatusFilter

address feedback and rework StatusFilter

License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2018-03-27 14:56:49 +10:00
Hector Sanjuan
7ca3dc292a Fix #269: Add IPFS() method to api/rest/client
The IPFS() methods returns an ipfs Shell pointing to the ipfs-cluster
proxy endpoint. The location can be customized (via ProxyAddr configuration
option) or it is assumed to be the same as the PeerAddr/APIAddr, with
a different port (the default).

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-26 15:23:14 +02:00
Hector Sanjuan
8e7ca5a682 rest/config: remove dup https options
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-21 16:16:24 +01:00
Hector Sanjuan
4ea873c297 api/rest/client: run endpoint tests in parallel
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-21 09:51:20 +01:00
Hector Sanjuan
62bdbaa9f3 Use iff iff it is necessary
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-21 00:34:57 +01:00
Hector Sanjuan
6777122abf rest/libp2p-http: address @zenground0 comments
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-20 19:51:57 +01:00
Hector Sanjuan
09f4c9fce3 rest/libp2p-http: address lanzafame's review
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-20 19:35:42 +01:00
Hector Sanjuan
02bde2650e api/rest: refactorings in config.go (codeclimate)
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-16 14:55:36 +01:00
Hector Sanjuan
a9a58a50a0 Config: provide utility to parse duration arguments. Use it.
Should reduce complexity (codeclimate).

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
2018-03-16 14:22:11 +01:00