worker: pass a temporary store to osbuild
When fdd753615 added `--output-directory` to the invocation of osbuild,
it also removed `--store`.
This was a mistake: osbuild's default store is `.osbuild`, which is not
what we want. Restore the old behavior of passing a temporary directory.
This commit is contained in:
parent
b065d8c304
commit
e503b0a4d4
2 changed files with 12 additions and 8 deletions
|
|
@ -64,18 +64,21 @@ func (e *TargetsError) Error() string {
|
|||
}
|
||||
|
||||
func RunJob(job *worker.Job, uploadFunc func(uuid.UUID, string, io.Reader) error) (*common.ComposeResult, error) {
|
||||
tmpOutput, err := ioutil.TempDir("/var/tmp", "osbuild-output-*")
|
||||
tmpdir, err := ioutil.TempDir("/var/tmp", "osbuild-worker-*")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error setting up osbuild output directory: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
err := os.RemoveAll(tmpOutput)
|
||||
err := os.RemoveAll(tmpdir)
|
||||
if err != nil {
|
||||
log.Printf("Error removing temporary directory %s for job %s: %v", tmpOutput, job.Id, err)
|
||||
log.Printf("Error removing temporary directory %s for job %s: %v", tmpdir, job.Id, err)
|
||||
}
|
||||
}()
|
||||
|
||||
result, err := RunOSBuild(job.Manifest, tmpOutput, os.Stderr)
|
||||
outputDirectory := path.Join(tmpdir, "output")
|
||||
store := path.Join(tmpdir, "store")
|
||||
|
||||
result, err := RunOSBuild(job.Manifest, store, outputDirectory, os.Stderr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -85,7 +88,7 @@ func RunJob(job *worker.Job, uploadFunc func(uuid.UUID, string, io.Reader) error
|
|||
for _, t := range job.Targets {
|
||||
switch options := t.Options.(type) {
|
||||
case *target.LocalTargetOptions:
|
||||
f, err := os.Open(path.Join(tmpOutput, options.Filename))
|
||||
f, err := os.Open(path.Join(outputDirectory, options.Filename))
|
||||
if err != nil {
|
||||
r = append(r, err)
|
||||
continue
|
||||
|
|
@ -109,7 +112,7 @@ func RunJob(job *worker.Job, uploadFunc func(uuid.UUID, string, io.Reader) error
|
|||
options.Key = job.Id.String()
|
||||
}
|
||||
|
||||
_, err = a.Upload(path.Join(tmpOutput, options.Filename), options.Bucket, options.Key)
|
||||
_, err = a.Upload(path.Join(outputDirectory, options.Filename), options.Bucket, options.Key)
|
||||
if err != nil {
|
||||
r = append(r, err)
|
||||
continue
|
||||
|
|
@ -136,7 +139,7 @@ func RunJob(job *worker.Job, uploadFunc func(uuid.UUID, string, io.Reader) error
|
|||
err := azure.UploadImage(
|
||||
credentials,
|
||||
metadata,
|
||||
path.Join(tmpOutput, options.Filename),
|
||||
path.Join(outputDirectory, options.Filename),
|
||||
azureMaxUploadGoroutines,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ func (e *OSBuildError) Error() string {
|
|||
return e.Message
|
||||
}
|
||||
|
||||
func RunOSBuild(manifest *osbuild.Manifest, outputDirectory string, errorWriter io.Writer) (*common.ComposeResult, error) {
|
||||
func RunOSBuild(manifest *osbuild.Manifest, store, outputDirectory string, errorWriter io.Writer) (*common.ComposeResult, error) {
|
||||
cmd := exec.Command(
|
||||
"osbuild",
|
||||
"--store", store,
|
||||
"--output-directory", outputDirectory,
|
||||
"--json", "-",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue