containerd-stress: add snapshotter option for stress test to use
containerd-stress utility needs to be able to run with snapshotter passed by user in cli in order to be able to stress test snapshotters. This adds a cli option --snapshotter="<snapshotter-name>" Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
This commit is contained in:
parent
054a3e281e
commit
0550c32330
@ -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),
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
@ -252,6 +259,7 @@ func test(c config) error {
|
||||
image: image,
|
||||
client: client,
|
||||
commit: v.Revision,
|
||||
snapshotter: c.Snapshotter,
|
||||
}
|
||||
workers = append(workers, w)
|
||||
}
|
||||
@ -266,6 +274,7 @@ func test(c config) error {
|
||||
image: image,
|
||||
client: client,
|
||||
commit: v.Revision,
|
||||
snapshotter: c.Snapshotter,
|
||||
},
|
||||
}
|
||||
go exec.exec(ctx, tctx)
|
||||
|
@ -38,6 +38,7 @@ type worker struct {
|
||||
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")),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user