Skip to content

Commit

Permalink
worker: keep output directory in /var/cache
Browse files Browse the repository at this point in the history
Let's keep this on the same filesystem as the osbuild store, and
in particular stay away from /var/tmp and its scary semantics.

We are not aware of any issues caused by /var/tmp, but getting
rid of it means we don't have to think about that when debugging,
if nothing else.

Signed-off-by: Tom Gundersen <[email protected]>
  • Loading branch information
teg authored and ondrejbudai committed Feb 20, 2021
1 parent 5ae5cdb commit f0b7cc0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/osbuild-worker/jobimpl-osbuild-koji.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

type OSBuildKojiJobImpl struct {
Store string
Output string
KojiServers map[string]koji.GSSAPICredentials
}

Expand Down Expand Up @@ -54,7 +55,7 @@ func (impl *OSBuildKojiJobImpl) kojiUpload(file *os.File, server, directory, fil
}

func (impl *OSBuildKojiJobImpl) Run(job worker.Job) error {
outputDirectory, err := ioutil.TempDir("/var/tmp", "osbuild-worker-*")
outputDirectory, err := ioutil.TempDir(impl.Output, job.Id().String()+"-*")
if err != nil {
return fmt.Errorf("error creating temporary output directory: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/osbuild-worker/jobimpl-osbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

type OSBuildJobImpl struct {
Store string
Output string
KojiServers map[string]koji.GSSAPICredentials
}

Expand Down Expand Up @@ -62,7 +63,7 @@ func osbuildStagesToRPMs(stages []osbuild.StageResult) []koji.RPM {
}

func (impl *OSBuildJobImpl) Run(job worker.Job) error {
outputDirectory, err := ioutil.TempDir("/var/tmp", "osbuild-worker-*")
outputDirectory, err := ioutil.TempDir(impl.Output, job.Id().String()+"-*")
if err != nil {
return fmt.Errorf("error creating temporary output directory: %v", err)
}
Expand Down Expand Up @@ -154,7 +155,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
Datastore: options.Datastore,
}

tempDirectory, err := ioutil.TempDir("/var/tmp", "osbuild-worker-vmware-*")
tempDirectory, err := ioutil.TempDir(impl.Output, job.Id().String()+"-vmware-*")
if err != nil {
r = append(r, err)
continue
Expand Down
4 changes: 4 additions & 0 deletions cmd/osbuild-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func main() {
log.Fatal("CACHE_DIRECTORY is not set. Is the service file missing CacheDirectory=?")
}
store := path.Join(cacheDirectory, "osbuild-store")
output := path.Join(cacheDirectory, "output")
_ = os.Mkdir(output, os.ModeDir)

kojiServers := make(map[string]koji.GSSAPICredentials)
for server, creds := range config.KojiServers {
Expand Down Expand Up @@ -152,10 +154,12 @@ func main() {
jobImpls := map[string]JobImplementation{
"osbuild": &OSBuildJobImpl{
Store: store,
Output: output,
KojiServers: kojiServers,
},
"osbuild-koji": &OSBuildKojiJobImpl{
Store: store,
Output: output,
KojiServers: kojiServers,
},
"koji-init": &KojiInitJobImpl{
Expand Down

0 comments on commit f0b7cc0

Please sign in to comment.