Commit Graph

475 Commits

Author SHA1 Message Date
mpl e6dd735c20 cmd/pk: strip knownKeys from dumpconfig
Fixes #1204

Change-Id: If463b84d8250ed1b0f48e6ed24b7d37843f082cb
2018-09-26 02:00:19 +02:00
mpl 03a10b5c34 cmd/pk-mount: make -version flag actually work
Fixes #1219

Change-Id: I3eb81a3f3fdd9dbaabd3510e8d9d80e5b0ef4b8e
2018-09-24 20:12:12 +02:00
mpl 5ca78c73d2 cmd/pk-mount: add schema summary to doc
Change-Id: I516d6fe5c364b6eb1d7f8977a67791ca399d214e
2018-08-28 18:55:20 +02:00
Euan Kemp 1ca3a0443e pk-deploy: set logger to fix panic
Fixes #1206

Change-Id: Ifa4ba0d0face1f4ee176cbaed483ec173e7dbbb7
2018-08-13 10:29:36 -07:00
Brad Fitzpatrick 9d0472a968 Merge "pk/fs: add Logger, set it to discard when not debugging" 2018-05-19 02:44:04 +00:00
mpl 17c1685159 pk/fs: add Logger, set it to discard when not debugging
Change-Id: I66914d436b7e3d15416a8089fac0d1c1107ce13e
2018-05-16 20:08:56 +02:00
mpl 5789ec4b8d pkg/fs: add sha224-xx...xx hint dir
And fix sha1 assumption for file name.

Fixes #1169

Change-Id: I2a907c6cf11631a4a86268a4dc393c64402b5d35
2018-05-16 18:03:18 +02:00
Brad Fitzpatrick f3f38f0c76 perkeepd, serverinit, gce: opaque-ify serverinit.Config, trim camlistored.go
This change has two major parts, which were interwoven enough to do
them in one change:

1) make serverinit.Config fully opaque, in prep for TOML configs #1134

2) shrink the massive server/perkeepd/camlistored.go file. It was out
   of control and had a bunch of code that better belonged
   elsewhere. This change moves a few hundred lines of code from
   camlistored.go into more logical places: internal/osutil/gce for
   GCE stuff, serverinit for config stuff (KeyRingAndId), etc.

I also added a TODO to make it possible to compile perkeepd without
any GCE stuff, which I saw as a possible and worthy goal only after
moving everything away.

Updates #1134

Change-Id: Iea6f84c5aca9c70b97806f4a201ec35e0f630e3b
2018-05-13 15:50:10 -07:00
mpl b76a4f6727 internal/osutil: revert to using "test safe" func for identitySecretRing
And while we're at it, rename said func (CamliConfigDir) to
PerkeepConfigDir.

Fixes #1161

Change-Id: Ia8c9b5826046437b77c8e16ee91912e31ad319a3
2018-05-12 02:12:03 +02:00
mpl a4864af2b4 pk: fix get Describe that was copied from put
Change-Id: I4e166f2a1b37bdae4a10da2366dc23cfc8dcb054
2018-05-11 20:52:13 +02:00
Brad Fitzpatrick e621fc3e01 Merge "importer/feed: Add date fields to imported items" 2018-05-07 14:57:39 +00:00
Amanda Cameron 276137d656 importer/feed: Add date fields to imported items
This also changed a few of the magic strings in the SetAttrs call to use
the nodeattr constants.

One thing I'm unsure about is if "link" should be changed to
nodeattr.URL, but that's left out of this initial revision.

This also sneaks in a change to devimport that was blocking
the testing of the feed service, as it doesn't use authentication.

Fixes #1148

Change-Id: Ic3cf85dc30c446954f3780683cba99f118b46fb6
2018-05-07 08:32:16 -04:00
Paul Lindner 19079950b0 pkg/sorted/sqlite: default to using journal_mode=WAL
Remove explicit version checking using pkg-config and just check if
setting journal_mode=WAL succeeds.  Remove -wal command line
flag from pk tool and also remove duplicated logic for db
handling.

Fixes #840

Change-Id: I72874a5bb9c5bb3a7be552a65e5ddb0c12fd726e
2018-05-06 01:47:07 -07:00
Brad Fitzpatrick 789f861964 all: rename some references to .config/camlistore to .config/perkeep
Updates #981

Change-Id: Id76fe17d80380bdb973bc85ec8f54ba9500aff40
2018-05-02 21:36:29 -07:00
Brad Fitzpatrick f483cba421 cmdmain, cmd/pk: support for demoting prominence of some subcommands
We saw users get confused about the flood of help out of useless
commands like dbinit.

Change-Id: I627bd4f0e79abfcf2274626112d31c965c43396a
2018-05-02 13:48:04 -07:00
Brad Fitzpatrick 46bb719dc5 buildinfo: track Version and Dockerfile separately
And don't hard-code VERSION info in the Dockerfile.

Change-Id: I35cb22fbb56cd634be4f1342c54ca86ce0e79901
2018-05-02 13:36:32 -07:00
Brad Fitzpatrick 576dabac82 Merge "cmd/pk-mount: in debug mode, dump stacks on SIGQUIT" 2018-04-27 18:24:38 +00:00
Brad Fitzpatrick c5c5270dd0 cmd/pk-mount: in debug mode, dump stacks on SIGQUIT
Change-Id: I70737247bf29063a7061c330960b7657213266cb
2018-04-27 11:24:04 -07:00
Brad Fitzpatrick e52593865b cmd/pk-mount: default to mounting at /pk if it exists
And recommend /pk.

Change-Id: I5255c203e46b503a1b4c59856e085d7359d84f4f
2018-04-26 15:46:24 -07:00
mpl 7a27eb42eb cmd: rename camget to pk-get, and make it a mode of pk
A couple of related fixes and renames too.

Updates #981
Fixes #1056

Change-Id: Id47a933c77422edfb9db41d34c38ed9d0d7a1846
2018-04-22 20:50:54 -07:00
mpl 2bb666ccf6 all: rename remaining occurrences of camput
Also removed misc/buildbot while at it (which contained camput
references) since we don't use it anymore at all.

TODO: the OSX app seems to be relying on finding a binary in ../bin,
which we do not use anymore. This will probably need fixing.

Updates #981

Change-Id: I14220fbad2e81181330fca4bb2d2e5fe170e1bd6
2018-04-21 16:20:24 -07:00
Brad Fitzpatrick ca76a40bbc Rename camlistored to perkeepd.
Updates #981

Change-Id: I8fe43c240c149074c23128a89ab426af9cbf94b4
2018-04-21 11:06:09 -07:00
mpl ce4658abfc cmd: rename camput to pk-put, and make "pk put" call it
A new "put" mode is added to the pk command, so that the "pk put"
command can be used to create and upload blobs.

What this command does is actually just call the previously named
"camput" executable, which is renamed to "pk-put" in this change.

This involves adding a new way to register a mode in cmdmain, when such
a mode is just meant to call an external binary. To emphasize the
distinction, the existing func (to register a sub-command, or a mode) is
renamed from RegisterCommand to RegisterMode, and RegisterCommand is now
the name of the new func/way.

Updates #981
Updates #1056

Change-Id: Ief954c17aa88a376f551df7de4b4e9fe41ad96d1
2018-04-21 10:26:55 -07:00
Brad Fitzpatrick a13abdeb8c cmd/camput: add flag to specify hash function for raw blobs
Also a bit more logging around indexing in debug mode.

Change-Id: I2eb67cfec12cff102ba64b17de0369bde38e416a
2018-04-20 21:02:43 -07:00
Brad Fitzpatrick 27abfcced5 cmd/pk: make "search" command highlight position of JSON syntax errors
Change-Id: Ie63b32f9dee403b9a985e45a646ae1ece5d2cc7c
2018-04-20 20:30:18 -07:00
mpl 6dcbe2ee9c cmd/camtool: rename from camtool to pk
Updates #981
Updates #1056

