Commit Graph

3973 Commits

Author SHA1 Message Date
Jeromy
cf478af971 cleanup changes from PR 2015-04-22 01:25:22 -07:00
Jeromy
001b7ab714 implement a config option for mdns 2015-04-22 00:55:31 -07:00
Juan Batiz-Benet
58d6d1e7b6 updated vendored mdns libs 2015-04-22 00:49:40 -07:00
Juan Batiz-Benet
73c3888812 vendored mdns deps 2015-04-21 23:57:48 -07:00
Juan Batiz-Benet
b223dc2d05 fix vendoring problems from migrations 2015-04-21 23:57:09 -07:00
Jeromy
0917c1cb82 implement basic peer discovery using mdns 2015-04-21 21:34:54 -07:00
Juan Batiz-Benet
b1adeef85c version bump to 0.3.1
This patch update fixes a few bugs:

* harden shutdown logic by @torarnv
* daemon locking fixes by @travisperson
* don't re-add entire dirs by @whyrusleeping
* tests now wait for graceful shutdown by @jbenet
* default key size is now 2048 by @jbenet

(experimenting with using semver)
2015-04-21 01:43:10 -07:00
Juan Batiz-Benet
c7d2d6090a Merge pull request #1111 from ipfs/init-lower-key-size
init: lower default rsa key size to 2048 for now
2015-04-21 01:37:04 -07:00
Juan Batiz-Benet
bafcaaeb61 Merge pull request #1110 from ipfs/graceful-exit-sharness
sharness: wait for graceful shutdown
2015-04-21 01:36:17 -07:00
Juan Batiz-Benet
16f56e1c9b init: lower default rsa key size to 2048 for now
I think we should lower the default rsa key size to 2048 for now -- until we have a proper focus on securing everything. It's always a pain for new users to get hung on 4096 rsa key gen, when we have not even made sure we're using the keys perfectly correctly yet. (And 2048 is still considered secure)
2015-04-21 01:18:52 -07:00
Juan Batiz-Benet
cf797d3d02 sharness: only send kill signal once - #1106
sharness should only send the kill signal once, as that is
what a graceful shutdown should do. in the event that doesn't
happen, we should send it again, and then kill -9 to prevent it
lingering and messing with other tests.
2015-04-21 01:15:22 -07:00
Juan Batiz-Benet
bd9e2c6edb sharness: t0030-mount output known breakage
The test_must_fail check fails on osx. (it does not seem to fail on
linux). See #1109
2015-04-21 01:15:14 -07:00
Juan Batiz-Benet
db56c0f16a Merge pull request #1037 from torarnv/harden-shutdown-logic
Harden shutdown logic
2015-04-21 00:58:49 -07:00
Juan Batiz-Benet
1bac12f922 Merge pull request #1103 from travisperson/bug/init-with-daemon
Check to see if the daemon is currently running
2015-04-21 00:58:35 -07:00
Travis Person
676fd50ca0 Correctly written test for ipfs init with daemon 2015-04-20 23:46:59 -07:00
Travis Person
e7756e45f9 Problem with initializing daemon on same port
At this point I think this test should be moved out of this file
2015-04-20 19:33:41 -07:00
Juan Batiz-Benet
33fab2290a Merge pull request #1101 from ipfs/fix/add-perf
don't readd entire directories recursively
2015-04-20 19:23:52 -07:00
Travis Person
cca5212e09 Add sharness test
This test to make sure we can't run `ipfs init` while a daemon is
currently running.
2015-04-20 18:35:42 -07:00
Travis Person
e1f8dfa25a Check to see if the daemon is currently running
If the daemon is running we do not want to proceed with an
an initialization.

