Merge pull request #1960 from dmcgowan/images-removal-dirty

metadata: image removal triggers GC
This commit is contained in:
Stephen Day
2018-01-17 13:58:39 -08:00
committed by GitHub
6 changed files with 223 additions and 246 deletions

View File

@@ -261,7 +261,7 @@ func TestMetadataCollector(t *testing.T) {
if err := mdb.Update(func(tx *bolt.Tx) error {
for _, obj := range objects {
node, err := create(obj, tx, cs, sn)
node, err := create(obj, tx, NewImageStore(mdb), cs, sn)
if err != nil {
return err
}
@@ -336,7 +336,7 @@ func benchmarkTrigger(n int) func(b *testing.B) {
if err := mdb.Update(func(tx *bolt.Tx) error {
for _, obj := range objects {
node, err := create(obj, tx, cs, sn)
node, err := create(obj, tx, NewImageStore(mdb), cs, sn)
if err != nil {
return err
}
@@ -416,7 +416,7 @@ type object struct {
labels map[string]string
}
func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshots.Snapshotter) (*gc.Node, error) {
func create(obj object, tx *bolt.Tx, is images.Store, cs content.Store, sn snapshots.Snapshotter) (*gc.Node, error) {
var (
node *gc.Node
namespace = "test"
@@ -469,12 +469,14 @@ func create(obj object, tx *bolt.Tx, cs content.Store, sn snapshots.Snapshotter)
}
}
case testImage:
ctx := WithTransactionContext(ctx, tx)
image := images.Image{
Name: v.name,
Target: v.target,
Labels: obj.labels,
}
_, err := NewImageStore(tx).Create(ctx, image)
_, err := is.Create(ctx, image)
if err != nil {
return nil, errors.Wrap(err, "failed to create image")
}