Change-Id: Ib78c47a69fa9816d5ac6cc547586a2af321005e3
2018-03-06 16:20:59 +01:00
James Hillyerd 8c18a7bfec cmd/camtool: add "-1" flag to search subcommand
search -1 will output one blob ref per line instead of JSON, suitable
for piping into xargs.

Fixes #1034

Change-Id: I7bf812767fa9859ff5f5d98858abb688906f20f6
2018-02-28 11:36:09 -08:00
mpl db2604f981 pkg/schema: break static-sets in subsets for large directories
The current maximum size for a schema blob is 1MB. For a large enough
directory (~20000 children), the resulting static-set JSON schema is
over that maximum size.

We could increase that maximum, but we would eventually hit the maximum
blob size (16MB), which would only allow for ~300000 children. Even if
that is an uncommon size, it is technically possible to have such large
directories, so I don't think it would be reasonable to restrict users
to such a limit. So it does not seems like enough of a solution.

The solution proposed in this CL is to spread the children of a
directory (when they are more numerous than a given maximum, here set to
10000) onto several static-sets, recursively if needed. These
static-sets (subsets of the whole lot of children) are stored in the new
"mergeSets" field of their parent static-set schema. The actual fileRefs
or dirRefs, are still stored in the "members" field of the subset they were
spread in. The "mergeSets" and "members" field of a static-set are therefore
mutually exclusive.

Fixes #924

Change-Id: Ibe47b50795d5288fe904d3cce0cc7f780d313408
2018-02-09 01:36:38 +01:00
Mathieu Lonjaret 6e8a5930c9 all: make server advertise when it has legacy SHA-1 indexes, use that info
when its wholeref index lines contain any "sha1-" wholeref lines.

Then, have the client use that info when uploading files to also
compute the sha-1 (in addition to the sha-224) and ask the server for
both.

By client, we mean changes to cmd/camput, to pkg/client functions (for
camput and other Go clients, such as the apps), and to the web UI.

Also, add a -sha1 mode to devcam server, as well as the
CAMLI_SHA1_ENABLED env var, to facilitate testing/debugging of the
legacy sha1 mode.  Fix/document unrelated options in devcam server
while we're at it.

Change-Id: I369679d2a4719f6f8b409f78dd4d065e13a3f62f
2018-01-31 01:10:52 +01:00
Brad Fitzpatrick f9f109ffa1 all: more Camlistore to Perkeep renamings
Updates #981

Change-Id: I7fd4958bceaa4ada63d07aacf08af11cc03f32d7
2018-01-30 13:31:59 -08:00
Paul Lindner 459c75410e all: more renaming of Camlistore to Perkeep
Change-Id: I118e3cbcf20d80afeffc84f001388c4556f21628
2018-01-30 03:02:56 -08:00
Brad Fitzpatrick 66791480b0 cmd/client: remove NewStorageClient, convert to an option
Also fix some docs, rename some Camlistore to Perkeep, and make Close
close idle connections.

Change-Id: Ib903c7f01728d36b87301674094ca8967306cda1
2018-01-24 08:52:07 -08:00
Brad Fitzpatrick d4ff75359c pkg/client: reduce the number of New constructors, return error by default
This removes NewDefault and NewFromParams.

Now the default way to create a client is:

    client.New() -> (*Client, error)

Specifying a server is optional and now requires
client.OptionServer(server).

If the caller really wants to log.Fatal on error, they can use
client.NewOrFail.

Also, some of the boilerplate from GopherJS callers is now promoted to
be the default behavior in the client package.

Change-Id: Icb106cf3e13cc492fe5b2f7f240e1ad4227eaf33
2018-01-24 07:42:04 -08:00
Brad Fitzpatrick fc49db3967 cmd/camtool: add "camtool whoami" subcommand
Actually add the file, missing from previous commit
38c2a87ad2.

That's what I get for skipping code review. Sigh.

Change-Id: Icfaa7f6922c4ceaae69bd228b8d6498d0a85a7d8
2018-01-23 15:42:36 -08:00
Brad Fitzpatrick 38c2a87ad2 cmd/camtool: add "camtool whoami" subcommand
Also clean up and document the client package.

