Add children bucket to back reference snapshots

Adds back links from parent to children in order to prevent
deletion of a referenced snapshot in a namespace.
Avoid removing snapshot during metadata delete to
prevent shared namespaces from being mistakenly deleted.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-10-02 16:44:57 -07:00
parent 56c1b79a4c
commit 447a0a9452
3 changed files with 58 additions and 12 deletions

View File

@@ -305,7 +305,7 @@ func Remove(ctx context.Context, key string) (string, snapshot.Kind, error) {
if pbkt != nil {
k, _ := pbkt.Cursor().Seek(parentPrefixKey(id))
if getParentPrefix(k) == id {
return errors.Errorf("cannot remove snapshot with child")
return errors.Wrap(errdefs.ErrFailedPrecondition, "cannot remove snapshot with child")
}
if si.Parent != "" {