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"),
|
Exec: cliContext.GlobalBool("exec"),
|
||||||
JSON: cliContext.GlobalBool("json"),
|
JSON: cliContext.GlobalBool("json"),
|
||||||
Metrics: cliContext.GlobalString("metrics"),
|
Metrics: cliContext.GlobalString("metrics"),
|
||||||
|
Snapshotter: cliContext.GlobalString("snapshotter"),
|
||||||
}
|
}
|
||||||
client, err := config.newClient()
|
client, err := config.newClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,7 +67,7 @@ var densityCommand = cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Infof("pulling %s", imageName)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -91,6 +92,7 @@ var densityCommand = cli.Command{
|
|||||||
id := fmt.Sprintf("density-%d", i)
|
id := fmt.Sprintf("density-%d", i)
|
||||||
|
|
||||||
c, err := client.NewContainer(ctx, id,
|
c, err := client.NewContainer(ctx, id,
|
||||||
|
containerd.WithSnapshotter(config.Snapshotter),
|
||||||
containerd.WithNewSnapshot(id, image),
|
containerd.WithNewSnapshot(id, image),
|
||||||
containerd.WithNewSpec(
|
containerd.WithNewSpec(
|
||||||
oci.WithImageConfig(image),
|
oci.WithImageConfig(image),
|
||||||
|
@ -42,6 +42,7 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
|
|||||||
id := fmt.Sprintf("exec-container-%d", w.id)
|
id := fmt.Sprintf("exec-container-%d", w.id)
|
||||||
c, err := w.client.NewContainer(ctx, id,
|
c, err := w.client.NewContainer(ctx, id,
|
||||||
containerd.WithNewSnapshot(id, w.image),
|
containerd.WithNewSnapshot(id, w.image),
|
||||||
|
containerd.WithSnapshotter(w.snapshotter),
|
||||||
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")),
|
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -149,6 +149,11 @@ func main() {
|
|||||||
Usage: "set the runtime to stress test",
|
Usage: "set the runtime to stress test",
|
||||||
Value: plugin.RuntimeRuncV2,
|
Value: plugin.RuntimeRuncV2,
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "snapshotter",
|
||||||
|
Usage: "set the snapshotter to use",
|
||||||
|
Value: "overlayfs",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
app.Before = func(context *cli.Context) error {
|
app.Before = func(context *cli.Context) error {
|
||||||
if context.GlobalBool("json") {
|
if context.GlobalBool("json") {
|
||||||
@ -171,6 +176,7 @@ func main() {
|
|||||||
JSON: context.GlobalBool("json"),
|
JSON: context.GlobalBool("json"),
|
||||||
Metrics: context.GlobalString("metrics"),
|
Metrics: context.GlobalString("metrics"),
|
||||||
Runtime: context.GlobalString("runtime"),
|
Runtime: context.GlobalString("runtime"),
|
||||||
|
Snapshotter: context.GlobalString("snapshotter"),
|
||||||
}
|
}
|
||||||
if config.Metrics != "" {
|
if config.Metrics != "" {
|
||||||
return serve(config)
|
return serve(config)
|
||||||
@ -191,6 +197,7 @@ type config struct {
|
|||||||
JSON bool
|
JSON bool
|
||||||
Metrics string
|
Metrics string
|
||||||
Runtime string
|
Runtime string
|
||||||
|
Snapshotter string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c config) newClient() (*containerd.Client, error) {
|
func (c config) newClient() (*containerd.Client, error) {
|
||||||
@ -222,7 +229,7 @@ func test(c config) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Infof("pulling %s", imageName)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -252,6 +259,7 @@ func test(c config) error {
|
|||||||
image: image,
|
image: image,
|
||||||
client: client,
|
client: client,
|
||||||
commit: v.Revision,
|
commit: v.Revision,
|
||||||
|
snapshotter: c.Snapshotter,
|
||||||
}
|
}
|
||||||
workers = append(workers, w)
|
workers = append(workers, w)
|
||||||
}
|
}
|
||||||
@ -266,6 +274,7 @@ func test(c config) error {
|
|||||||
image: image,
|
image: image,
|
||||||
client: client,
|
client: client,
|
||||||
commit: v.Revision,
|
commit: v.Revision,
|
||||||
|
snapshotter: c.Snapshotter,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
go exec.exec(ctx, tctx)
|
go exec.exec(ctx, tctx)
|
||||||
|
@ -38,6 +38,7 @@ type worker struct {
|
|||||||
client *containerd.Client
|
client *containerd.Client
|
||||||
image containerd.Image
|
image containerd.Image
|
||||||
commit string
|
commit string
|
||||||
|
snapshotter string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *worker) run(ctx, tctx context.Context) {
|
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) {
|
func (w *worker) runContainer(ctx context.Context, id string) (err error) {
|
||||||
// fix up cgroups path for a default config
|
// fix up cgroups path for a default config
|
||||||
c, err := w.client.NewContainer(ctx, id,
|
c, err := w.client.NewContainer(ctx, id,
|
||||||
|
containerd.WithSnapshotter(w.snapshotter),
|
||||||
containerd.WithNewSnapshot(id, w.image),
|
containerd.WithNewSnapshot(id, w.image),
|
||||||
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("true")),
|
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("true")),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user