jobimpl-depsolve: Always return result
Previously it would not return a result if there was an error. This adds a deferred function that always returns the current contents of result, and if there is an error it logs it. Related: RHEL-60125
This commit is contained in:
parent
29f81a029a
commit
3c2b415e53
1 changed files with 11 additions and 6 deletions
|
|
@ -127,14 +127,22 @@ func workerClientErrorFrom(err error, logWithId *logrus.Entry) *clienterrors.Err
|
|||
|
||||
func (impl *DepsolveJobImpl) Run(job worker.Job) error {
|
||||
logWithId := logrus.WithField("jobId", job.Id())
|
||||
|
||||
var result worker.DepsolveJobResult
|
||||
// ALWAYS return a result
|
||||
defer func() {
|
||||
err := job.Update(&result)
|
||||
if err != nil {
|
||||
logWithId.Errorf("Error reporting job result: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var args worker.DepsolveJob
|
||||
err := job.Args(&args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var result worker.DepsolveJobResult
|
||||
|
||||
if impl.RepositoryMTLSConfig != nil {
|
||||
for pkgsetsi, pkgsets := range args.PackageSets {
|
||||
for pkgseti, pkgset := range pkgsets {
|
||||
|
|
@ -163,10 +171,7 @@ func (impl *DepsolveJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Errorf("Error during rpm repo cache cleanup: %s", err.Error())
|
||||
}
|
||||
|
||||
err = job.Update(&result)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error reporting job result: %v", err)
|
||||
}
|
||||
// NOTE: result is returned by deferred function above
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue