Revert "snapshot/storage: namespace snapshot drivers"
This reverts commit b1a70aa335.
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/snapshot"
|
||||
db "github.com/containerd/containerd/snapshot/storage/proto"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
@@ -138,7 +137,7 @@ func CreateActive(ctx context.Context, key, parent string, readonly bool) (a Act
|
||||
return errors.Wrapf(errdefs.ErrAlreadyExists, "snapshot %v", key)
|
||||
}
|
||||
|
||||
id, err := nextSequence(ctx)
|
||||
id, err := bkt.NextSequence()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to get identifier")
|
||||
}
|
||||
@@ -311,68 +310,28 @@ func CommitActive(ctx context.Context, key, name string, usage snapshot.Usage) (
|
||||
return
|
||||
}
|
||||
|
||||
// nextSequence maintains the snapshot ids in the same space across namespaces
|
||||
// to avoid collisions on the filesystem, which is typically not namespace
|
||||
// aware. This will also be useful to ensure that snapshots can be used across
|
||||
// namespaces in the future, by projecting parent relationships into an
|
||||
// alternate namespace without fixing up identifiers.
|
||||
func nextSequence(ctx context.Context) (uint64, error) {
|
||||
t, ok := ctx.Value(transactionKey{}).(*boltFileTransactor)
|
||||
if !ok {
|
||||
return 0, ErrNoTransaction
|
||||
}
|
||||
|
||||
bkt := t.tx.Bucket(bucketKeyStorageVersion)
|
||||
if bkt == nil {
|
||||
return 0, errors.New("version bucket required for sequence")
|
||||
}
|
||||
|
||||
return bkt.NextSequence()
|
||||
}
|
||||
|
||||
func withBucket(ctx context.Context, fn func(context.Context, *bolt.Bucket, *bolt.Bucket) error) error {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t, ok := ctx.Value(transactionKey{}).(*boltFileTransactor)
|
||||
if !ok {
|
||||
return ErrNoTransaction
|
||||
}
|
||||
nbkt := t.tx.Bucket(bucketKeyStorageVersion)
|
||||
if nbkt == nil {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "bucket does not exist")
|
||||
}
|
||||
|
||||
bkt := nbkt.Bucket([]byte(namespace))
|
||||
bkt := t.tx.Bucket(bucketKeyStorageVersion)
|
||||
if bkt == nil {
|
||||
return errors.Wrapf(errdefs.ErrNotFound, "namespace not available in snapshotter")
|
||||
return errors.Wrap(errdefs.ErrNotFound, "bucket does not exist")
|
||||
}
|
||||
|
||||
return fn(ctx, bkt.Bucket(bucketKeySnapshot), bkt.Bucket(bucketKeyParents))
|
||||
}
|
||||
|
||||
func createBucketIfNotExists(ctx context.Context, fn func(context.Context, *bolt.Bucket, *bolt.Bucket) error) error {
|
||||
namespace, err := namespaces.NamespaceRequired(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t, ok := ctx.Value(transactionKey{}).(*boltFileTransactor)
|
||||
if !ok {
|
||||
return ErrNoTransaction
|
||||
}
|
||||
|
||||
nbkt, err := t.tx.CreateBucketIfNotExists(bucketKeyStorageVersion)
|
||||
bkt, err := t.tx.CreateBucketIfNotExists(bucketKeyStorageVersion)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create version bucket")
|
||||
}
|
||||
|
||||
bkt, err := nbkt.CreateBucketIfNotExists([]byte(namespace))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sbkt, err := bkt.CreateBucketIfNotExists(bucketKeySnapshot)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create snapshots bucket")
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/snapshot"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -46,7 +45,7 @@ func MetaStoreSuite(t *testing.T, name string, meta func(root string) (*MetaStor
|
||||
// makeTest creates a testsuite with a writable transaction
|
||||
func makeTest(t *testing.T, name string, metaFn metaFactory, fn testFunc) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
ctx := namespaces.WithNamespace(context.Background(), "testing-snapshot-metadata")
|
||||
ctx := context.Background()
|
||||
tmpDir, err := ioutil.TempDir("", "metastore-test-"+name+"-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user