Merge pull request #1638 from dmcgowan/gc-policy

gc: add policy plugin
This commit is contained in:
Stephen Day
2017-11-27 18:20:10 -08:00
committed by GitHub
21 changed files with 853 additions and 148 deletions

View File

@@ -3,6 +3,7 @@ package main
// register containerd builtins here
import (
_ "github.com/containerd/containerd/diff/walking"
_ "github.com/containerd/containerd/gc/scheduler"
_ "github.com/containerd/containerd/services/containers"
_ "github.com/containerd/containerd/services/content"
_ "github.com/containerd/containerd/services/diff"

View File

@@ -270,8 +270,14 @@ var removeCommand = cli.Command{
Name: "remove",
Aliases: []string{"rm"},
Usage: "remove one or more images by reference",
ArgsUsage: "<ref> [<ref>, ...]",
ArgsUsage: "[flags] <ref> [<ref>, ...]",
Description: "remove one or more images by reference",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "sync",
Usage: "Synchronously remove image and all associated resources",
},
},
Action: func(context *cli.Context) error {
client, ctx, cancel, err := commands.NewClient(context)
if err != nil {
@@ -282,8 +288,12 @@ var removeCommand = cli.Command{
exitErr error
imageStore = client.ImageService()
)
for _, target := range context.Args() {
if err := imageStore.Delete(ctx, target); err != nil {
for i, target := range context.Args() {
var opts []images.DeleteOpt
if context.Bool("sync") && i == context.NArg()-1 {
opts = append(opts, images.SynchronousDelete())
}
if err := imageStore.Delete(ctx, target, opts...); err != nil {
if !errdefs.IsNotFound(err) {
if exitErr == nil {
exitErr = errors.Wrapf(err, "unable to delete %v", target)