Skip to content

Commit

Permalink
cloudapi/v2/server: assure order of fail-calls
Browse files Browse the repository at this point in the history
by avoiding map but rather using a slice the
order of SetFailed is maintained
  • Loading branch information
schuellerf authored and croissanne committed Nov 19, 2024
1 parent ca3f0a1 commit 02778b5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions internal/cloudapi/v2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,18 +469,21 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
if jobResult.JobError != nil {
// set all jobs to "failed"
// osbuild job will fail as dependency
jobs := map[string]uuid.UUID{
"depsolve": depsolveJobID,
"containerResolve": containerResolveJobID,
"ostreeResolve": ostreeResolveJobID,
"manifest": manifestJobID,
jobs := []struct {
Name string
ID uuid.UUID
}{
{"depsolve", depsolveJobID},
{"containerResolve", containerResolveJobID},
{"ostreeResolve", ostreeResolveJobID},
{"manifest", manifestJobID},
}

for jobName, jobID := range jobs {
if jobID != uuid.Nil {
err := workers.SetFailed(jobID, jobResult.JobError)
for _, job := range jobs {
if job.ID != uuid.Nil {
err := workers.SetFailed(job.ID, jobResult.JobError)
if err != nil {
logWithId.Errorf("Error failing %s job: %v", jobName, err)
logWithId.Errorf("Error failing %s job: %v", job.Name, err)
}
}
}
Expand Down

0 comments on commit 02778b5

Please sign in to comment.