worker: define worker errors
Define worker errors to give more structured
error messages. The error api is:
id: VALIDATION_ERROR_NUMBER, reason: STRING, details: { issues: [{...}, {...}] }
The api was agreed upon with osbuild so that,
in future, osbuild errors will share the same
structure
This commit is contained in:
parent
1dbbc37cac
commit
daf24f8db3
2 changed files with 54 additions and 0 deletions
43
internal/worker/clienterrors/errors.go
Normal file
43
internal/worker/clienterrors/errors.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package clienterrors
|
||||
|
||||
const (
|
||||
ErrorNoDynamicArgs ClientErrorCode = 1
|
||||
ErrorInvalidTargetConfig ClientErrorCode = 2
|
||||
ErrorSharingTarget ClientErrorCode = 3
|
||||
ErrorInvalidTarget ClientErrorCode = 4
|
||||
ErrorDepsolveDependency ClientErrorCode = 5
|
||||
ErrorReadingJobStatus ClientErrorCode = 6
|
||||
ErrorParsingDynamicArgs ClientErrorCode = 7
|
||||
ErrorManifestGeneration ClientErrorCode = 8
|
||||
ErrorManifestDependency ClientErrorCode = 9
|
||||
ErrorBuildJob ClientErrorCode = 10
|
||||
ErrorUploadingImage ClientErrorCode = 11
|
||||
ErrorImportingImage ClientErrorCode = 12
|
||||
ErrorKojiFailedDependency ClientErrorCode = 13
|
||||
ErrorKojiBuild ClientErrorCode = 14
|
||||
ErrorKojiInit ClientErrorCode = 15
|
||||
ErrorKojiFinalize ClientErrorCode = 16
|
||||
ErrorInvalidConfig ClientErrorCode = 17
|
||||
ErrorOldResultCompatible ClientErrorCode = 18
|
||||
|
||||
ErrorDNFDepsolveError ClientErrorCode = 20
|
||||
ErrorDNFMarkingError ClientErrorCode = 21
|
||||
ErrorDNFOtherError ClientErrorCode = 22
|
||||
ErrorRPMMDError ClientErrorCode = 23
|
||||
)
|
||||
|
||||
type ClientErrorCode int
|
||||
|
||||
type Error struct {
|
||||
ID ClientErrorCode `json:"id"`
|
||||
Reason string `json:"reason"`
|
||||
Details interface{} `json:"details"`
|
||||
}
|
||||
|
||||
func WorkerClientError(code ClientErrorCode, reason string, details ...interface{}) *Error {
|
||||
return &Error{
|
||||
ID: code,
|
||||
Reason: reason,
|
||||
Details: details,
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import (
|
|||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/target"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker/clienterrors"
|
||||
)
|
||||
|
||||
//
|
||||
|
|
@ -22,6 +23,10 @@ type OSBuildJob struct {
|
|||
PipelineNames *PipelineNames `json:"pipeline_names,omitempty"`
|
||||
}
|
||||
|
||||
type JobResult struct {
|
||||
JobError *clienterrors.Error `json:"job_error,omitempty"`
|
||||
}
|
||||
|
||||
type OSBuildJobResult struct {
|
||||
Success bool `json:"success"`
|
||||
OSBuildOutput *osbuild.Result `json:"osbuild_output,omitempty"`
|
||||
|
|
@ -29,6 +34,7 @@ type OSBuildJobResult struct {
|
|||
TargetErrors []string `json:"target_errors,omitempty"`
|
||||
UploadStatus string `json:"upload_status"`
|
||||
PipelineNames *PipelineNames `json:"pipeline_names,omitempty"`
|
||||
JobResult
|
||||
}
|
||||
|
||||
type KojiInitJob struct {
|
||||
|
|
@ -42,6 +48,7 @@ type KojiInitJobResult struct {
|
|||
BuildID uint64 `json:"build_id"`
|
||||
Token string `json:"token"`
|
||||
KojiError string `json:"koji_error"`
|
||||
JobResult
|
||||
}
|
||||
|
||||
type OSBuildKojiJob struct {
|
||||
|
|
@ -62,6 +69,7 @@ type OSBuildKojiJobResult struct {
|
|||
ImageHash string `json:"image_hash"`
|
||||
ImageSize uint64 `json:"image_size"`
|
||||
KojiError string `json:"koji_error"`
|
||||
JobResult
|
||||
}
|
||||
|
||||
type KojiFinalizeJob struct {
|
||||
|
|
@ -77,6 +85,7 @@ type KojiFinalizeJob struct {
|
|||
|
||||
type KojiFinalizeJobResult struct {
|
||||
KojiError string `json:"koji_error"`
|
||||
JobResult
|
||||
}
|
||||
|
||||
// PipelineNames is used to provide two pieces of information related to a job:
|
||||
|
|
@ -113,6 +122,7 @@ type DepsolveJobResult struct {
|
|||
PackageSpecs map[string][]rpmmd.PackageSpec `json:"package_specs"`
|
||||
Error string `json:"error"`
|
||||
ErrorType ErrorType `json:"error_type"`
|
||||
JobResult
|
||||
}
|
||||
|
||||
type ManifestJobByID struct{}
|
||||
|
|
@ -120,6 +130,7 @@ type ManifestJobByID struct{}
|
|||
type ManifestJobByIDResult struct {
|
||||
Manifest distro.Manifest `json:"data,omitempty"`
|
||||
Error string `json:"error"`
|
||||
JobResult
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue