fix: clean up bind_workdir workspace after job execution

When bind_workdir is enabled, workspace directories persist on the host
after container removal. Clean them up after job execution to prevent
stale files from accumulating.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind 2026-03-02 11:14:28 +01:00
parent 0bae040917
commit 1b31155930
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
1 changed files with 8 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"maps"
"os"
"path/filepath"
"strings"
"sync"
@ -245,6 +246,13 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
execErr := executor(ctx)
reporter.SetOutputs(job.Outputs)
if r.cfg.Container.BindWorkdir {
if err := os.RemoveAll(runnerConfig.Workdir); err != nil {
log.Warnf("failed to clean up workspace %s: %v", runnerConfig.Workdir, err)
}
}
return execErr
}