cloudapi/v2/server: assure order of fail-calls

by avoiding map but rather using a slice the
order of SetFailed is maintained
This commit is contained in:
Florian Schüller 2024-11-13 16:35:31 +01:00 committed by Sanne Raymaekers
parent ca3f0a190f
commit 02778b5361

View file

@ -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)
}
}
}