osbuld-worker: call osbuild with --export flag
osbuild now supports using the `--export` flag (can be invoked multiple times) to request the exporting of one or more artefacts. Omitting it causes the build job to export nothing. The Koji API doesn't support the new image types (yet) so it simply uses the "assembler" name, which is the final stage of the old (v1) Manifests.
This commit is contained in:
parent
541cbab0f6
commit
2cce81093f
5 changed files with 17 additions and 5 deletions
|
|
@ -85,8 +85,9 @@ func (impl *OSBuildKojiJobImpl) Run(job worker.Job) error {
|
|||
return err
|
||||
}
|
||||
|
||||
exports := []string{"assembler"} // NOTE: Koji API doesn't support new image types yet
|
||||
if initArgs.KojiError == "" {
|
||||
result.OSBuildOutput, err = RunOSBuild(args.Manifest, impl.Store, outputDirectory, os.Stderr)
|
||||
result.OSBuildOutput, err = RunOSBuild(args.Manifest, impl.Store, outputDirectory, exports, os.Stderr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
start_time := time.Now()
|
||||
|
||||
osbuildOutput, err := RunOSBuild(args.Manifest, impl.Store, outputDirectory, os.Stderr)
|
||||
osbuildOutput, err := RunOSBuild(args.Manifest, impl.Store, outputDirectory, args.Exports, os.Stderr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -98,9 +98,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
streamOptimizedPath := ""
|
||||
|
||||
// NOTE: Currently OSBuild supports multiple exports, but this isn't used
|
||||
// by any of the image types and it can't be specified during the request.
|
||||
// Use the first (and presumably only) export for the imagePath.
|
||||
exportPath := args.Exports[0]
|
||||
if osbuildOutput.Success && args.ImageName != "" {
|
||||
var f *os.File
|
||||
imagePath := path.Join(outputDirectory, args.ImageName)
|
||||
imagePath := path.Join(outputDirectory, exportPath, args.ImageName)
|
||||
if args.StreamOptimized {
|
||||
f, err = vmware.OpenAsStreamOptimizedVmdk(imagePath)
|
||||
if err != nil {
|
||||
|
|
@ -129,7 +133,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
continue
|
||||
}
|
||||
var f *os.File
|
||||
imagePath := path.Join(outputDirectory, options.Filename)
|
||||
imagePath := path.Join(outputDirectory, exportPath, options.Filename)
|
||||
if options.StreamOptimized {
|
||||
f, err = vmware.OpenAsStreamOptimizedVmdk(imagePath)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,13 +16,17 @@ import (
|
|||
// Note that osbuild returns non-zero when the pipeline fails. This function
|
||||
// does not return an error in this case. Instead, the failure is communicated
|
||||
// with its corresponding logs through osbuild.Result.
|
||||
func RunOSBuild(manifest distro.Manifest, store, outputDirectory string, errorWriter io.Writer) (*osbuild.Result, error) {
|
||||
func RunOSBuild(manifest distro.Manifest, store, outputDirectory string, exports []string, errorWriter io.Writer) (*osbuild.Result, error) {
|
||||
cmd := exec.Command(
|
||||
"osbuild",
|
||||
"--store", store,
|
||||
"--output-directory", outputDirectory,
|
||||
"--json", "-",
|
||||
)
|
||||
|
||||
for _, export := range exports {
|
||||
cmd.Args = append(cmd.Args, "--export", export)
|
||||
}
|
||||
cmd.Stderr = errorWriter
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
|
|
|
|||
|
|
@ -256,6 +256,7 @@ func (api *API) getComposeStatus(compose store.Compose) *composeStatus {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &composeStatus{
|
||||
State: composeStateFromJobStatus(jobStatus, &result),
|
||||
Queued: jobStatus.Queued,
|
||||
|
|
@ -2024,6 +2025,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
Targets: targets,
|
||||
ImageName: imageType.Filename(),
|
||||
StreamOptimized: imageType.Name() == "vmdk", // https://github.com/osbuild/osbuild/issues/528
|
||||
Exports: imageType.Exports(),
|
||||
})
|
||||
if err == nil {
|
||||
err = api.store.PushCompose(composeID, manifest, imageType, bp, size, targets, jobId)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ type OSBuildJob struct {
|
|||
Targets []*target.Target `json:"targets,omitempty"`
|
||||
ImageName string `json:"image_name,omitempty"`
|
||||
StreamOptimized bool `json:"stream_optimized,omitempty"`
|
||||
Exports []string `json:"export_stages,omitempty"`
|
||||
}
|
||||
|
||||
type OSBuildJobResult struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue