mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-13 14:56:11 -04:00
process.New applies its options and discards the error they return. When WithTemporaryStateDir could not create a directory, StateDir stayed empty and every later option went unapplied, so the failure surfaced from Run as "mkdir : no such file or directory" naming no path. That message cost a full day of diagnosis on a worker whose volume was full: the real errno was ENOSPC and nothing reported it. The loader now creates the directory itself and returns the underlying error with the path attached. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude Code:claude-opus-5 [golangci-lint]
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package model
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Backend process state directory", func() {
|
|
It("reports why the state directory could not be created", func() {
|
|
// A worker whose volume is full, or whose TMPDIR no longer resolves,
|
|
// cannot get a state directory. go-processmanager's New() drops the
|
|
// option error, leaving StateDir empty, and Run() then failed with
|
|
// "mkdir : no such file or directory" naming no path at all. Resolving
|
|
// the directory here keeps the real cause attached.
|
|
GinkgoT().Setenv("TMPDIR", filepath.Join(GinkgoT().TempDir(), "does-not-exist"))
|
|
|
|
dir, err := newProcessStateDir()
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(dir).To(BeEmpty())
|
|
Expect(err.Error()).To(ContainSubstring("backend process state directory"))
|
|
Expect(err.Error()).To(ContainSubstring("does-not-exist"),
|
|
"the error must name the directory it could not create")
|
|
})
|
|
|
|
It("returns a usable directory when the temp location works", func() {
|
|
GinkgoT().Setenv("TMPDIR", GinkgoT().TempDir())
|
|
|
|
dir, err := newProcessStateDir()
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(dir).ToNot(BeEmpty())
|
|
info, statErr := os.Stat(dir)
|
|
Expect(statErr).ToNot(HaveOccurred())
|
|
Expect(info.IsDir()).To(BeTrue())
|
|
})
|
|
})
|