metadata: define content sharing policy
This changeset modifies the metadata store to allow one to set a
"content sharing policy" that defines how blobs are shared between
namespaces in the content store.
The default mode "shared" will make blobs available in all namespaces
once it is pulled into any namespace. The blob will be pulled into
the namespace if a writer is opened with the "Expected" digest that
is already present in the backend.
The alternative mode, "isolated" requires that clients prove they have
access to the content by providing all of the content to the ingest
before the blob is added to the namespace.
Both modes share backing data, while "shared" will reduce total
bandwidth across namespaces, at the cost of allowing access to any
blob just by knowing its digest.
Note: Most functional codes and changelog of this commit originate from
Stephen J Day <stephen.day@docker.com>, see
40455aade8
Fixes #1713 Fixes #2865
Signed-off-by: Eric Lin <linxiulei@gmail.com>
This commit is contained in:
@@ -36,7 +36,7 @@ import (
|
||||
bolt "go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
func createContentStore(ctx context.Context, root string) (context.Context, content.Store, func() error, error) {
|
||||
func createContentStore(ctx context.Context, root string, opts ...DBOpt) (context.Context, content.Store, func() error, error) {
|
||||
// TODO: Use mocked or in-memory store
|
||||
cs, err := local.NewStore(root)
|
||||
if err != nil {
|
||||
@@ -60,13 +60,24 @@ func createContentStore(ctx context.Context, root string) (context.Context, cont
|
||||
}
|
||||
ctx = testsuite.SetContextWrapper(ctx, wrap)
|
||||
|
||||
return ctx, NewDB(db, cs, nil).ContentStore(), func() error {
|
||||
return ctx, NewDB(db, cs, nil, opts...).ContentStore(), func() error {
|
||||
return db.Close()
|
||||
}, nil
|
||||
}
|
||||
|
||||
func createContentStoreWithPolicy(opts ...DBOpt) testsuite.StoreInitFn {
|
||||
return func(ctx context.Context, root string) (context.Context, content.Store, func() error, error) {
|
||||
return createContentStore(ctx, root, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContent(t *testing.T) {
|
||||
testsuite.ContentSuite(t, "metadata", createContentStore)
|
||||
testsuite.ContentSuite(t, "metadata", createContentStoreWithPolicy())
|
||||
testsuite.ContentCrossNSSharedSuite(t, "metadata", createContentStoreWithPolicy())
|
||||
testsuite.ContentCrossNSIsolatedSuite(
|
||||
t, "metadata", createContentStoreWithPolicy([]DBOpt{
|
||||
WithPolicyIsolated,
|
||||
}...))
|
||||
}
|
||||
|
||||
func TestContentLeased(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user