Workers reported status via an `osbuild.Result`, which only includes osbuild output. Make it report OSBuildJobResult instead, which was meant to be used for this purpose and is already used as the result type in the jobqueue. While at it, add any errors produced by targets into this struct, as well as an overall success flag. Note that this breaks older workers returning the result of an osbuild job to a new composer. I think this is fine in this case, for two reasons: 1. We don't support running different versions of the worker and composer in the weldr API, and remote workers aren't widely used yet. 2. Both osbuild.Result and worker.OSBuildJobResult have a top-level `Success` boolean. Thus, logs are lost in such cases, but the overall status of the compose is not.
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package worker
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/osbuild/osbuild-composer/internal/distro"
|
|
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
|
"github.com/osbuild/osbuild-composer/internal/target"
|
|
)
|
|
|
|
//
|
|
// JSON-serializable types for the jobqueue
|
|
//
|
|
|
|
type OSBuildJob struct {
|
|
Manifest distro.Manifest `json:"manifest"`
|
|
Targets []*target.Target `json:"targets,omitempty"`
|
|
ImageName string `json:"image_name,omitempty"`
|
|
StreamOptimized bool `json:"stream_optimized,omitempty"`
|
|
}
|
|
|
|
type OSBuildJobResult struct {
|
|
Success bool `json:"success"`
|
|
OSBuildOutput *osbuild.Result `json:"osbuild_output,omitempty"`
|
|
TargetErrors []string `json:"target_errors,omitempty"`
|
|
}
|
|
|
|
//
|
|
// JSON-serializable types for the HTTP API
|
|
//
|
|
|
|
type statusResponse struct {
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
type requestJobResponse struct {
|
|
Id uuid.UUID `json:"id"`
|
|
Location string `json:"location"`
|
|
ArtifactLocation string `json:"artifact_location"`
|
|
Type string `json:"type"`
|
|
Args json.RawMessage `json:"args,omitempty"`
|
|
}
|
|
|
|
type getJobResponse struct {
|
|
Canceled bool `json:"canceled"`
|
|
}
|
|
|
|
type updateJobRequest struct {
|
|
Result json.RawMessage `json:"result"`
|
|
}
|
|
|
|
type updateJobResponse struct {
|
|
}
|