We had a problem happening when assigning the returned *api.Error
to default 'error' type.
Things like "if err != nil" would not work even when *api.Error is nil
I'm not sure why this happens, but this is very confusing for the user
integrating on top. It is better that we just return plain go errors.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
The multiaddresses protocols for websockets and dns are only registered
with init() function when loading the modules. ipfs-cluster-ctl
uses just the api, which did not load these modules so converting
from serialized types caused bad panics.
We have also ignored errors in the api library under the thinking that it
would only parse things serialized by us, but this has made parsing errors
to go unnoticed. From now, all errors are logged and some precautions
are taking to better handle the possibility of nil objects.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
Apparently, cancelling the request context closes the response body
prematurely, before it's being fully read.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
As before, exit status 1 means a client application error and
exit status 2 means a server-returned error.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
This allows taking advantage of connection keep alive by having the
api client re-use the same connection. Additionally, an option
to close connections after every request is provided.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
* Set default logging facility
* Remove old keep-alive comment in tests
* Use a port for TestPeersWithErrors which is not default
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
This adds the pakage api/rest/client which implements a go-client
for the REST API component. It also update the ipfs-cluster-ctl
tool to rely on it.
Originally, I wanted this to live it in it's own separate repository,
but the api client uses /api/types.go, which is part of cluster.
Therefore it would need to import all of cluster as a dependency.
ipfs-cluster-ctl would also need to import go-ipfs-cluster-api-client
as a dependency, creating circular gx deps which would be a mess to
maintain.
Only the splitting of cluster in multiple repositories (at least for
api, rest, ipfs-cluster-ctl, rest/client and test) would allow better
dependency management by allowing rest/client and the ctl tool
to only import what is needed, but this is something which brings
maintenance costs and can probably wait a bit until cluster is more stable.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
ipfs-cluster-service now locks before running the daemon and state
upgrade commands. Locking mechanism heavily inspired by ipfs, see
go-ipfs fsrepo. Unlock called on exit to free up repo. one lockfile
per repo. A very simple sharness test checks that two service
invocations cannot occur.
A longstanding sharness/ci logging issue is addressed by exporting
verbose=t into the travis environment. Now output of commands from
within sharness test strings are displayed during travis runs.
License: MIT
Signed-off-by: Wyatt Daviau <wdaviau@cs.stanford.edu>
I've modified the peer identifier to be 'peername'. I've also
modified the TestLoadJSON to check that it is correctly read from
config and set to a default if empty.
Also added 'peername' fields to configurations for various tests.
This allows to call the Rest API's status and sync endpoints with a
"?local=true" parameter. This will trigger operations but only on the
local peer. Cluster *Local and RPC-*Local methods have been accordingly,
although they are aliases for the PinTracker methods (but otherwise they
would not be exposed in external APIs). ipfs-cluster-ctl has been updated to
support the new flag.
The rationaly behind this feature is that sometimes, a single cluster peer
(or the ipfs daemon in it) is misbehaving. The user then wants to Sync,
Recover, or see Status for that single peer. This is specially relevant
when working with big pinsets in larger clusters, as a Status() call will
be considerably more expensive when broadcasted everywhere.
Note that the Rest API keeps returning GlobalPinInfo objects even on local=true
calls. This ensures that the user always gets the same datatype from an endpoint.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
I renamed Hostname to simply Name as to not imply relation to DNS.
Removed quotes from formatter, used helper function setting config,
and added defensive error check.
URL encoding was added for `ipfs-cluster-ctl pin add --name`. The
Map State version was return to version 2. I did not notice errors,
but if there are, Version 2 still is not in a stable release.
I added an option called --name or -n which specifies the name for
the added pin to be stored in consensus. Also added quotes around
name for allocations formatter.
When not specified, the name was being assigned to whichever name
was assigned to the previous pin. Not sure exactly what was
happening, but it works after removing omitempty. The idea was to
make Name optional, but here it will always be assigned.
Added Name field to be a part of the stored state of a Pin. This
allows the name to be stored as a part of the consensus if needed.
This is the bare minimum to use. Some other calls like status need
to be checked out.
This adds API, RPC calls to support RecoverAllLocal() (and expose RecoverLocal()
on the Rest API too). cluster-ctl is updated accordingly.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
I added a "hostname" property to a node's configuration file. Its
value defaults to the hostname provided by the OS, but can be
modified to anything beside an empty string in the config file.
The "hostname" was added to the output of the "id" call. Thus, peer
hostnames are available when listing peers.
This also generates a default configuration section when it
doesn't exist, so it's backwards compatible.
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
The main container will now run only ipfs-cluster-service.
A new ipfs-cluster-bundle container is built by Dockerfile-bundle
which will provide ipfs-cluster+ipfs.
Fixes#197
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
Allows us to test against latest ipfs (either it's broken and this
helps finding out, or it's not broken anymore and we don't lose time
trying to figure out why).
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>