And misc cleanups.

Change-Id: I385d9948d8735deb37814ac45ac58851d8e58c75
2018-01-23 14:02:32 -08:00
Brad Fitzpatrick 8eec428c0a Merge "blobserver: add context to BlobRemover" 2018-01-23 18:33:20 +00:00
Paul Lindner 6d2d9714de all: simpify constructs by running gofmt -s on all code
Change-Id: Idc12ddcfe8f735d77c6baa942f5bb7a2c7d9b40b
2018-01-21 10:27:12 -08:00
Brad Fitzpatrick 66db09453f blobserver: add context to BlobRemover
Updates #733

Change-Id: I2fffb5cad59aa994441ee82ac5d940270113ee5a
2018-01-19 09:54:46 -08:00
Brad Fitzpatrick 194d4f9443 blobserver, all: add contexts to ReceiveBlob, Fetch & million resulting deps
I had intended for this to be a small change.

I was going to just add context.Context to the BlobReceiver interface,
but then I saw blob.Fetcher could also use one, so I decided to do two
in one CL.

And then it got a bit infectious and ended up touching everything.

I ended up doing SubFetch in the process by necessity.

At a certain point I finally started using context.TODO() in a few
spots, but not too many. But removing context.TODO() will come in the
future. There are more blob storage interfaces lacking context, too,
like RemoveBlobs.

Updates #733

Change-Id: Idf273180b3f8e397ac5929c6d7f520ccc5cdce08
2018-01-18 16:22:16 -08:00
mpl da9020ec71 cmd/camput: compact LevelDB on HaveCache setup
This CL is about levelDB as the HaveCache for camput, and there are
several aspects to it. To describe it, I'll take the particular example
where you want to add many permanodes (~33k) to a given set, with
camput. Something like:

for _, blob := range blobs {
	do("camput attr -add sha1-foobar camliMember " + blob)
}

In a "normal" levelDB use case, everytime the number of level-0 .ldb
files goes over 4 (by default), a background compaction task is
started to transform these SST into level-1 ones, and remove the level-0
ones.
However, since our particular camput call is very short lived
(especially on a local Perkeep), not only might there be not enough time
for the compaction to be triggered, but even if it is, when the DB is
flushed (on a Close call), any ongoing compactions are cancelled. This
makes level-0 compactions very unlikely to happen on short-lived camput
calls. As a result, the number of level-0 files keeps growing until
levelDB fails while trying to open them all, because it hits the current
process ulimit.

Now, in this CL, what we propose is to systematically force a compaction
as soon as the HaveCache is opened. It is not scheduled concurrently, so
we are sure that the compaction happens before the DB actually gets used
by camput. This seems to make sure that the number of level-0 tables
never grows too much. With this change, I was able to run the above
example on 33K blobs without hitting the ulimit error.

However, it should be noted that potential problems might remain. The
compaction for levels above 0 is triggered based only on the total size
of the level (e.g. at 100MB by default for level-1), and not on the
number of files. Since we're creating many tiny tables (basically 1
entry per table), the number of files grows very fast while the total
size does not, and the compaction does not get triggered, even if forced
with CompactRange. This does not seem to be a problem for our use case,
as levelDB does not seem to need to open many of the level-1 files at
the same time, so we're not hitting the ulimit problem because of that.

If needed, there's at least one way this problem (if it is one?) could
be fixed: make the compaction trigger on other conditions, such as
number of files per level. I've experimented with it (forcing the
level-1 compaction to trigger at the 100 files limit), and it seems to
be working. But I had to do change the goleveldb code itself, and I
don't think levelDB implementations are supposed to do that.

For information, at the end of the run on the 33K blobs:
$ du -sch *.ldb
...
83M	total
$ ll | wc -l
20988

And indeed, when asking for leveldb.stats on the table:
 Level |   Tables   |    Size(MB)   |
-------+------------+---------------+
   0   |          1 |       0.00015 |
   1   |      20981 |       3.47307 |