Return a client error telling the user to kill the daemon
before proceeding with the command.
2015-04-20 17:21:13 -07:00
Jeromy
861f30cc12 don't readd entire directories recursively 2015-04-20 16:21:00 -07:00
Tor Arne Vestbø
bfd12114e7 Remove daemon InitDone guard in interrupt handler
Instead of just terminating right there and then, we cancel the
context, and let the daemon exit cleanly. This make take a few
seconds, as the node builder and its child processes do not
care too much about the context state while building nodes,
but this can be improved by injecting checks for ctx.Done()
before time-consuming steps.
2015-04-20 16:35:35 +02:00
Tor Arne Vestbø
cf6a268cd3 Handle ipfs command interruption by cancelling the command context
Instead of assuming the command is the daemon command and closing
the node, which resulted in bugs like #1053, we cancel the context
and let the context children detect the cancellation and gracefully
clean up after themselves.

The shutdown logging has been moved into the daemon command, where
it makes more sense, so that commands like ping will not print out
the same output on cancellation.
2015-04-20 16:35:35 +02:00
Tor Arne Vestbø
cc45e21e4c Teach http client to abort channel streaming on context cancellation
When the response includes the X-Chunked-Output header, we treat that
as channel output, and fire up a goroutine to decode the chunks. This
routine need to look for context cancellation so that it can exit
cleanly.
2015-04-20 16:35:35 +02:00
Tor Arne Vestbø
661fb0a4b5 Teach http client to cancel request on context cancellation
The context may be cancelled while a request is in flight. We need to
handle this and cancel the request. The code is based on the ideas
from https://blog.golang.org/context
2015-04-20 16:35:35 +02:00
Tor Arne Vestbø
3d05764262 Sync up request context with root context just before calling command
The context passed on from main() may change before we hit callCommand,
so setting it in Parse is a bit optimistic.
2015-04-20 16:35:35 +02:00
Tor Arne Vestbø
00a6e595ba main: wait for interrupt to finish before ending command invocation
If a command invocation such as 'daemon' is interrupted, the interrupt
handler asks the node to close. The closing of the node will result in
the command invocation finishing, and possibly returning from main()
before the interrupt handler is done. In particular, the info logging
that a graceful shutdown was completed may never reach reach stdout.

As the whole point of logging "Gracefully shut down." is to give
confidence when debugging that the shutdown was clean, this is
slightly unfortunate.

The interrupt handler needs to be set up in main() instead of Run(),
so that we can defer the closing of the interrupt handler until just
before returning from main, not when Run() returns with a streaming
result reader.
2015-04-20 16:35:30 +02:00
Juan Batiz-Benet
d7c91992a4 Merge pull request #1099 from ipfs/fix-randperm
core: bugfix: bootstrap random permutation
2015-04-20 06:13:36 -07:00
Juan Batiz-Benet
ce7914063f core: bugfix: bootstrap random permutation
the random permutaton for bootstrap peers was not working as
intended, returning the first four bootstrap peers always.
this commit fixes it to be a random subset.
2015-04-20 06:00:42 -07:00
Tor Arne Vestbø
6fe85496f5 corehttp: disable HTTP keep-alive when shutting down server
Once the server is asked to shut down, we stop accepting new
connections, but the 'manners' graceful shutdown will wait for
all existing connections closed to close before finishing.

For keep-alive connections this will never happen unless the
client detects that the server is shutting down through the
ipfs API itself, and closes the connection in response.

This is a problem e.g. with the webui's connections visualization,
which polls the swarm/peers endpoint once a second, and never
detects that the API server was shut down.

We can mitigate this by telling the server to disable keep-alive,
which will add a 'Connection: close' header to the next HTTP
response on the connection. A well behaving client should then
treat that correspondingly by closing the connection.

Unfortunately this doesn't happen immediately in all cases,
presumably depending on the keep-alive timeout of the browser
that set up the connection, but it's at least a step in the
right direction.
2015-04-20 14:55:42 +02:00
Tor Arne Vestbø
c9d3084910 corehttp: ensure node closing/teardown waits for server termination
When closing a node, the node itself only takes care of tearing down
its own children. As corehttp sets up a server based on a node, it
needs to also ensure that the server is accounted for when determining
if the node has been fully closed.
2015-04-20 14:55:42 +02:00
Tor Arne Vestbø
cc830ff2ee corehttp: log when server takes a long time to shut down
The server may stay alive for quite a while due to waiting on
open connections to close before shutting down. We should
find ways to terminate these connections in a more controlled
manner, but in the meantime it's helpful to be able to see
why a shutdown of the ipfs daemon is taking so long.
2015-04-20 14:55:42 +02:00
Tor Arne Vestbø
61efc4de1d Revert "fix ugly error message when killing commands"
This reverts commit f74e71f965.

The 'Online' flag of the command context does not seem to be set in
any code paths, at least not when running commands such as 'ipfs daemon'
or 'ipfs ping'. The result after f74e71f9 is that we never shutdown
cleanly, as we'll always os.Exit(0) from the interrupt handler.

The os.Exit(0) itself is also dubious, as conceptually the interrupt
handler should ask whatever is stalling to stop stalling, so that
main() can return like normal. Exiting with -1 in error cases where
the interrupt handler is unable to stop the stall is fine, but the
normal case of interrupting cleanly should exit through main().
2015-04-20 14:55:41 +02:00
Juan Batiz-Benet
b948bd65f9 version bump to 0.3.0
This commit includes a poor attempt at a changelog.
2015-04-20 05:10:45 -07:00
Juan Batiz-Benet
7e887b9191 Merge pull request #950 from ipfs/migrations
fsrepo migrations
2015-04-20 03:06:36 -07:00
Juan Batiz-Benet
dd25a75225 repo: move daemon.lock -> repo.lock
The "daemon.lock" was really a repo.lock, as the cli also took it
and the purpose was any process mutex. This is part of the 1-to-2
migration, and has already been handled in
https://github.com/ipfs/fs-repo-migrations/tree/master/ipfs-1-to-2
2015-04-20 02:26:34 -07:00
Juan Batiz-Benet
c1b8d292fb repo: clean up migration errors
Improved the repo migration errors to provide instructions
to the user.
2015-04-20 02:26:34 -07:00
Jeromy
bb7bf81873 put mfsr package back 2015-04-20 02:26:33 -07:00
Jeromy
591cca9507 remove migrations code from go-ipfs, in favor of fs-repo-migrations repo 2015-04-20 02:26:33 -07:00
Jeromy
c419a489e1 make ipfs understand the new migration 2015-04-20 02:26:33 -07:00
Christian Couder
96a22c5bb1 config: change default config dir name to .ipfs
This changes .go-ipfs to .ipfs everywhere.
And by the way this defines a DefaultPathName const
for this name.

License: MIT
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
2015-04-20 02:25:41 -07:00
Jeromy
f3fbedf312 no longer worry about moving key out of config file 2015-04-20 02:25:41 -07:00
Jeromy
2c79e5ddb5 add 1-to-2 migration program 2015-04-20 02:24:24 -07:00
Jeromy
e965c53780 remove / prefix and close directories properly in query 2015-04-20 02:24:23 -07:00
Tommi Virtanen
24daeec70c Use flatfs to store objects under /blocks outside of LevelDB
WARNING: No migration performed! That needs to come in a separate
commit, perhaps amended into this one.

Migration must move keyspace "/b" from leveldb to the flatfs subdir,
while removing the "b" prefix (keys should start with just "/").
2015-04-20 02:24:23 -07:00
Tommi Virtanen
4f4b894627 Update vendored go-datastore, now has flatfs and mount 2015-04-20 02:22:46 -07:00
Tommi Virtanen
59aa209164 Let FSRepo Close know explicitly about LevelDB
This allows replacing the datastore without needing to write Close
through to every wrapped datastore.
2015-04-20 02:22:46 -07:00
Tommi Virtanen
26cebac6d8 Remove comment referring to old code
FSRepo.Open is dead since fdd1cd8dc0
2015-04-20 02:21:49 -07:00
Tommi Virtanen
5cb8d80bb6 LevelDB is no longer "the" datastore, adjust identifiers 2015-04-20 02:21:49 -07:00
Juan Batiz-Benet
7eb4a92aba 0-to-1 fsrepo migration 2015-04-20 02:20:31 -07:00
Juan Batiz-Benet
c79dddd3d3 core: resolve error + bounds check
- handle error on "/ipns/"
- bounds-check, otherwise might cause a panic
2015-04-20 01:49:22 -07:00