Commit Graph

109 Commits

Author SHA1 Message Date
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
Hector Sanjuan
dc2e73dfc2
Release 0.11.0-rc6 2019-08-13 20:25:53 +02:00
Hector Sanjuan
dc3170b1d2 cluster: add mDNS service discovery
I always thought the libp2p node would do this, but it is not the case.
With this, CRDT peers are able to autodiscover on local networks.
2019-08-13 19:32:38 +02:00
Hector Sanjuan
5303a7f721
Merge pull request #874 from ipfs/feat/865-init-consensus
Service: Select consensus on "init" (not on "daemon")
2019-08-13 10:21:45 +02:00
Hector Sanjuan
3b3e3493a8 Service: init: improve log messages
Align with previous behaviour and make sure it is logged that
the configuration file was written.

Do not say "peerstore written with 0 entries" as that might be
taken like an error.
2019-08-12 16:58:06 +02:00
Hector Sanjuan
d8c20adc4e
Merge pull request #869 from ipfs/fix/732-pin-update-the-good-way
Fix #732: Introduce native pin/update
2019-08-12 12:15:30 +02:00
Kishan Mohanbhai Sagathiya
684f58894d Use string flag instead of string slice
Because string slice is not very user friendly. Using string instead
would allow us to pass a comma separated list of arguments in one option
2019-08-12 11:31:26 +02:00
Hector Sanjuan
2311bdac19 daemon: do consensus things inside a switch 2019-08-12 10:39:49 +02:00
Hector Sanjuan
f32a53c4e6 Daemon: "init" do not TrustAll when passing --peers 2019-08-12 10:25:55 +02:00
Hector Sanjuan
063c5f1b78 Service: Select consensus on "init" (not on "daemon")
Fixes #865.

This makes the necessary changes so that consensu is selected on "init" with a
flag set, by default, to "crdt". This generates only a "crdt" or a "raft"
section, not both.

If the configuration file has a "raft" section, "raft" will be used to start
the daemon. If it has a "crdt" section, "crdt" will be used. If it has none or
both sections, an error will happen.

