1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 05:52:20 +08:00

3950 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
61efc4de1d Revert "fix ugly error message when killing commands"
This reverts commit f74e71f96545b14f5293c9851ce624aecddb68aa.

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
b948bd65f9 version bump to 0.3.0
This commit includes a poor attempt at a changelog.
2015-04-20 05:10:45 -07:00
7e887b9191 Merge pull request #950 from ipfs/migrations
fsrepo migrations
2015-04-20 03:06:36 -07:00
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
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
bb7bf81873 put mfsr package back 2015-04-20 02:26:33 -07:00
591cca9507 remove migrations code from go-ipfs, in favor of fs-repo-migrations repo 2015-04-20 02:26:33 -07:00
c419a489e1 make ipfs understand the new migration 2015-04-20 02:26:33 -07:00
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
f3fbedf312 no longer worry about moving key out of config file 2015-04-20 02:25:41 -07:00
2c79e5ddb5 add 1-to-2 migration program 2015-04-20 02:24:24 -07:00
e965c53780 remove / prefix and close directories properly in query 2015-04-20 02:24:23 -07:00
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
4f4b894627 Update vendored go-datastore, now has flatfs and mount 2015-04-20 02:22:46 -07:00
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
26cebac6d8 Remove comment referring to old code
FSRepo.Open is dead since fdd1cd8dc045db90b06497a15df7f6f232f76bda
2015-04-20 02:21:49 -07:00
5cb8d80bb6 LevelDB is no longer "the" datastore, adjust identifiers 2015-04-20 02:21:49 -07:00
7eb4a92aba 0-to-1 fsrepo migration 2015-04-20 02:20:31 -07:00
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
928581c9e7 Merge pull request #1071 from ipfs/add-err-fix
cmds/add: silent error fix
2015-04-20 01:48:54 -07:00
c75a2938a9 Merge pull request #1080 from gatesvp/iss750
Iss750
2015-04-20 01:27:30 -07:00
218aeeb77e cmds/add: silent error fix 2015-04-20 01:18:42 -07:00
31ff954539 Move IPNS resolutions into the core library
Move IPNS resolutions into the core library via the pathresolver.go
file. Fix the CLI commands to leverage this core component.
2015-04-20 01:04:30 -07:00
7bba80041c Merge pull request #1098 from ipfs/rm-debugerror
remove debugerrors
2015-04-20 00:55:40 -07:00
140cd1fd1b remove debugerrors
We now consider debugerrors harmful: we've run into cases where
debugerror.Wrap() hid valuable error information (err == io.EOF?).
I've removed them from the main code, but left them in some tests.
Go errors are lacking, but unfortunately, this isn't the solution.

It is possible that debugerros.New or debugerrors.Errorf should
remain still (i.e. only remove debugerrors.Wrap) but we don't use
these errors often enough to keep.
2015-04-20 00:35:35 -07:00
b483fdc948 Merge pull request #1010 from ipfs/fix/pin-bug
fix pinning
2015-04-20 00:21:05 -07:00
ef56f4f83b functions dont need to be called functions 2015-04-19 23:40:25 -07:00
0a6b880bee fix for #1008 and other pinning fixes
This commit adds a new set of sharness tests for pinning, and addresses
bugs that were pointed out by said tests.

test/sharness: added more pinning tests

Pinning is currently broken. See issue #1051. This commit introduces
a few more pinning tests. These are by no means exhaustive, but
definitely surface the present problems going on. I believe these
tests are correct, but not sure. Pushing them as failing so that
pinning is fixed in this PR.

make pinning and merkledag.Get take contexts

improve 'add' commands usage of pinning

FIXUP: fix 'pin lists look good'

ipfs-pin-stat simple script to help check pinning

This is a simple shell script to help check pinning.

We ought to strive towards making adding commands this easy.
The http api is great and powerful, but our setup right now
gets in the way. Perhaps we can clean up that area.

updated t0081-repo-pinning

- fixed a couple bugs with the tests
- made it a bit clearer (still a lot going on)
- the remaining tests are correct and highlight a problem with
  pinning. Namely, that recursive pinning is buggy. At least:
  towards the end of the test, $HASH_DIR4 and $HASH_FILE4 should
  be pinned indirectly, but they're not. And thus get gc-ed out.
  There may be other problems too.

cc @whyrusleeping

fix grep params for context deadline check

fix bugs in pin and pin tests

check for block local before checking recursive pin
2015-04-19 23:40:25 -07:00
d23647ed39 Merge pull request #947 from hosh/hosh/fuse-docs
DOCS: Updated FUSE docs
2015-04-19 15:42:28 -07:00
c67fc2a286 Merge pull request #1015 from ipfs/merkledag-link-manipulation
Add additional link manipulation functions
2015-04-19 15:39:54 -07:00
c0c4fd3842 Merge pull request #1085 from ipfs/bloomfilter-hamming-distance
Add hamming distance calculation to bloom filters
2015-04-19 15:23:48 -07:00
ff34efba75 re-vendored hamming lib with license 2015-04-19 13:59:56 -07:00
e817852424 Merge pull request #1091 from ipfs/bitswap-perf
add more bitswap task workers
2015-04-19 13:29:51 -07:00
43eeab9549 change env var for bitswap
changed IPFS_TASK_WORKERS to IPFS_BITSWAP_TASK_WORKERS
2015-04-19 13:10:43 -07:00
16e04356b9 address comments from CR 2015-04-19 11:19:51 -07:00
3629d7d548 make number of workers tuneable by an env var 2015-04-17 15:57:50 -07:00
3178dfe78b add more bitswap task workers 2015-04-17 12:43:31 -07:00
a97e9e70c7 Merge pull request #1087 from ipfs/bitswap-perf
increase window size for yamux streams
2015-04-17 01:33:52 -07:00
30ee01f19d increase window size for yamux streams 2015-04-16 20:56:40 -07:00
20383472c7 Add additional link manipulation functions
// AddRawLink adds a link to this node
AddRawLink(name string, lnk *Link) error

// Return a copy of the link with given name
GetNodeLink(name string) (*Link, error)
2015-04-15 17:22:52 +02:00
2c3f9f2419 Add hamming distance calculation to bloom filters 2015-04-15 17:13:47 +02:00
240633414e Merge pull request #1079 from ipfs/chriscool-readme-fix-todo
README: alpha version has been released
2015-04-14 09:21:14 -07:00