Also, update github.com/syndtr/goleveldb to
34011bf325bce385408353a30b101fe5e923eb6e
And remove github.com/syndtr/gosnappy as goleveldb does not use it
anymore.

Also apply this change to StatCache.

Fixes #1008

Change-Id: If9f790a003e67f3c075881470e52e5f2174afa73
2018-01-16 00:46:11 +01:00
Paul Lindner d35f919539 vendor/github.com/go-sql-driver/mysql: upgrade to v1.3.0
Upgrades mysql driver to a versioned release, fixes a minor issue
in dbinit that caused SHOW DATABASES queries to fail and improves
error messages to help diagnose such problems.

Changelog: vendor/github.com/go-sql-driver/mysql/CHANGELOG.md
Revision: go-sql-driver/mysql@a0583e0143

Change-Id: I4f5fdee60b30eca85564c452f72774e9c15828f3
2018-01-12 10:02:14 -08:00
Brad Fitzpatrick 38f10a7bd0 all, testhooks: use sha224 by default, add hook for some tests to use sha-1
Remove the blob.SHA{1,224}From{Bytes,String} constructors too. No
longer used. This adds blob.RefFromBytes which was missing. We had
blob.RefFromString. Now everything uses blob.RefFrom* instead of
specifying a hash function.

Some tests set a flag to force use of SHA-1 because there was too much
golden data to update. We can remove those one-by-one over time as we
fix up tests.

Updates #537

Change-Id: Ibe6428089a6221594c2b751f53f98b03b5a28dc2
2018-01-09 20:03:38 -08:00
Brad Fitzpatrick 0e8980b54b blobserver: change BlobStatter interface, simplify proxycache
This addresses a long-standing TODO in the BlobStatter interface to
clean it up. Just like all new Go programmers, I misused channels in
APIs. I should've cleaned this up years ago.

While here, I also added a context.

The rest should get contexts later.

This also cleans up a few things here & there.

The pkg/client statting no longer does batching, which added a lot of
complexity. There was a comment saying something like "once we have
SPDY, we can delete this". Well, we have HTTP/2 now, so seems
deletable.

All tests pass.

Change-Id: I034ce07d9b70e5cc9e5482213368993e638d4bc8
2018-01-08 16:54:52 -08:00
Brad Fitzpatrick 27bacd3df1 pkg/blob, all: support SHA-224 blobrefs, make them the default
Updates #537

Change-Id: I3966697cbdb05ca4b380974be604deebdaa258c2
2018-01-08 16:34:41 -08:00
Brad Fitzpatrick 617ac40512 all: rename cammount to pk-mount
Updates #981

Change-Id: Ie1d2e3c0fd7e2b7a7801ceac0fd8f93f62d56651
2018-01-08 09:54:41 -08:00
Brad Fitzpatrick 57648c6b83 all: update copyright holder from Google Inc to The Perkeep Authors
The AUTHORS file is the list of copyright holders.
2018-01-03 16:52:49 -08:00
Paul Lindner d5b55e51a8 Merge "all: update mongo to latest version" 2018-01-03 21:04:12 +00:00
Paul Lindner 49b1af4a1b all: update mongo to latest version
The mongo integration was using a very old package.  It's using
a new namespace now.  Upgrade and adjust all call points

Removes labix.org/v2/mgo

Introduces gopkg.in/mgo.v2 from branch v2 with revision
  3f83fa5005286a7fe593b055f0d7771a7dce4655

Change-Id: I2784fca941998460f58e0ac8d3d51286401590b5
2018-01-03 10:49:07 -08:00
Brad Fitzpatrick 8a0a3e8649 Rename camdeploy to pk-deploy.
Updates #981

Change-Id: I4c6c16135f3239bb4b8d2d187e9537a4abf7a3fe
2018-01-02 22:10:37 -08:00
Brad Fitzpatrick c3d05cdce9 Move more packages out of pkg/ and into internal/
Moved hashutil, httputil, osutil, netutil,
images, media, magic, video, and rollsum.
2018-01-02 21:03:30 -08:00