Stop setting the StreamOptimized option in Weldr and Cloud APIs
The VMDK image is already produced as stream-optimized. Therefore stop setting the `StreamOptimized` option in `OSBuildJob` structure by both, Weldr and Cloud APIs. Keep the handling of the option in worker for backward compatibility, in case an older instance of Composer server is used, which does not produce VMDK manifests as stream-optimized. In such case, the worker needs to convert the image.
This commit is contained in:
parent
be6675d54e
commit
0bf67dfad5
4 changed files with 27 additions and 14 deletions
|
|
@ -116,6 +116,7 @@ func validateResult(result *worker.OSBuildJobResult, jobID string) {
|
|||
func uploadToS3(a *awscloud.AWS, outputDirectory, exportPath, bucket, key, filename string, osbuildJobResult *worker.OSBuildJobResult, genericS3 bool, streamOptimized bool, streamOptimizedPath string) (err error) {
|
||||
imagePath := path.Join(outputDirectory, exportPath, filename)
|
||||
|
||||
// TODO: delete the stream-optimized handling after "some" time (kept for backward compatibility)
|
||||
// *** SPECIAL VMDK HANDLING START ***
|
||||
// Upload the VMDK image as stream-optimized.
|
||||
// The VMDK conversion is applied only when the job was submitted by Weldr API,
|
||||
|
|
@ -294,6 +295,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// TODO: delete the stream-optimized handling after "some" time (kept for backward compatibility)
|
||||
streamOptimizedPath := ""
|
||||
|
||||
// NOTE: Currently OSBuild supports multiple exports, but this isn't used
|
||||
|
|
@ -303,6 +305,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if osbuildJobResult.OSBuildOutput.Success && args.ImageName != "" {
|
||||
var f *os.File
|
||||
imagePath := path.Join(outputDirectory, exportPath, args.ImageName)
|
||||
// TODO: delete the stream-optimized handling after "some" time (kept for backward compatibility)
|
||||
if args.StreamOptimized {
|
||||
f, err = vmware.OpenAsStreamOptimizedVmdk(imagePath)
|
||||
if err != nil {
|
||||
|
|
@ -354,6 +357,15 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
// create a symlink so that uploaded image has the name specified by user
|
||||
imageName := args.Targets[0].ImageName + ".vmdk"
|
||||
imagePath := path.Join(tempDirectory, imageName)
|
||||
|
||||
// New version of composer is already generating manifest with stream-optimized VMDK and is not setting
|
||||
// the args.StreamOptimized option. In such case, the image itself is already stream optimized.
|
||||
// Simulate the case as if it was converted by the worker. This makes it simpler to reuse the rest of
|
||||
// the existing code below.
|
||||
if !args.StreamOptimized {
|
||||
streamOptimizedPath = path.Join(outputDirectory, exportPath, options.Filename)
|
||||
}
|
||||
|
||||
err = os.Symlink(streamOptimizedPath, imagePath)
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
|
|
|
|||
|
|
@ -102,9 +102,8 @@ func (s *Server) enqueueCompose(distribution distro.Distro, bp blueprint.Bluepri
|
|||
}
|
||||
|
||||
id, err = s.workers.EnqueueOSBuildAsDependency(ir.arch.Name(), &worker.OSBuildJob{
|
||||
Targets: []*target.Target{ir.target},
|
||||
Exports: ir.imageType.Exports(),
|
||||
StreamOptimized: ir.imageType.Name() == "vmdk", // https://github.com/osbuild/osbuild/issues/528,
|
||||
Targets: []*target.Target{ir.target},
|
||||
Exports: ir.imageType.Exports(),
|
||||
PipelineNames: &worker.PipelineNames{
|
||||
Build: ir.imageType.BuildPipelines(),
|
||||
Payload: ir.imageType.PayloadPipelines(),
|
||||
|
|
|
|||
|
|
@ -2347,11 +2347,10 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
var jobId uuid.UUID
|
||||
|
||||
jobId, err = api.workers.EnqueueOSBuild(api.archName, &worker.OSBuildJob{
|
||||
Manifest: manifest,
|
||||
Targets: targets,
|
||||
ImageName: imageType.Filename(),
|
||||
StreamOptimized: imageType.Name() == "vmdk", // https://github.com/osbuild/osbuild/issues/528
|
||||
Exports: imageType.Exports(),
|
||||
Manifest: manifest,
|
||||
Targets: targets,
|
||||
ImageName: imageType.Filename(),
|
||||
Exports: imageType.Exports(),
|
||||
PipelineNames: &worker.PipelineNames{
|
||||
Build: imageType.BuildPipelines(),
|
||||
Payload: imageType.PayloadPipelines(),
|
||||
|
|
|
|||
|
|
@ -15,12 +15,15 @@ import (
|
|||
//
|
||||
|
||||
type OSBuildJob struct {
|
||||
Manifest distro.Manifest `json:"manifest,omitempty"`
|
||||
Targets []*target.Target `json:"targets,omitempty"`
|
||||
ImageName string `json:"image_name,omitempty"`
|
||||
StreamOptimized bool `json:"stream_optimized,omitempty"`
|
||||
Exports []string `json:"export_stages,omitempty"`
|
||||
PipelineNames *PipelineNames `json:"pipeline_names,omitempty"`
|
||||
Manifest distro.Manifest `json:"manifest,omitempty"`
|
||||
Targets []*target.Target `json:"targets,omitempty"`
|
||||
ImageName string `json:"image_name,omitempty"`
|
||||
|
||||
// TODO: Delete this after "some" time (kept for backward compatibility)
|
||||
StreamOptimized bool `json:"stream_optimized,omitempty"`
|
||||
|
||||
Exports []string `json:"export_stages,omitempty"`
|
||||
PipelineNames *PipelineNames `json:"pipeline_names,omitempty"`
|
||||
}
|
||||
|
||||
type JobResult struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue