Clear snapshot when container doesn't exist

This clears up a scenario where a container can be deleted but
its snapshot is not.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2019-12-28 20:01:01 +00:00
parent 6c3fe813fd
commit 38f26b213f

View File

@ -43,6 +43,12 @@ func Remove(ctx context.Context, client *containerd.Client, name string) error {
if err != nil { if err != nil {
return fmt.Errorf("error deleting container %s, %s, %s", container.ID(), name, err) return fmt.Errorf("error deleting container %s, %s, %s", container.ID(), name, err)
} }
} else {
service := client.SnapshotService("")
key := name + "snapshot"
if _, err := client.SnapshotService("").Stat(ctx, key); err == nil {
service.Remove(ctx, key)
}
} }
return nil return nil
} }