worker: always send status "FINISHED"

The server hasn't used common.ImageBuildState to mark a job as
successful or failed for a long time. Instead, it's using the job's
return argument for that. (Jobs don't have a high-level concept of
failing).

Drop the check in the server, and always send "FINISHED" from the client
for backwards compatibility.
This commit is contained in:
Lars Karlitski 2020-10-27 22:37:54 +01:00
parent b7cb2cff62
commit d1f322ec6f
3 changed files with 4 additions and 15 deletions

View file

@ -28,7 +28,7 @@ type Client struct {
type Job interface {
Id() uuid.UUID
OSBuildArgs() (distro.Manifest, []*target.Target, error)
Update(status common.ImageBuildState, result *osbuild.Result) error
Update(result *osbuild.Result) error
Canceled() (bool, error)
UploadArtifact(name string, reader io.Reader) error
}
@ -154,11 +154,11 @@ func (j *job) OSBuildArgs() (distro.Manifest, []*target.Target, error) {
return args.Manifest, args.Targets, nil
}
func (j *job) Update(status common.ImageBuildState, result *osbuild.Result) error {
func (j *job) Update(result *osbuild.Result) error {
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(api.UpdateJobJSONRequestBody{
Result: result,
Status: status.ToString(),
Status: "FINISHED",
})
if err != nil {
panic(err)

View file

@ -18,7 +18,6 @@ import (
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/osbuild/osbuild-composer/internal/common"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/jobqueue"
"github.com/osbuild/osbuild-composer/internal/target"
@ -311,13 +310,6 @@ func (h *apiHandlers) UpdateJob(ctx echo.Context, idstr string) error {
return err
}
// The jobqueue doesn't support setting the status before a job is
// finished. This branch should never be hit, because the worker
// doesn't attempt this. Change the API to remove this awkwardness.
if body.Status != common.IBFinished && body.Status != common.IBFailed {
return echo.NewHTTPError(http.StatusBadRequest, "setting status of a job to waiting or running is not supported")
}
err = h.server.FinishJob(token, &OSBuildJobResult{OSBuildOutput: body.Result})
if err != nil {
switch err {