This also affects "state *" commands, which will now autoselect how to work
from the existing configuration.
2019-08-09 19:20:53 +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
Hector Sanjuan
00e78a6b6d
Daemon: support remote configuration (#868)
* Daemon: support remote configuration

This:

* Adds support for fetching the configuration from a remote HTTP location:

`ipfs-cluster-service init http://localhost:8080/ipfs/Qm...` will instruct
cluster to read the configuration file from ipfs on start (potentially making
use of ipns and dnslink).

This is done by creating a `service.json` like `{ "source": <url> }`.

The source is then read when loading that configuration every time the daemon starts.

This allows to let users always use a mutating remote configuration, potentially
adding/removing trusted peers from the list or adjusting other things.

* Configuration and state helpers from ipfs-cluster-service have been extracted
to its own cmdutils package. This will help supporting something like an
`ipfs-cluster-follow` command in the next releases.

* Allows to disable the rest api by not defining it in the configuration (I thought
this was already so, but apparently only affected the ipfsproxy).

* Removes informer/allocator configurations from the daemon (--alloc). No one used
a non default pair. In fact, it was potentially buggy to use the reposize one.
2019-08-09 12:56:27 +02:00
Hector Sanjuan
eace9031dc
Merge pull request #856 from ipfs/feat/force-consensus-choice
service: Make --consensus a mandatory flag
2019-07-30 11:32:49 +02:00
Kishan Sagathiya
e0c38a2ddf Auto-trust bootstrap peers (#857)
Fix #834: Auto-trust bootstrap peers (#857)

Add bootstrap peers to list of trusted peers for crdt.
2019-07-29 10:17:43 +02:00
Hector Sanjuan
6188d6ff52 service: Make --consensus a mandatory flag
It has a few implications to launch a raft peer when you wanted to do crdt and vice-versa.

Same when exporting and exporting states.

Users starting cluster peers should be explicit about their consensus choice.

Also, if we ever want to make `crdt` the default, we can't do that before
making `raft` non-default first. I don't like to break things but otherwise
the experience for new users wanting to try crdts might be aweful.
2019-07-26 18:15:41 +02:00
Kishan Sagathiya
e7b731e0e4 Fix #835: service: init --peers
* Init should take a list of peers

This commit adds `--peers` option to `ipfs-cluster-service init`

`ipfs-cluster-service init --peers <multiaddress,multiaddress>`

- Adds and writes the given peers to the peerstore file
- For raft config section, adds the peer IDs to the `init_peerset`
- For crdt config section, add the peer IDs to the `trusted_peers`
2019-07-25 10:47:44 +02:00
Kishan Sagathiya
b96c2b664d Do not load API components removed from the config (#836)
* Do not load API components removed from the config

This commit introduces a map that would keep track of whether components
for a component were missing or not from the JSON config file. This map
can be check while creating cluster to avoid loading a component.

It would consider component only if the component is fully missing from the
config.
Say the component in question is `ipfsproxy` which is under `api`
section.
This would use defaults for `ipfsproxy` and load IPFS proxy.

```
{
"api":{
	"ipfsproxy": {}
	}
}
```

However, this would not load IPFS proxy
```
{
"api":{}
}
```
2019-07-18 17:33:14 +02:00
Hector Sanjuan
4c16675a39
Release 0.11.0-rc5 2019-06-27 17:58:26 +01:00
Hector Sanjuan
d5f8a30da9
Release 0.11.0-rc4 2019-06-14 14:43:31 +02: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
Hector Sanjuan
97549152cc
Release 0.11.0-rc3 2019-06-13 17:31:51 +02:00
Hector Sanjuan
6d7daee875
Release 0.11.0-rc2 2019-06-10 16:18:34 +02:00
Hector Sanjuan
445e48445e
Release 0.11.0-rc1 2019-06-07 19:16:15 +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
96edbc1ea6 Daemon: handle host and DHT lifecycle outside Cluster
The Host and DHT are created outside of cluster and should be
shutdown outside of it, not inside.
2019-05-25 00:23:46 +02:00
Hector Sanjuan
5f7510bd2d
Merge pull request #780 from ipfs/fix/identity-docs
service: multiple fixes around init and identities
2019-05-17 11:57:31 +01:00
Hector Sanjuan
d51c2a0377 Merge branch 'master' into feat/monitor-ring 2019-05-16 15:46:30 +02:00
Hector Sanjuan
e62d10f83a service: multiple fixes around init and identities
* Fix error messages (they must be in the form "doing something")
* Improve/reword some error messages
* Document the identity.json existance in the cli docs
* Fix a bunch of typos
* Fix missing folder path in the --help
* Fix cluster not locking when configuration is not there but folder is
* Fix force flag not overriding the config overwrite prompt
* Fix deletion of Raft state on re-init (not necessary if identity persists)
* Fix overwriting on identity (should not be overwritten if already exists)

Much of this paves the way to be able to run without service.json:

* Either taking default values (and using env vars) - maybe someday
* Either by getting a configuration template it from somewhere (ipfs, http)
  at runtime - sooner.
2019-05-16 15:31:36 +02:00
Hector Sanjuan
f428a3b669
Merge pull request #766 from ipfs/issue_760
Separate Identity and Configuration
2019-05-16 09:24:44 +01:00
Hector Sanjuan
26b0949b5e
Merge pull request #769 from ipfs/deps/update
Update deps
2019-05-08 13:24:21 +01:00
Kishan Mohanbhai Sagathiya
909a536d59 Pass identity before configs everywhere
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-05-06 14:24:31 +05:30
Kishan Mohanbhai Sagathiya
b40f2c4caa Merge branch 'master' into issue_760
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-05-06 14:08:35 +05:30
Kishan Mohanbhai Sagathiya
cbf3e28ccb Separate identity from configuration
- Move identity.go to config package
- extractIdentity --> loadIdentity inside ipfs-cluster-service/configs.go
- ApplyEnvVars for identity
- Use crypto.Ed25519 instead of crypto.RSA
- Don't rewrite service.json

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-05-06 14:05:12 +05:30
Kishan Mohanbhai Sagathiya
47d7023471 Separate identity and configuration
Resave configuration if identity.json did not exist. This would remove
identity from service.json

License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
2019-04-30 20:59:15 +05:30
Kishan Mohanbhai Sagathiya
51214da4d8 Separate Identity and Configuaration 2019-04-30 15:17:36 +05:30
Hector Sanjuan
539dfcd6ec Update exporter import paths 2019-04-29 18:57:13 +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
Adrian Lanzafame
42693eb06d
fix passing ctx from daemon to pubsub
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-04-29 17:58:28 +10:00
Adrian Lanzafame
661de45908
fix daemon call to create pubsubmon
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-04-26 18:14:38 +10:00
Adrian Lanzafame
3c09ebcc71
add Alerts measure
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-04-26 17:56:44 +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
0f9ce4807c
Release 0.10.1 2019-04-10 12:04:43 +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
Hector Sanjuan
6531f56575 Fix: ctl: --enc=json shows empty output on "add" 2019-03-23 16:35:20 +00:00
jmank88
215458c0a6 fix nil pointer panic 2019-03-23 08:59:16 -05:00
Kishan Sagathiya
962d249e74
Remove basic monitor (#726)
Remove basic monitor

This commit removes `basic` monitor component, because it is not being
used by default since few releases ago pubsub monitor was introduced.

Issue #689
2019-03-21 22:48:40 +05:30
Hector Sanjuan
9bfcaffef8
Merge pull request #720 from ipfs/fix/peers-ls-output
Fix ID output using shortened peer ID.
2019-03-15 19:33:33 +00:00
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
Hector Sanjuan
7bdf97b9da Fix ID output using shortened peer ID. 2019-03-11 23:08:51 +00:00