Capture more error locations during stress tests

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2018-02-07 15:50:29 -05:00
parent f12ba2407e
commit e68bdbe9d9
2 changed files with 19 additions and 8 deletions

View File

@ -84,13 +84,16 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
} }
} }
func (w *execWorker) runExec(ctx context.Context, task containerd.Task, id string, spec *specs.Process) error { func (w *execWorker) runExec(ctx context.Context, task containerd.Task, id string, spec *specs.Process) (err error) {
process, err := task.Exec(ctx, id, spec, cio.NullIO) process, err := task.Exec(ctx, id, spec, cio.NullIO)
if err != nil { if err != nil {
return err return err
} }
defer process.Delete(ctx, containerd.WithProcessKill) defer func() {
if _, derr := process.Delete(ctx, containerd.WithProcessKill); err == nil {
err = derr
}
}()
statusC, err := process.Wait(ctx) statusC, err := process.Wait(ctx)
if err != nil { if err != nil {
return err return err
@ -105,6 +108,7 @@ func (w *execWorker) runExec(ctx context.Context, task containerd.Task, id strin
return nil return nil
} }
w.failures++ w.failures++
errCounter.WithValues(err.Error()).Inc()
} }
return nil return nil
} }

View File

@ -58,7 +58,7 @@ func (w *worker) run(ctx, tctx context.Context) {
} }
} }
func (w *worker) runContainer(ctx context.Context, id string) 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
w.spec.Linux.CgroupsPath = filepath.Join("/", "stress", id) w.spec.Linux.CgroupsPath = filepath.Join("/", "stress", id)
c, err := w.client.NewContainer(ctx, id, c, err := w.client.NewContainer(ctx, id,
@ -68,14 +68,20 @@ func (w *worker) runContainer(ctx context.Context, id string) error {
if err != nil { if err != nil {
return err return err
} }
defer c.Delete(ctx, containerd.WithSnapshotCleanup) defer func() {
if derr := c.Delete(ctx, containerd.WithSnapshotCleanup); err == nil {
err = derr
}
}()
task, err := c.NewTask(ctx, cio.NullIO) task, err := c.NewTask(ctx, cio.NullIO)
if err != nil { if err != nil {
return err return err
} }
defer task.Delete(ctx, containerd.WithProcessKill) defer func() {
if _, derr := task.Delete(ctx, containerd.WithProcessKill); err == nil {
err = derr
}
}()
statusC, err := task.Wait(ctx) statusC, err := task.Wait(ctx)
if err != nil { if err != nil {
return err return err
@ -90,6 +96,7 @@ func (w *worker) runContainer(ctx context.Context, id string) error {
return nil return nil
} }
w.failures++ w.failures++
errCounter.WithValues(err.Error()).Inc()
} }
return nil return nil
} }