Skip to content

Commit

Permalink
worker: ensure that the reported result is always non-nil
Browse files Browse the repository at this point in the history
When osbuild crashes (e.g. when cp fails because of the machine running
out of disk space), it doesn't produce a machine-readable result. Due to
our suboptimal handling of the result struct (this is my fault), this can
lead to result == nil. However, composer expects that result != nil in all
cases because it uses the Success flag to assess the compose state. If
result == nil, it just crashes terribly.
  • Loading branch information
ondrejbudai authored and teg committed Jun 12, 2020
1 parent 4f3f09f commit ab0a805
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/osbuild-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ func main() {
// signal to WatchJob() that it can stop watching
cancel()

// Ensure we always have a non-nil result, composer doesn't like nils.
// This can happen in cases when OSBuild crashes and doesn't produce
// a meaningful output. E.g. when the machine runs of disk space.
if result == nil {
result = &common.ComposeResult{
Success: false,
}
}

err = client.UpdateJob(job, status, result)
if err != nil {
log.Fatalf("Error reporting job result: %v", err)
Expand Down

0 comments on commit ab0a805

Please sign in to comment.