diff --git a/executor/resources/monitor.go b/executor/resources/monitor.go index 78438b26df76..95b954bcbe6f 100644 --- a/executor/resources/monitor.go +++ b/executor/resources/monitor.go @@ -56,6 +56,10 @@ func (r *cgroupRecord) Start() { r.closeSampler = s.Close } +func (r *cgroupRecord) Close() { + r.close() +} + func (r *cgroupRecord) CloseAsync(next func(context.Context) error) error { go func() { r.close() @@ -160,6 +164,9 @@ func (r *nopRecord) Samples() (*types.Samples, error) { return nil, nil } +func (r *nopRecord) Close() { +} + func (r *nopRecord) CloseAsync(next func(context.Context) error) error { return next(context.TODO()) } diff --git a/executor/resources/types/types.go b/executor/resources/types/types.go index 8ef316a167e3..9bac557e2160 100644 --- a/executor/resources/types/types.go +++ b/executor/resources/types/types.go @@ -9,6 +9,7 @@ import ( type Recorder interface { Start() + Close() CloseAsync(func(context.Context) error) error Wait() error Samples() (*Samples, error) diff --git a/executor/runcexecutor/executor.go b/executor/runcexecutor/executor.go index 9c12996e53da..e804ee850b28 100644 --- a/executor/runcexecutor/executor.go +++ b/executor/runcexecutor/executor.go @@ -335,6 +335,9 @@ func (w *runcExecutor) Run(ctx context.Context, id string, root executor.Mount, err = exitError(ctx, err) if err != nil { + if rec != nil { + rec.Close() + } releaseContainer(context.TODO()) return nil, err }