workerapi: serialize koji errors as strings
Serializing an interface does not work, let us simply use the string representation and treat the empty string as no error. This is compatible with the current API in the success case, and fixes the error case, which is currently broken. Also extend the test matrix for the kojiapi to ensure that all the different kinds of errors can be serialized correctly and leads to the correct status being returned. Fixes #1079 and #1080.
This commit is contained in:
parent
21f4a6416d
commit
bf86e8ad79
6 changed files with 299 additions and 139 deletions
|
|
@ -105,7 +105,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if initArgs.KojiError != nil {
|
||||
if initArgs.KojiError != "" {
|
||||
failure = true
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !buildArgs.OSBuildOutput.Success || buildArgs.KojiError != nil {
|
||||
if !buildArgs.OSBuildOutput.Success || buildArgs.KojiError != "" {
|
||||
failure = true
|
||||
break
|
||||
}
|
||||
|
|
@ -167,9 +167,15 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
|
||||
var result worker.KojiFinalizeJobResult
|
||||
if failure {
|
||||
result.KojiError = impl.kojiFail(args.Server, int(initArgs.BuildID), initArgs.Token)
|
||||
err = impl.kojiFail(args.Server, int(initArgs.BuildID), initArgs.Token)
|
||||
if err != nil {
|
||||
result.KojiError = err.Error()
|
||||
}
|
||||
} else {
|
||||
result.KojiError = impl.kojiImport(args.Server, build, buildRoots, images, args.KojiDirectory, initArgs.Token)
|
||||
err = impl.kojiImport(args.Server, build, buildRoots, images, args.KojiDirectory, initArgs.Token)
|
||||
if err != nil {
|
||||
result.KojiError = err.Error()
|
||||
}
|
||||
}
|
||||
|
||||
err = job.Update(&result)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,10 @@ func (impl *KojiInitJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
|
||||
var result worker.KojiInitJobResult
|
||||
result.Token, result.BuildID, result.KojiError = impl.kojiInit(args.Server, args.Name, args.Version, args.Release)
|
||||
result.Token, result.BuildID, err = impl.kojiInit(args.Server, args.Name, args.Version, args.Release)
|
||||
if err != nil {
|
||||
result.KojiError = err.Error()
|
||||
}
|
||||
|
||||
err = job.Update(&result)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func (impl *OSBuildKojiJobImpl) Run(job worker.Job) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if initArgs.KojiError == nil {
|
||||
if initArgs.KojiError == "" {
|
||||
result.OSBuildOutput, err = RunOSBuild(args.Manifest, impl.Store, outputDirectory, os.Stderr)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -95,7 +95,10 @@ func (impl *OSBuildKojiJobImpl) Run(job worker.Job) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result.ImageHash, result.ImageSize, result.KojiError = impl.kojiUpload(f, args.KojiServer, args.KojiDirectory, args.KojiFilename)
|
||||
result.ImageHash, result.ImageSize, err = impl.kojiUpload(f, args.KojiServer, args.KojiDirectory, args.KojiFilename)
|
||||
if err != nil {
|
||||
result.KojiError = err.Error()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue