diff --git a/cmd/containerd-stress/density.go b/cmd/containerd-stress/density.go index 6359254a1..27b537dd2 100644 --- a/cmd/containerd-stress/density.go +++ b/cmd/containerd-stress/density.go @@ -55,6 +55,7 @@ var densityCommand = cli.Command{ Exec: cliContext.GlobalBool("exec"), JSON: cliContext.GlobalBool("json"), Metrics: cliContext.GlobalString("metrics"), + Snapshotter: cliContext.GlobalString("snapshotter"), } client, err := config.newClient() if err != nil { @@ -66,7 +67,7 @@ var densityCommand = cli.Command{ return err } logrus.Infof("pulling %s", imageName) - image, err := client.Pull(ctx, imageName, containerd.WithPullUnpack) + image, err := client.Pull(ctx, imageName, containerd.WithPullUnpack, containerd.WithPullSnapshotter(config.Snapshotter)) if err != nil { return err } @@ -91,6 +92,7 @@ var densityCommand = cli.Command{ id := fmt.Sprintf("density-%d", i) c, err := client.NewContainer(ctx, id, + containerd.WithSnapshotter(config.Snapshotter), containerd.WithNewSnapshot(id, image), containerd.WithNewSpec( oci.WithImageConfig(image), diff --git a/cmd/containerd-stress/exec_worker.go b/cmd/containerd-stress/exec_worker.go index cda1d04cd..981055455 100644 --- a/cmd/containerd-stress/exec_worker.go +++ b/cmd/containerd-stress/exec_worker.go @@ -42,6 +42,7 @@ func (w *execWorker) exec(ctx, tctx context.Context) { id := fmt.Sprintf("exec-container-%d", w.id) c, err := w.client.NewContainer(ctx, id, containerd.WithNewSnapshot(id, w.image), + containerd.WithSnapshotter(w.snapshotter), containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")), ) if err != nil { diff --git a/cmd/containerd-stress/main.go b/cmd/containerd-stress/main.go index 19d9dec82..2706b826d 100644 --- a/cmd/containerd-stress/main.go +++ b/cmd/containerd-stress/main.go @@ -149,6 +149,11 @@ func main() { Usage: "set the runtime to stress test", Value: plugin.RuntimeRuncV2, }, + cli.StringFlag{ + Name: "snapshotter", + Usage: "set the snapshotter to use", + Value: "overlayfs", + }, } app.Before = func(context *cli.Context) error { if context.GlobalBool("json") { @@ -171,6 +176,7 @@ func main() { JSON: context.GlobalBool("json"), Metrics: context.GlobalString("metrics"), Runtime: context.GlobalString("runtime"), + Snapshotter: context.GlobalString("snapshotter"), } if config.Metrics != "" { return serve(config) @@ -191,6 +197,7 @@ type config struct { JSON bool Metrics string Runtime string + Snapshotter string } func (c config) newClient() (*containerd.Client, error) { @@ -222,7 +229,7 @@ func test(c config) error { return err } logrus.Infof("pulling %s", imageName) - image, err := client.Pull(ctx, imageName, containerd.WithPullUnpack) + image, err := client.Pull(ctx, imageName, containerd.WithPullUnpack, containerd.WithPullSnapshotter(c.Snapshotter)) if err != nil { return err } @@ -247,11 +254,12 @@ func test(c config) error { for i := 0; i < c.Concurrency; i++ { wg.Add(1) w := &worker{ - id: i, - wg: &wg, - image: image, - client: client, - commit: v.Revision, + id: i, + wg: &wg, + image: image, + client: client, + commit: v.Revision, + snapshotter: c.Snapshotter, } workers = append(workers, w) } @@ -261,11 +269,12 @@ func test(c config) error { wg.Add(1) exec = &execWorker{ worker: worker{ - id: i, - wg: &wg, - image: image, - client: client, - commit: v.Revision, + id: i, + wg: &wg, + image: image, + client: client, + commit: v.Revision, + snapshotter: c.Snapshotter, }, } go exec.exec(ctx, tctx) diff --git a/cmd/containerd-stress/worker.go b/cmd/containerd-stress/worker.go index 0b9b2801a..c0b17ab62 100644 --- a/cmd/containerd-stress/worker.go +++ b/cmd/containerd-stress/worker.go @@ -35,9 +35,10 @@ type worker struct { count int failures int - client *containerd.Client - image containerd.Image - commit string + client *containerd.Client + image containerd.Image + commit string + snapshotter string } func (w *worker) run(ctx, tctx context.Context) { @@ -74,6 +75,7 @@ func (w *worker) run(ctx, tctx context.Context) { func (w *worker) runContainer(ctx context.Context, id string) (err error) { // fix up cgroups path for a default config c, err := w.client.NewContainer(ctx, id, + containerd.WithSnapshotter(w.snapshotter), containerd.WithNewSnapshot(id, w.image), containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("true")), )