Skip to content

Commit d2aa7ac

Browse files
authored
fix: create executor cache directory if missing (#220)
## Summary - `os.MkdirTemp` in `ArchiveSource.Prepare` failed on hosts where the default cache dir (e.g. `/root/.cache/benchmarkoor`) didn't yet exist, since `MkdirTemp` does not create parent directories. - Add an `os.MkdirAll` before the `MkdirTemp` call, matching the pattern already used by `resolvePartsFile` and the git/eest sources. Fixes the runtime error: ``` FATL | Failed to execute command error=starting executor: preparing source: creating temp directory: stat /root/.cache/benchmarkoor: no such file or directory ``` ## Test plan - [x] `go build ./pkg/executor/` - [x] `go test ./pkg/executor/ -run TestArchive` - [ ] Run on a fresh host where `~/.cache/benchmarkoor` does not exist and confirm the executor starts.
1 parent ddd5100 commit d2aa7ac

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/executor/archive_source.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ type ArchiveSource struct {
3434

3535
// Prepare downloads (if URL) and extracts the archive, then discovers tests.
3636
func (s *ArchiveSource) Prepare(ctx context.Context) (*PreparedSource, error) {
37-
// Create temp directory for extraction.
37+
// Create temp directory for extraction. MkdirTemp requires the parent to
38+
// exist, so ensure the cache dir is created (e.g. ~/.cache/benchmarkoor on
39+
// a fresh host).
3840
parentDir := s.cacheDir
3941
if parentDir == "" {
4042
parentDir = os.TempDir()
4143
}
4244

45+
if err := os.MkdirAll(parentDir, 0755); err != nil {
46+
return nil, fmt.Errorf("creating cache directory: %w", err)
47+
}
48+
4349
tmpDir, err := os.MkdirTemp(parentDir, "archive-*")
4450
if err != nil {
4551
return nil, fmt.Errorf("creating temp directory: %w", err)

0 commit comments

Comments
 (0)