Commit Graph

6178 Commits

Author SHA1 Message Date
mpl 6f5a718ad1 cmd/camget: update client share chain when getting blobs from cache
When fetching shared blobs, we rely on the share chain to verify if a
blob can be reached. This chain is updated whenever we fetch an
additional link of the chain, by updating the Client.via map. However,
when some blobs of the chain are already cached in camget's DiskCache,
because we get them from the cache, we don't fetch them with
Client.FetchVia, which means the Client.via map isn't updated. And thus
the chain is broken.

This change adds Client.UpdateShareChain, and sets it as a hook to be
called by the CachingFetcher in the event of a cache hit. That way, we
ensure that the share chain is updated even when we get blobs from the
cache (instead of from the Client).

We also add a mutex to guard Client.via, because it is accessed by
concurrent smartFetch calls in case of a static-set.

As FetchVia was undocumented and not used by anyone, I made it
unexported. We can always export it again later when needed.

Fixes #856

Change-Id: I767cbec4b6f382cbccc25c0b97782b2a7472deb8
2016-09-26 19:03:04 +02:00
mpl 5b5065cff1 travis CI: update to go 1.7
Change-Id: Ie75074cb179a0ff357763f14a4b0bbb7677f94ad
2016-09-19 15:50:52 +02:00
Brad Fitzpatrick 3dedf3c72f Merge "search: add location info to DescribedBlob" 2016-09-16 19:34:00 +00:00
Brad Fitzpatrick 2d186e7773 Merge "index: add ClaimsAttrValue" 2016-09-16 19:33:53 +00:00
mpl 27b2442475 vendor: add google.golang.org/api/internal
at rev 63cb68f1e3834e44683ca062ddf06cb9a889380a

Forgot to add it to the commit at
ab06dbd80d

Fixes #854

Change-Id: Ic8a9a3d0fd279b2bcf20c1dd77bee56512ae3f39
2016-09-09 12:34:45 +02:00
mpl ab06dbd80d vendor: rename google.golang.org/cloud to cloud.google.com/go
rm google.golang.org/cloud
add cloud.google.com/go at a47b182e769f5e75f5fc927ff6ee2678f7f552cf
update google.golang.org/api to 63cb68f1e3834e44683ca062ddf06cb9a889380a
update google.golang.org/grpc to
0e6ec3a4501ee9ee2d023abe92e436fd04ed4081
update go4.org to f5283521d7365fb2875408726e9cbf349f173767

fix in cmd/ pkg/ server/

TODO(mpl): fix misc/docker tools as well. next CL.

Fixes #832

Change-Id: I842b968a0afea8a5822913bd614d67cdbe50ee63
2016-09-08 15:14:12 +02:00
Mathieu Lonjaret 03c34141e3 Merge "pkg/index: use mime.TypeByExtension to record MIMEType" 2016-09-06 20:57:48 +00:00
Mathieu Lonjaret be6d657dde Merge "website: clean up previous docker git container" 2016-09-06 14:35:32 +00:00
mpl 25652d66d9 pkg/index: use mime.TypeByExtension to record MIMEType
When receiving a file, we were only trying to guess its MIME type
through its contents (pkg/magic). We're now making a better effort at it
by guessing from the filename extension if needed.

Also:

pkg/magic: get rid of all the extra video extensions that are already
covered by mime.TypeByExtension. Because it's redundant and
confusing.

app/publisher, pkg/types/camtypes: also use mime.TypeByExtension as an
extra effort. Especially since a reindex would be necessary to benefit
from the pkg/index change.
There are other places in Camlistore that could use such an effort.
Maybe we should have a camtypes.*FileInfo.MIME() method that tries all
the ways to guess the MIME type of the file?

Change-Id: Ib9a2bc42af77c5394dac578ae415524b5111ad4e
2016-09-06 16:26:09 +02:00
mpl 2ab4d44e79 website: clean up previous docker git container
All the camweb features depending on docker had been stuck for a couple
of weeks because one of the docker containers was wedged somehow. I
don't know exactly what was wrong, but I figure it can't hurt to add the
same kind of cleanup that we have for the demo blobserver.

So in this CL, we name each container running a git command, so we can
stop and remove said container the next time we run the same command.

Change-Id: I66592fbbde73ea30e4cee7477ada450e0c6a645e
2016-09-05 23:51:41 +02:00
Mathieu Lonjaret b185fcdd10 Merge "android: build client with Go 1.7" 2016-09-05 20:32:09 +00:00
Tilman Dilo 555cc5fca6 android: build client with Go 1.7
Change-Id: I7736a10a6a3e30408643e678b7f8fc942f028ff7
2016-09-05 21:53:29 +02:00
mpl e44c2571e0 website: monthly release: 10aa2b3fbd
Change-Id: I5e51a72777352c8112f4e929865458f71e83e2fd
2016-09-05 19:01:50 +02:00
mpl 10aa2b3fbd make.go: use host GOOS and GOARCH when go generating zsearch.go
Because our go generate line is:
//go:generate go run gensearchtypes.go -out zsearch.go

which will run a binary of gensearchtypes.go built for whatever $GOOS is
set to. Which will fail if $GOOS is different from runtime.GOOS (the
cross-compiling case).

I suppose it means that the day pkg/search becomes GOOS differentiated,
we may have to introduce an -os flag to gensearchtypes.go, since it
calls go doc on camlistore.org/pkg/search, whose output might depend on
GOOS?

Change-Id: I1ea32bb9190300120887ee8614dcdd2d1391a954
2016-09-05 18:40:10 +02:00
mpl a75f7e6c63 misc/docker: gensearchtypes.sh does not exist anymore
follow-up of f802f031cc

Change-Id: I4b30e84b98292bc79e2e4b55708711f30ec94fb6
2016-09-05 16:50:06 +02:00
Mathieu Lonjaret d44b7db944 Merge "app/publisher: rewrite gensearchtypes.sh as gensearchtypes.go" 2016-09-05 14:22:58 +00:00
mpl 4fc061e8a2 pkg/server/app: refresh cached domain blobs on 403
To decide whether a search submitted to the app search proxy is allowed,
we compare its results to the domain blobs, result of the master query,
that we cache when the master query is set.

However, since the results of the master query are liable to change when
new blobs arrive (e.g. a new camliMember is added to the set that is
published), that cache may need to be invalidated. Otherwise, we might
reply with a 403 to search query that is actually allowed.

Therefore, this CL adds a refresh of the cache on two instances:

-When the app handler gets a search query that seems to be forbidden.
Before replying with a 403, we refresh the cache with the master query,
and recheck whether the search query is allowed.

-When the publisher gets a request for a "members" page, or the "file"
page, it preemptively asks the app handler to refresh. Now that a lot of
the client workflow has been moved to javascript/the browser, these
kinds of requests should not happen too often, so it seems a reasonable
place to ask for a refresh. But this might change, so we should of
course be careful not to flood the app handler with refresh requests in
the future.

In any case, the app handler is suppressing the refresh requests, so
that it does not perform refreshes at more that one per minute.

As a smarter approach, we could later imagine a way for the app handler
to be aware of when new blobs get to the blobserver (akin to the blob
hub that the sync handler uses?), so that it only ever refreshes when
needed.

Fixes #851

Change-Id: Idc14cce5018053deac01ec454e5c936ed93e5a05
2016-09-02 18:40:42 +02:00
Attila Tajti 8b4c324adb search: add location info to DescribedBlob
Add Handler.GetPermanodeLocation, based on the existing logic of loc:* and has:loc
search predicates, and that of index/Corpus.PermanodeLatLong:
  1. Permanode attributes "latitude" and "longitude"
  2. Referenced permanode attributes (eg. for "foursquare.com:checkin"
     its "foursquareVenuePermanode")
  3. Location in permanode camliContent file metadata
 The sources are checked in this order, the location from
 the first source yielding a valid result is returned.

camtypes: add new Location type

index: Add GetFileLocation to Index/Interface, to make
indexed location info accessible without a corpus.
This was unlike other file metadata like image info or media tags
which had accessors in both Index and Corpus.

Fixes #777

Change-Id: I63cf143d67a12732ca2c941de64b63736be5de6e
2016-09-02 11:28:39 +02:00
Tamás Gulácsi f802f031cc app/publisher: rewrite gensearchtypes.sh as gensearchtypes.go
This fixes make.go on systems without a POSIX shell,
such as Windows.

Fixes #848.

Change-Id: I8ba7befa08bd545095677655f8489614449d7692
2016-09-02 11:11:26 +02:00
mpl bf001df550 app/publisher: serve text types with their right MIMEs
So far only images were served with their MIME types set properly, so
they would display directly in the browser, instead of being served as a
file download.

Now the same is done for a subset of text types: i.e. text/plain,
text/html, text/xml, and text/json. Aside from the browsing convenience,
the obvious advantage is being able to serve HTML directly, which should
allow us to build other things on top of the publisher.

Also a bit of related refactoring: moving the extension matching to
pkg/magic

Change-Id: Id98065c7c685036a272d1d2e293bfcbca33015ee
2016-09-01 02:06:44 +02:00
mpl bcb5fca493 pkg/sorted: log and skip on too large a key/value
So far we were returning an error, which appears to be a little too
strict, so we now just ignore when a key or value is too large, log it,
and go on.

Fixes #849

Change-Id: Iadd4eaab7459643e22ab3043d1f45e3eab662b30
2016-08-31 17:51:52 +02:00
mpl 2f4a94bca6 misc/docker: chmod u+x on gensearchtypes.sh
Because docker unpacks the file without its +x, which makes go generate
fail when trying to execute it.

Change-Id: I9998b849110437c6faff89090f5dbe98fe2f2c9b
2016-08-31 02:29:10 +02:00
mpl cda8c932d6 misc/docker: Go1.7
Change-Id: I861c91e919b46862037b1fad8cc89e964d4f221c
2016-08-31 01:20:34 +02:00
mpl 0016221f8c config/config/dev-server-config.json: fix SourceRoot for publisher
This should have been done with
0367de7b61

Change-Id: Icc7ab39fa0220c757781cc108e5243d4193e78d1
2016-08-30 18:42:14 +02:00
mpl 5bc0864f81 Switch to Go1.7
vendoring: update gopherjs to rev
45518c130e5bd1525f20110830a4986365a153de

Patch on upstream to remove fsnotify dep added (for reference) as:
vendor/github.com/gopherjs/gopherjs/nofsnotify.diff

make.go: make Go1.7 the required version

Fixes #838

Change-Id: I2013ee4832a26f8be3a8b42f02e40a347674ec9a
2016-08-30 16:46:07 +02:00
mpl 64ca2c47d0 pkg/server/app: do not mutate r.URL.Path
Since the app handler should not trim the r.URL.Path of the handler's
prefix, it is now the responsibility of the app to cope with that
prefix.

Fixes #833

Change-Id: Ie1fa9801b26767c3e3b6612498380261e22cdf07
2016-08-30 01:39:16 +02:00
Mathieu Lonjaret b02ea7db7d Merge "pkg/server/app: proxy search requests for publisher" 2016-08-29 21:23:16 +00:00
mpl 3df678b010 pkg/server/app: proxy search requests for publisher
Some of the publisher features have moved from the server-side app to
the client-side app (the browser) thanks to gopherjs. Some of these
features imply doing some search queries against Camlistore, which
requires authentication. The server-side app receives the necessary
credentials on creation, from Camlistore. However, we can't just
communicate them to the client-side (as we do with the web UI) since the
publisher app itself does not require any auth and is supposed to be
exposed to the world.

Therefore, we need to allow some search queries to be done without
authentication.

To this end, the app handler on Camlistore now assumes a new role: it is
also a search proxy for the app. The app sends an unauthenticated search
query to the app handler (instead of directly to the search handler),
and it is the role of the app handler to verify that this query is
allowed for the app, and if yes, to forward the search to the Camlistore's
search handler.

We introduce a new mechanism to filter the search queries in the form of
a master query. Upon startup, the publisher registers, using the new
CAMLI_APP_MASTERQUERY_URL env var, a *search.SearchQuery with the app
handler. The app handler runs that query and caches all the blob refs
included in the response to that query. In the following, all incoming
search queries are run by the app handler, which checks that none of the
response blobs are out of the set defined by the aforementioned cached
blob refs. If that check fails, the search response is not forwarded to
the app/client.

The process can be improved in a subsequent CL (or patchset), with finer
grained domains, i.e. a master search query per published camliPath,
instead of one for the whole app handler.

Change-Id: I00d91ff73e0cbe78744bfae9878077dc3a8521f4
2016-08-29 19:14:19 +02:00
Attila Tajti 8c30e24b77 vendor/github.com/spf13/cobra: remove mousetrap dep
This fixes building gopherjs on Windows.

Fixes #844

Change-Id: Ibb4dee707bcf565a36fd7d90e92198ca952df435
2016-08-29 17:51:28 +02:00
Attila Tajti b5bdb7d502 index: add ClaimsAttrValue
ClaimsAttrValue can be used in clients of pkg index, such
as in search on values returned by Index.AppendClaims to
query permanode attributes.

Related: issue #777

Change-Id: I5a8fa2a970d88f9ddbcc3de350215a196e124b64
2016-08-27 07:42:59 +02:00
mpl f9ab7f3897 pkg/search: rename Describe to StartDescribe
And clarify doc.

Change-Id: I31a8de35cf29086b3b4c3f67bd14701b10fbc833
2016-08-27 02:01:28 +02:00
Mathieu Lonjaret 61f3cd059e Merge "make.go: do not cross-compile gopherjs" 2016-08-26 23:49:22 +00:00
mpl bccc0ff7a1 make.go: do not cross-compile gopherjs
Because it needs to run on the native platform, not the one we
cross-compile to.

Fixes #845

Change-Id: Iffaeab8d02dacecc0c1dd579481219c6a542b1b2
2016-08-27 01:48:04 +02:00
Brad Fitzpatrick 315fa6f3d9 search: fix describe race
For a given DescribeRequest, allow only one describer in flight per
blobRef.

Fixes #846

Change-Id: Ief42eb568df5eb8dfa5d2e3b2710f3511f9f055e
2016-08-27 00:13:09 +02:00
mpl ee421c8eb2 pkg/search: use the right method for locking the index
Since probably e93e4f3822 we've been using
(*search.Handler).DescribeLocked instead of
(*search.Handler).Describe when serving describe queries, so the index
was never locked :(

I was so focused on debugging the recursions in describeReally that I
missed that elephant in the room.

I still think the Describe and describeReally recursions protected by
dr.wg is too complicated but that's for another CL.

Fixes #750

Change-Id: I376ee0f807df68ad1ef3752f944edc7c9bdb92ee
2016-08-26 02:24:35 +02:00
Mathieu Lonjaret 55a0748c37 Merge "search: add query and describe benchmarks" 2016-08-24 23:21:16 +00:00
Mathieu Lonjaret 7ef7c34a7c Merge "pkg/search: lock index for corpus creation" 2016-08-24 21:11:19 +00:00
mpl 4e1aab1136 pkg/search: lock index for corpus creation
As soon as the (bs->index) sync handler is initialized, it starts
writing pending blobs to the index. However, so far the corpus
initialization has been left, unguarded, up to the search handler. Which
means lots of potential data races on the corpus fields between the sync
handler writing a blob to the index, and the search handler creating all
the pieces of the corpus itself.

This change fixes the issue by locking the index while the search
handler is creating the corpus.

This change does not entirely fix issue #750, as there seems to be yet
another data race going on, but it is related as the fixed race was
found thanks to the race trace at:
https://github.com/camlistore/camlistore/issues/750#issuecomment-241881987

Change-Id: I6de0165064a4f8934466f6a08710b4962f7b0256
2016-08-24 23:08:19 +02:00
mpl 0367de7b61 publisher: restore SourceRoot configurability
This change allows the publisher to use resources from a SourceRoot
directory, without having to rebuild the publisher binary, instead of
only using embedded resources.

Change-Id: Ife29e3015b8595a33f175a62d98fcf5ffa689134
2016-08-22 21:51:58 +02:00
Attila Tajti 06036c2612 search: add query and describe benchmarks
Change-Id: I21e0199a0209a47d2e24fc3adf1dbf08f8d3be75
2016-08-22 20:42:48 +02:00
Mathieu Lonjaret 588d31044e Merge "pkg/search: optimize file search by wholeRef" 2016-08-19 19:27:43 +00:00
mpl e321eb75d5 camput: replace kv with leveldb for stat/havecache
Fixes #382

Change-Id: I9600049395c706f84f284fd7c774c3101a8eaf6d
2016-08-19 00:10:09 +02:00
mpl f279013f65 pkg/search: optimize file search by wholeRef
Issue #684

Change-Id: Id1e317df36172bdcc21906339c46ece898d4d023
2016-08-18 18:32:23 +02:00
Mathieu Lonjaret 108f4b7f61 Merge "pkg/blobserver/localdisk: gate tmp file creations" 2016-08-17 16:25:37 +00:00
mpl 2d87c79abb pkg/blobserver/localdisk: gate tmp file creations
To avoid tmp file creation errors due to ulimit.

A different, more flexible, approach was discussed on
https://github.com/camlistore/camlistore/issues/812 , and could be
implemented later on if the current CL is too naive.

As a follow-up, issue #837 should be then fixed.

Fixes #812

Change-Id: I2590fdac137b0e8711a6a1bf4ba8a32259496515
2016-08-17 18:24:30 +02:00
mpl c052bd2804 web UI: upload with input file button
Fixes #830

Change-Id: Ic69fb7e6edc6a0dc0d604356f0214aaf6c8136a9
2016-08-16 18:18:56 +02:00
Mathieu Lonjaret ab25a2c2fc Merge "pkg/sorted/mysql: fix detection of outdated database schema" 2016-08-09 17:09:23 +00:00
mpl fb6fe83535 pkg/sorted/mysql: fix detection of outdated database schema
Regardless of whether the database tables are newly created, we were
_always_ stamping the database schema version in the meta table BEFORE
doing the database version check. Which means said check was actually
useless.

Also add a small sanity check of the database name.

Issue #806

Change-Id: I85e19ef7583ebd5ef1043a6deb0fe61abaa4d190
2016-08-06 01:17:41 +02:00
Mathieu Lonjaret 41516af23d Merge "config: used leveldb for the dev server instead of kv" 2016-08-05 14:55:18 +00:00
mpl 120dce4efc config: used leveldb for the dev server instead of kv
Related: issue #779

Change-Id: I97dedc19eb9a4562bdde2ac6dcef7f3d706acd38
2016-08-05 16:53:04 +02:00