clienterrors: rename WorkerClientError to clienterrors.New
The usual convention to create new object is to prefix `New*` so this commit renames the `WorkerClientError`. Initially I thought it would be `NewWorkerClientError()` but looking at the package prefix it seems unneeded, i.e. `clienterrors.New()` already provides enough context it seems and it's the only error we construct. We could consider renaming it to `clienterror` (singular) too but that could be a followup. I would also like to make `clienterror.Error` implement the `error` interface but that should be a followup to make this (mechanical) rename trivial to review.
This commit is contained in:
parent
09445a1030
commit
573b349f16
19 changed files with 188 additions and 188 deletions
|
|
@ -36,31 +36,31 @@ func (impl *AWSEC2CopyJobImpl) Run(job worker.Job) error {
|
|||
var args worker.AWSEC2CopyJob
|
||||
err := job.Args(&args)
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingJobArgs, fmt.Sprintf("Error parsing arguments: %v", err), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorParsingJobArgs, fmt.Sprintf("Error parsing arguments: %v", err), nil)
|
||||
return err
|
||||
}
|
||||
|
||||
aws, err := getAWS(impl.AWSCreds, args.TargetRegion)
|
||||
if err != nil {
|
||||
logWithId.Errorf("Error creating aws client: %v", err)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, "Invalid worker config", nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorInvalidConfig, "Invalid worker config", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
ami, err := aws.CopyImage(args.TargetName, args.Ami, args.SourceRegion)
|
||||
if err != nil {
|
||||
logWithId.Errorf("Error copying ami: %v", err)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Error copying ami %s", args.Ami), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Error copying ami %s", args.Ami), nil)
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case "InvalidRegion":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Invalid source region '%s'", args.SourceRegion), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Invalid source region '%s'", args.SourceRegion), nil)
|
||||
case "InvalidAMIID.Malformed":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Malformed source ami id '%s'", args.Ami), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Malformed source ami id '%s'", args.Ami), nil)
|
||||
case "InvalidAMIID.NotFound":
|
||||
fallthrough // CopyImage returns InvalidRequest instead of InvalidAMIID.NotFound
|
||||
case "InvalidRequest":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Source ami '%s' not found", args.Ami), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Source ami '%s' not found", args.Ami), nil)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
|
@ -89,24 +89,24 @@ func (impl *AWSEC2ShareJobImpl) Run(job worker.Job) error {
|
|||
var args worker.AWSEC2ShareJob
|
||||
err := job.Args(&args)
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingJobArgs, fmt.Sprintf("Error parsing arguments: %v", err), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorParsingJobArgs, fmt.Sprintf("Error parsing arguments: %v", err), nil)
|
||||
return err
|
||||
}
|
||||
|
||||
if args.Ami == "" || args.Region == "" {
|
||||
if job.NDynamicArgs() != 1 {
|
||||
logWithId.Error("No arguments given and dynamic args empty")
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, "An ec2 share job should have args or depend on an ec2 copy job", nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorNoDynamicArgs, "An ec2 share job should have args or depend on an ec2 copy job", nil)
|
||||
return nil
|
||||
}
|
||||
var cjResult worker.AWSEC2CopyJobResult
|
||||
err = job.DynamicArgs(0, &cjResult)
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args as ec2 copy job", nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args as ec2 copy job", nil)
|
||||
return err
|
||||
}
|
||||
if cjResult.JobError != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorJobDependency, "AWSEC2CopyJob dependency failed", nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorJobDependency, "AWSEC2CopyJob dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -117,22 +117,22 @@ func (impl *AWSEC2ShareJobImpl) Run(job worker.Job) error {
|
|||
aws, err := getAWS(impl.AWSCreds, args.Region)
|
||||
if err != nil {
|
||||
logWithId.Errorf("Error creating aws client: %v", err)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, "Invalid worker config", nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorInvalidConfig, "Invalid worker config", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
err = aws.ShareImage(args.Ami, args.ShareWithAccounts)
|
||||
if err != nil {
|
||||
logWithId.Errorf("Error sharing image: %v", err)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Error sharing image with target %v", args.ShareWithAccounts), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Error sharing image with target %v", args.ShareWithAccounts), nil)
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case "InvalidAMIID.Malformed":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Malformed ami id '%s'", args.Ami), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Malformed ami id '%s'", args.Ami), nil)
|
||||
case "InvalidAMIID.NotFound":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Ami '%s' not found in region '%s'", args.Ami, args.Region), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Ami '%s' not found in region '%s'", args.Ami, args.Region), nil)
|
||||
case "InvalidAMIAttributeItemValue":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, fmt.Sprintf("Invalid user id to share ami with: %v", args.ShareWithAccounts), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorSharingTarget, fmt.Sprintf("Invalid user id to share ami with: %v", args.ShareWithAccounts), nil)
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ func (impl *ContainerResolveJobImpl) Run(job worker.Job) error {
|
|||
specs, err := resolver.Finish()
|
||||
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorContainerResolution, err.Error(), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorContainerResolution, err.Error(), nil)
|
||||
} else {
|
||||
for i, spec := range specs {
|
||||
result.Specs[i] = worker.ContainerSpec{
|
||||
|
|
|
|||
|
|
@ -81,16 +81,16 @@ func workerClientErrorFrom(err error) (*clienterrors.Error, error) {
|
|||
details := e.Reason
|
||||
switch e.Kind {
|
||||
case "DepsolveError":
|
||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, reason, details), nil
|
||||
return clienterrors.New(clienterrors.ErrorDNFDepsolveError, reason, details), nil
|
||||
case "MarkingErrors":
|
||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFMarkingErrors, reason, details), nil
|
||||
return clienterrors.New(clienterrors.ErrorDNFMarkingErrors, reason, details), nil
|
||||
case "RepoError":
|
||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFRepoError, reason, details), nil
|
||||
return clienterrors.New(clienterrors.ErrorDNFRepoError, reason, details), nil
|
||||
default:
|
||||
err := fmt.Errorf("Unhandled dnf-json error in depsolve job: %v", err)
|
||||
// This still has the kind/reason format but a kind that's returned
|
||||
// by dnf-json and not explicitly handled here.
|
||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, reason, details), err
|
||||
return clienterrors.New(clienterrors.ErrorDNFOtherError, reason, details), err
|
||||
}
|
||||
default:
|
||||
reason := "rpmmd error in depsolve job"
|
||||
|
|
@ -101,7 +101,7 @@ func workerClientErrorFrom(err error) (*clienterrors.Error, error) {
|
|||
details = err.Error()
|
||||
}
|
||||
// Error originates from internal/rpmmd, not from dnf-json
|
||||
return clienterrors.WorkerClientError(clienterrors.ErrorRPMMDError, reason, details), err
|
||||
return clienterrors.New(clienterrors.ErrorRPMMDError, reason, details), err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ func (impl *DepsolveJobImpl) Run(job worker.Job) error {
|
|||
for _, baseurlstr := range repo.BaseURLs {
|
||||
match, err := impl.RepositoryMTLSConfig.CompareBaseURL(baseurlstr)
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidRepositoryURL, "Repository URL is malformed", err.Error())
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorInvalidRepositoryURL, "Repository URL is malformed", err.Error())
|
||||
return err
|
||||
}
|
||||
if match {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func (impl *FileResolveJobImpl) Run(job worker.Job) error {
|
|||
|
||||
if result.Results == nil || len(result.Results) == 0 {
|
||||
logWithId.Infof("Resolving file contents failed: %v", err)
|
||||
result.JobError = clienterrors.WorkerClientError(
|
||||
result.JobError = clienterrors.New(
|
||||
clienterrors.ErrorRemoteFileResolution,
|
||||
"Error resolving file contents",
|
||||
"All remote file contents returned empty",
|
||||
|
|
@ -70,7 +70,7 @@ func (impl *FileResolveJobImpl) Run(job worker.Job) error {
|
|||
if len(resolutionErrors) == 0 {
|
||||
result.Success = true
|
||||
} else {
|
||||
result.JobError = clienterrors.WorkerClientError(
|
||||
result.JobError = clienterrors.New(
|
||||
clienterrors.ErrorRemoteFileResolution,
|
||||
"at least one file resolution failed",
|
||||
resolutionErrors,
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
|
||||
err := job.Args(args)
|
||||
if err != nil {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingJobArgs, "Error parsing job args", err.Error())
|
||||
kojiFinalizeJobResult.JobError = clienterrors.New(clienterrors.ErrorParsingJobArgs, "Error parsing job args", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -124,13 +124,13 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
var osbuildResults []worker.OSBuildJobResult
|
||||
initArgs, osbuildResults, err = extractDynamicArgs(job)
|
||||
if err != nil {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", err.Error())
|
||||
kojiFinalizeJobResult.JobError = clienterrors.New(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Check the dependencies early.
|
||||
if hasFailedDependency(*initArgs, osbuildResults) {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFailedDependency, "At least one job dependency failed", nil)
|
||||
kojiFinalizeJobResult.JobError = clienterrors.New(clienterrors.ErrorKojiFailedDependency, "At least one job dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
kojiTargetResults := buildResult.TargetResultsByName(target.TargetNameKoji)
|
||||
// Only a single Koji target is allowed per osbuild job
|
||||
if len(kojiTargetResults) != 1 {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Exactly one Koji target result is expected per osbuild job", nil)
|
||||
kojiFinalizeJobResult.JobError = clienterrors.New(clienterrors.ErrorKojiFinalize, "Exactly one Koji target result is expected per osbuild job", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
|
||||
err = impl.kojiImport(args.Server, build, buildRoots, outputs, args.KojiDirectory, initArgs.Token)
|
||||
if err != nil {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, err.Error(), nil)
|
||||
kojiFinalizeJobResult.JobError = clienterrors.New(clienterrors.ErrorKojiFinalize, err.Error(), nil)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func (impl *KojiInitJobImpl) Run(job worker.Job) error {
|
|||
var result worker.KojiInitJobResult
|
||||
result.Token, result.BuildID, err = impl.kojiInit(args.Server, args.Name, args.Version, args.Release)
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, err.Error(), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorKojiInit, err.Error(), nil)
|
||||
}
|
||||
|
||||
err = job.Update(&result)
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ func validateResult(result *worker.OSBuildJobResult, jobID string) {
|
|||
if result.OSBuildOutput == nil || !result.OSBuildOutput.Success {
|
||||
reason := "osbuild job was unsuccessful"
|
||||
logWithId.Errorf("osbuild job failed: %s", reason)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorBuildJob, reason, nil)
|
||||
return
|
||||
} else {
|
||||
logWithId.Infof("osbuild job succeeded")
|
||||
|
|
@ -265,14 +265,14 @@ func uploadToS3(a *awscloud.AWS, outputDirectory, exportPath, bucket, key, filen
|
|||
|
||||
result, err := a.Upload(imagePath, bucket, key)
|
||||
if err != nil {
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
return "", clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
|
||||
}
|
||||
|
||||
if public {
|
||||
err := a.MarkS3ObjectAsPublic(bucket, key)
|
||||
if err != nil {
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
return "", clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
}
|
||||
|
||||
return result.Location, nil
|
||||
|
|
@ -280,7 +280,7 @@ func uploadToS3(a *awscloud.AWS, outputDirectory, exportPath, bucket, key, filen
|
|||
|
||||
url, err := a.S3ObjectPresignedURL(bucket, key)
|
||||
if err != nil {
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
return "", clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
}
|
||||
|
||||
return url, nil
|
||||
|
|
@ -375,7 +375,7 @@ func makeJobErrorFromOsbuildOutput(osbuildOutput *osbuild.Result) *clienterrors.
|
|||
if failedStage != "" {
|
||||
reason += fmt.Sprintf(" in stage: %q", failedStage)
|
||||
}
|
||||
return clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, osbErrors)
|
||||
return clienterrors.New(clienterrors.ErrorBuildJob, reason, osbErrors)
|
||||
}
|
||||
|
||||
func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||
|
|
@ -403,7 +403,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Errorf("Recovered from panic: %v", r)
|
||||
logWithId.Errorf("%s", debug.Stack())
|
||||
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(
|
||||
osbuildJobResult.JobError = clienterrors.New(
|
||||
clienterrors.ErrorJobPanicked,
|
||||
fmt.Sprintf("job panicked:\n%v\n\noriginal error:\n%v", r, osbuildJobResult.JobError),
|
||||
nil,
|
||||
|
|
@ -430,7 +430,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
osbuildVersion, err := osbuild.OSBuildVersion()
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Error getting osbuild binary version", err.Error())
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorBuildJob, "Error getting osbuild binary version", err.Error())
|
||||
return err
|
||||
}
|
||||
osbuildJobResult.OSBuildVersion = osbuildVersion
|
||||
|
|
@ -459,13 +459,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
err = job.DynamicArgs(*jobArgs.ManifestDynArgsIdx, &manifestJR)
|
||||
}
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
// skip the job if the manifest generation failed
|
||||
if manifestJR.JobError != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
jobArgs.Manifest = manifestJR.Manifest
|
||||
|
|
@ -473,7 +473,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
}
|
||||
|
||||
if len(jobArgs.Manifest) == 0 {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, "Job has no manifest", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorEmptyManifest, "Job has no manifest", nil)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -484,12 +484,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
var jobResult worker.JobResult
|
||||
err = job.DynamicArgs(idx, &jobResult)
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
if jobResult.JobError != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorJobDependency, "Job dependency failed", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorJobDependency, "Job dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -503,7 +503,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
// get exports for all job's targets
|
||||
exports := jobArgs.OsbuildExports()
|
||||
if len(exports) == 0 {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "no osbuild export specified for the job", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "no osbuild export specified for the job", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -533,18 +533,18 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
case "aws.ec2":
|
||||
err = os.MkdirAll("/var/tmp/osbuild-composer", 0755)
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, "Unable to create /var/tmp/osbuild-composer needed to aws.ec2 executor", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorInvalidConfig, "Unable to create /var/tmp/osbuild-composer needed to aws.ec2 executor", nil)
|
||||
return err
|
||||
}
|
||||
tmpDir, err := os.MkdirTemp("/var/tmp/osbuild-composer", "")
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, "Unable to create /var/tmp/osbuild-composer needed to aws.ec2 executor", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorInvalidConfig, "Unable to create /var/tmp/osbuild-composer needed to aws.ec2 executor", nil)
|
||||
return err
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
executor = osbuildexecutor.NewAWSEC2Executor(impl.OSBuildExecutor.IAMProfile, impl.OSBuildExecutor.KeyName, impl.OSBuildExecutor.CloudWatchGroup, job.Id().String(), tmpDir)
|
||||
default:
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, "No osbuild executor defined", nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorInvalidConfig, "No osbuild executor defined", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -564,7 +564,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
osbuildJobResult.OSBuildOutput, err = executor.RunOSBuild(jobArgs.Manifest, opts, os.Stderr)
|
||||
// First handle the case when "running" osbuild failed
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", err.Error())
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorBuildJob, "osbuild build failed", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -606,13 +606,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
imagePath := path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename)
|
||||
f, err = os.Open(imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
defer f.Close()
|
||||
err = job.UploadArtifact(jobTarget.ImageName, f)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -630,7 +630,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
tempDirectory, err := os.MkdirTemp(impl.Output, job.Id().String()+"-vmware-*")
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -650,23 +650,23 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
err = os.Symlink(exportedImagePath, imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
err = vmware.ImportVmdk(credentials, imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
} else if strings.HasSuffix(exportedImagePath, ".ova") {
|
||||
err = vmware.ImportOva(credentials, exportedImagePath, jobTarget.ImageName)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
} else {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "No vmdk or ova provided", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, "No vmdk or ova provided", nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -674,12 +674,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewAWSTargetResult(nil, &artifact)
|
||||
a, err := impl.getAWS(targetOptions.Region, targetOptions.AccessKeyID, targetOptions.SecretAccessKey, targetOptions.SessionToken)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
if targetOptions.Key == "" {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "No AWS object key provided", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "No AWS object key provided", nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -687,7 +687,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if bucket == "" {
|
||||
bucket = impl.AWSBucket
|
||||
if bucket == "" {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "No AWS bucket provided", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "No AWS bucket provided", nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -701,25 +701,25 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if strings.HasSuffix(imagePath, ".xz") {
|
||||
imagePath, err = extractXzArchive(imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorTargetError, "Failed to extract compressed image", err.Error())
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorTargetError, "Failed to extract compressed image", err.Error())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
_, err = a.Upload(imagePath, bucket, targetOptions.Key)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
ami, err := a.Register(jobTarget.ImageName, bucket, targetOptions.Key, targetOptions.ShareWithAccounts, arch.Current().String(), targetOptions.BootMode)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
if ami == nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, "No ami returned", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, "No ami returned", nil)
|
||||
break
|
||||
}
|
||||
targetResult.Options = &target.AWSTargetResultOptions{
|
||||
|
|
@ -731,12 +731,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewAWSS3TargetResult(nil, &artifact)
|
||||
a, bucket, err := impl.getAWSForS3Target(targetOptions)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
if targetOptions.Key == "" {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "No AWS object key provided", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "No AWS object key provided", nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -751,7 +751,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewAzureTargetResult(&artifact)
|
||||
azureStorageClient, err := azure.NewStorageClient(targetOptions.StorageAccount, targetOptions.StorageAccessKey)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -771,7 +771,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
)
|
||||
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -781,12 +781,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
g, err := impl.getGCP(targetOptions.Credentials)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
if targetOptions.Object == "" {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "No GCP object key provided", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "No GCP object key provided", nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -794,7 +794,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if bucket == "" {
|
||||
bucket = impl.GCPConfig.Bucket
|
||||
if bucket == "" {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "No GCP bucket provided", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "No GCP bucket provided", nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -803,7 +803,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
_, err = g.StorageObjectUpload(ctx, path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename),
|
||||
bucket, targetOptions.Object, map[string]string{gcp.MetadataKeyImageName: jobTarget.ImageName})
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -822,7 +822,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
// check error from ComputeImageInsert()
|
||||
if importErr != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, importErr.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, importErr.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Infof("[GCP] 💿 Image URL: %s", g.ComputeImageURL(jobTarget.ImageName))
|
||||
|
|
@ -831,7 +831,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Infof("[GCP] 🔗 Sharing the image with: %+v", targetOptions.ShareWithAccounts)
|
||||
err = g.ComputeImageShare(ctx, jobTarget.ImageName, targetOptions.ShareWithAccounts)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorSharingTarget, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -845,13 +845,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
ctx := context.Background()
|
||||
|
||||
if impl.AzureConfig.Creds == nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, "osbuild job has org.osbuild.azure.image target but this worker doesn't have azure credentials", nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorSharingTarget, "osbuild job has org.osbuild.azure.image target but this worker doesn't have azure credentials", nil)
|
||||
break
|
||||
}
|
||||
|
||||
c, err := azure.NewClient(*impl.AzureConfig.Creds, targetOptions.TenantID, targetOptions.SubscriptionID)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Azure] 🔑 Logged in Azure")
|
||||
|
|
@ -860,7 +860,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if location == "" {
|
||||
location, err = c.GetResourceGroupLocation(ctx, targetOptions.ResourceGroup)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("retrieving resource group location failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("retrieving resource group location failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -876,7 +876,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
storageAccountTag,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("searching for a storage account failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("searching for a storage account failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -893,7 +893,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
storageAccountTag,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("creating a new storage account failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("creating a new storage account failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -905,13 +905,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
storageAccount,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("retrieving the storage account key failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("retrieving the storage account key failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
azureStorageClient, err := azure.NewStorageClient(storageAccount, storageAccessKey)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("creating the storage client failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("creating the storage client failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -920,7 +920,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Info("[Azure] 📦 Ensuring that we have a storage container")
|
||||
err = azureStorageClient.CreateStorageContainerIfNotExist(ctx, storageAccount, storageContainer)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("cannot create a storage container: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("cannot create a storage container: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -936,7 +936,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
if strings.HasSuffix(imagePath, ".xz") {
|
||||
imagePath, err = extractXzArchive(imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorTargetError, "Failed to extract compressed image", err.Error())
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorTargetError, "Failed to extract compressed image", err.Error())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -952,7 +952,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
impl.AzureConfig.UploadThreads,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, fmt.Sprintf("uploading the image failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, fmt.Sprintf("uploading the image failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -968,7 +968,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
location,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, fmt.Sprintf("registering the image failed: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, fmt.Sprintf("registering the image failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Azure] 🎉 Image uploaded and registered!")
|
||||
|
|
@ -980,13 +980,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewKojiTargetResult(nil, &artifact)
|
||||
kojiServerURL, err := url.Parse(targetOptions.Server)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("failed to parse Koji server URL: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("failed to parse Koji server URL: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
kojiServer, exists := impl.KojiServers[kojiServerURL.Hostname()]
|
||||
if !exists {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("Koji server has not been configured: %s", kojiServerURL.Hostname()), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("Koji server has not been configured: %s", kojiServerURL.Hostname()), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -995,7 +995,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
kojiAPI, err := koji.NewFromGSSAPI(targetOptions.Server, &kojiServer.creds, kojiTransport)
|
||||
if err != nil {
|
||||
logWithId.Warnf("[Koji] 🔑 login failed: %v", err) // DON'T EDIT: Used for Splunk dashboard
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("failed to authenticate with Koji server %q: %v", kojiServerURL.Hostname(), err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("failed to authenticate with Koji server %q: %v", kojiServerURL.Hostname(), err), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Infof("[Koji] 🔑 Authenticated with %q", kojiServerURL.Hostname())
|
||||
|
|
@ -1008,7 +1008,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorKojiBuild, fmt.Sprintf("failed to open the image for reading: %v", err), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorKojiBuild, fmt.Sprintf("failed to open the image for reading: %v", err), nil)
|
||||
break
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
@ -1017,7 +1017,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
imageHash, imageSize, err := kojiAPI.Upload(file, targetOptions.UploadDirectory, jobTarget.ImageName)
|
||||
if err != nil {
|
||||
logWithId.Warnf("[Koji] ⬆ upload failed: %v", err) // DON'T EDIT: used for Splunk dashboard
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Koji] 🎉 Image successfully uploaded")
|
||||
|
|
@ -1026,7 +1026,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
err = json.Indent(&manifest, jobArgs.Manifest, "", " ")
|
||||
if err != nil {
|
||||
logWithId.Warnf("[Koji] Indenting osbuild manifest failed: %v", err)
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorKojiBuild, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorKojiBuild, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Koji] ⬆ Uploading the osbuild manifest")
|
||||
|
|
@ -1034,7 +1034,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
manifestHash, manifestSize, err := kojiAPI.Upload(&manifest, targetOptions.UploadDirectory, manifestFilename)
|
||||
if err != nil {
|
||||
logWithId.Warnf("[Koji] ⬆ upload failed: %v", err)
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Koji] 🎉 Manifest successfully uploaded")
|
||||
|
|
@ -1043,7 +1043,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
err = osbuildJobResult.OSBuildOutput.Write(&osbuildLog)
|
||||
if err != nil {
|
||||
logWithId.Warnf("[Koji] Converting osbuild log to text failed: %v", err)
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorKojiBuild, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorKojiBuild, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Koji] ⬆ Uploading the osbuild output log")
|
||||
|
|
@ -1051,7 +1051,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
osbuildOutputHash, osbuildOutputSize, err := kojiAPI.Upload(&osbuildLog, targetOptions.UploadDirectory, osbuildOutputFilename)
|
||||
if err != nil {
|
||||
logWithId.Warnf("[Koji] ⬆ upload failed: %v", err)
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Koji] 🎉 osbuild output log successfully uploaded")
|
||||
|
|
@ -1112,14 +1112,14 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
PrivateKey: targetOptions.PrivateKey,
|
||||
})
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[OCI] 🔑 Logged in OCI")
|
||||
logWithId.Info("[OCI] ⬆ Uploading the image")
|
||||
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
@ -1139,7 +1139,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
file,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -1155,7 +1155,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
jobTarget.ImageName,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -1172,14 +1172,14 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
PrivateKey: targetOptions.PrivateKey,
|
||||
})
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[OCI] 🔑 Logged in OCI")
|
||||
logWithId.Info("[OCI] ⬆ Uploading the image")
|
||||
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
@ -1199,13 +1199,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
file,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
uri, err := ociClient.PreAuthenticatedRequest(fmt.Sprintf("osbuild-upload-%d", i), bucket, namespace)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorGeneratingSignedURL, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorGeneratingSignedURL, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[OCI] 🎉 Image uploaded and pre-authenticated request generated!")
|
||||
|
|
@ -1218,7 +1218,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
client, err := impl.getContainerClient(destination, targetOptions)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -1233,7 +1233,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
if err != nil {
|
||||
logWithId.Infof("[container] 🙁 Upload of '%s' failed: %v", sourceRef, err)
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Printf("[container] 🎉 Image uploaded (%s)!", digest.String())
|
||||
|
|
@ -1245,13 +1245,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
client, err := impl.getPulpClient(targetOptions)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
url, err := client.UploadAndDistributeCommit(archivePath, targetOptions.Repository, targetOptions.BasePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
targetResult.Options = &target.PulpOSTreeTargetResultOptions{RepoURL: url}
|
||||
|
|
@ -1259,7 +1259,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
default:
|
||||
// TODO: we may not want to return completely here with multiple targets, because then no TargetErrors will be added to the JobError details
|
||||
// Nevertheless, all target errors will be still in the OSBuildJobResult.
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTarget, fmt.Sprintf("invalid target type: %s", jobTarget.Name), nil)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorInvalidTarget, fmt.Sprintf("invalid target type: %s", jobTarget.Name), nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -1272,7 +1272,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
targetErrors := osbuildJobResult.TargetErrors()
|
||||
if len(targetErrors) != 0 {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorTargetError, "at least one target failed", targetErrors)
|
||||
osbuildJobResult.JobError = clienterrors.New(clienterrors.ErrorTargetError, "at least one target failed", targetErrors)
|
||||
} else {
|
||||
osbuildJobResult.Success = true
|
||||
osbuildJobResult.UploadStatus = "success"
|
||||
|
|
|
|||
|
|
@ -16,19 +16,19 @@ type OSTreeResolveJobImpl struct {
|
|||
func setError(err error, result *worker.OSTreeResolveJobResult) {
|
||||
switch err.(type) {
|
||||
case ostree.RefError:
|
||||
result.JobError = clienterrors.WorkerClientError(
|
||||
result.JobError = clienterrors.New(
|
||||
clienterrors.ErrorOSTreeRefInvalid,
|
||||
"Invalid OSTree ref",
|
||||
err.Error(),
|
||||
)
|
||||
case ostree.ResolveRefError:
|
||||
result.JobError = clienterrors.WorkerClientError(
|
||||
result.JobError = clienterrors.New(
|
||||
clienterrors.ErrorOSTreeRefResolution,
|
||||
"Error resolving OSTree ref",
|
||||
err.Error(),
|
||||
)
|
||||
default:
|
||||
result.JobError = clienterrors.WorkerClientError(
|
||||
result.JobError = clienterrors.New(
|
||||
clienterrors.ErrorOSTreeParamsInvalid,
|
||||
"Invalid OSTree parameters or parameter combination",
|
||||
err.Error(),
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
|||
|
||||
if len(dynArgs) == 0 {
|
||||
reason := "No dynamic arguments"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason, nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorNoDynamicArgs, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -504,28 +504,28 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
|||
err = json.Unmarshal(dynArgs[0], &depsolveResults)
|
||||
if err != nil {
|
||||
reason := "Error parsing dynamic arguments"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, reason, nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorParsingDynamicArgs, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = workers.DepsolveJobInfo(depsolveJobID, &depsolveResults)
|
||||
if err != nil {
|
||||
reason := "Error reading depsolve status"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if jobErr := depsolveResults.JobError; jobErr != nil {
|
||||
if jobErr.ID == clienterrors.ErrorDNFDepsolveError || jobErr.ID == clienterrors.ErrorDNFMarkingErrors {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency input, bad package set requested", jobErr.Details)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency input, bad package set requested", jobErr.Details)
|
||||
return
|
||||
}
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency", jobErr.Details)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency", jobErr.Details)
|
||||
return
|
||||
}
|
||||
|
||||
if len(depsolveResults.PackageSpecs) == 0 {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs", nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs", nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -537,12 +537,12 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
|||
|
||||
if err != nil {
|
||||
reason := "Error reading container resolve job status"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if jobErr := result.JobError; jobErr != nil {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorContainerDependency, "Error in container resolve job dependency", nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorContainerDependency, "Error in container resolve job dependency", nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -580,12 +580,12 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
|||
if err != nil {
|
||||
reason := "Error reading ostree resolve job status"
|
||||
logrus.Errorf("%s: %v", reason, err)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if jobErr := result.JobError; jobErr != nil {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOSTreeDependency, "Error in ostree resolve job dependency", nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorOSTreeDependency, "Error in ostree resolve job dependency", nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -621,7 +621,7 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
|||
ms, err := manifestSource.Serialize(depsolveResults.PackageSpecs, containerSpecs, ostreeCommitSpecs, depsolveResults.RepoConfigs)
|
||||
if err != nil {
|
||||
reason := "Error serializing manifest"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
{
|
||||
initResult: worker.KojiInitJobResult{
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, "Koji init error", nil),
|
||||
JobError: clienterrors.New(clienterrors.ErrorKojiInit, "Koji init error", nil),
|
||||
},
|
||||
},
|
||||
buildResult: worker.OSBuildJobResult{
|
||||
|
|
@ -240,7 +240,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
Success: true,
|
||||
},
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Koji build error", nil),
|
||||
JobError: clienterrors.New(clienterrors.ErrorBuildJob, "Koji build error", nil),
|
||||
},
|
||||
},
|
||||
composeReplyCode: http.StatusCreated,
|
||||
|
|
@ -346,7 +346,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
},
|
||||
finalizeResult: worker.KojiFinalizeJobResult{
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji finalize error", nil),
|
||||
JobError: clienterrors.New(clienterrors.ErrorKojiFinalize, "Koji finalize error", nil),
|
||||
},
|
||||
},
|
||||
composeReplyCode: http.StatusCreated,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
|
|||
}
|
||||
|
||||
if failDepsolve {
|
||||
dJR.JobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, "DNF Error", nil)
|
||||
dJR.JobResult.JobError = clienterrors.New(clienterrors.ErrorDNFOtherError, "DNF Error", nil)
|
||||
}
|
||||
|
||||
rawMsg, err := json.Marshal(dJR)
|
||||
|
|
@ -112,7 +112,7 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
|
|||
}
|
||||
|
||||
if failDepsolve {
|
||||
oJR.JobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOSTreeParamsInvalid, "ostree error", nil)
|
||||
oJR.JobResult.JobError = clienterrors.New(clienterrors.ErrorOSTreeParamsInvalid, "ostree error", nil)
|
||||
}
|
||||
|
||||
rawMsg, err := json.Marshal(oJR)
|
||||
|
|
@ -800,7 +800,7 @@ func TestComposeJobError(t *testing.T) {
|
|||
}`, jobId, jobId))
|
||||
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Error building image", nil),
|
||||
JobError: clienterrors.New(clienterrors.ErrorBuildJob, "Error building image", nil),
|
||||
}
|
||||
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||
require.NoError(t, err)
|
||||
|
|
@ -865,7 +865,7 @@ func TestComposeDependencyError(t *testing.T) {
|
|||
}`, jobId, jobId))
|
||||
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil),
|
||||
JobError: clienterrors.New(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil),
|
||||
}
|
||||
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||
require.NoError(t, err)
|
||||
|
|
@ -942,12 +942,12 @@ func TestComposeTargetErrors(t *testing.T) {
|
|||
{
|
||||
Name: "org.osbuild.aws",
|
||||
Options: target.AWSTargetResultOptions{Ami: "", Region: ""},
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, "error importing image", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorImportingImage, "error importing image", nil),
|
||||
},
|
||||
},
|
||||
}
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorTargetError, "at least one target failed", oJR.TargetErrors()),
|
||||
JobError: clienterrors.New(clienterrors.ErrorTargetError, "at least one target failed", oJR.TargetErrors()),
|
||||
}
|
||||
oJR.JobResult = jobErr
|
||||
jobResult, err := json.Marshal(oJR)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func (r *Resolver) Finish() []Spec {
|
|||
|
||||
var resultError *clienterrors.Error
|
||||
if result.err != nil {
|
||||
resultError = clienterrors.WorkerClientError(
|
||||
resultError = clienterrors.New(
|
||||
clienterrors.ErrorRemoteFileResolution,
|
||||
result.err.Error(),
|
||||
result.url,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func TestTargetResultUnmarshal(t *testing.T) {
|
|||
resultJSON: []byte(`{"name":"org.osbuild.aws","target_error":{"id":11,"reason":"failed to uplad image","details":"detail"}}`),
|
||||
expectedResult: &TargetResult{
|
||||
Name: TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to uplad image", "detail"),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to uplad image", "detail"),
|
||||
},
|
||||
},
|
||||
// unknown target name
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func TestComposeStatusFromJobError(t *testing.T) {
|
|||
require.Equal(t, jobId, j)
|
||||
|
||||
jobResult := worker.OSBuildJobResult{}
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "Upload error", nil)
|
||||
jobResult.JobError = clienterrors.New(clienterrors.ErrorUploadingImage, "Upload error", nil)
|
||||
rawResult, err := json.Marshal(jobResult)
|
||||
require.NoError(t, err)
|
||||
err = api.workers.FinishJob(token, rawResult)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func (e *Error) IsDependencyError() bool {
|
|||
}
|
||||
}
|
||||
|
||||
func WorkerClientError(code ClientErrorCode, reason string, details interface{}) *Error {
|
||||
func New(code ClientErrorCode, reason string, details interface{}) *Error {
|
||||
return &Error{
|
||||
ID: code,
|
||||
Reason: reason,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ func (j *OSBuildJobResult) TargetErrors() []*clienterrors.Error {
|
|||
// Add the target name to the error details, because the error reason
|
||||
// may not contain any information to determine the type of the target
|
||||
// which failed.
|
||||
targetErrors = append(targetErrors, clienterrors.WorkerClientError(targetError.ID, targetError.Reason, targetResult.Name))
|
||||
targetErrors = append(targetErrors, clienterrors.New(targetError.ID, targetError.Reason, targetResult.Name))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,22 +21,22 @@ func TestOSBuildJobResultTargetErrors(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
targetErrors: []*clienterrors.Error{
|
||||
clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
||||
clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", target.TargetNameVMWare),
|
||||
clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", target.TargetNameAWSS3),
|
||||
clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
||||
clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", target.TargetNameVMWare),
|
||||
clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", target.TargetNameAWSS3),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -44,20 +44,20 @@ func TestOSBuildJobResultTargetErrors(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
targetErrors: []*clienterrors.Error{
|
||||
clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
||||
clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", target.TargetNameAWSS3),
|
||||
clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
||||
clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", target.TargetNameAWSS3),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -99,19 +99,19 @@ func TestOSBuildJobResultTargetResultsByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -119,7 +119,7 @@ func TestOSBuildJobResultTargetResultsByName(t *testing.T) {
|
|||
targetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -129,19 +129,19 @@ func TestOSBuildJobResultTargetResultsByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -149,11 +149,11 @@ func TestOSBuildJobResultTargetResultsByName(t *testing.T) {
|
|||
targetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -163,19 +163,19 @@ func TestOSBuildJobResultTargetResultsByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -200,19 +200,19 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -222,11 +222,11 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
targetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -235,19 +235,19 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -258,7 +258,7 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
targetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -267,19 +267,19 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -290,11 +290,11 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
targetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -303,19 +303,19 @@ func TestOSBuildJobResultTargetResultsFilterByName(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
TargetError: clienterrors.New(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ func (s *Server) WatchHeartbeats() {
|
|||
logrus.Infof("Removing unresponsive job: %s\n", id)
|
||||
|
||||
missingHeartbeatResult := JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorJobMissingHeartbeat,
|
||||
JobError: clienterrors.New(clienterrors.ErrorJobMissingHeartbeat,
|
||||
fmt.Sprintf("Workers running this job stopped responding more than %d times.", maxHeartbeatRetries),
|
||||
nil),
|
||||
}
|
||||
|
|
@ -338,11 +338,11 @@ func (s *Server) OSBuildJobInfo(id uuid.UUID, result *OSBuildJobResult) (*JobInf
|
|||
|
||||
if result.JobError == nil && !jobInfo.JobStatus.Finished.IsZero() {
|
||||
if result.OSBuildOutput == nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorBuildJob, "osbuild build failed", nil)
|
||||
} else if len(result.OSBuildOutput.Error) > 0 {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, string(result.OSBuildOutput.Error), nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorOldResultCompatible, string(result.OSBuildOutput.Error), nil)
|
||||
} else if len(result.TargetErrors()) > 0 {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorTargetError, "at least one target failed", result.TargetErrors())
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorTargetError, "at least one target failed", result.TargetErrors())
|
||||
}
|
||||
}
|
||||
// For backwards compatibility: OSBuildJobResult didn't use to have a
|
||||
|
|
@ -365,7 +365,7 @@ func (s *Server) KojiInitJobInfo(id uuid.UUID, result *KojiInitJobResult) (*JobI
|
|||
}
|
||||
|
||||
if result.JobError == nil && result.KojiError != "" {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, result.KojiError, nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorOldResultCompatible, result.KojiError, nil)
|
||||
}
|
||||
|
||||
return jobInfo, nil
|
||||
|
|
@ -382,7 +382,7 @@ func (s *Server) KojiFinalizeJobInfo(id uuid.UUID, result *KojiFinalizeJobResult
|
|||
}
|
||||
|
||||
if result.JobError == nil && result.KojiError != "" {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, result.KojiError, nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorOldResultCompatible, result.KojiError, nil)
|
||||
}
|
||||
|
||||
return jobInfo, nil
|
||||
|
|
@ -400,9 +400,9 @@ func (s *Server) DepsolveJobInfo(id uuid.UUID, result *DepsolveJobResult) (*JobI
|
|||
|
||||
if result.JobError == nil && result.Error != "" {
|
||||
if result.ErrorType == DepsolveErrorType {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, result.Error, nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorDNFDepsolveError, result.Error, nil)
|
||||
} else {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorRPMMDError, result.Error, nil)
|
||||
result.JobError = clienterrors.New(clienterrors.ErrorRPMMDError, result.Error, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ func TestDepsolveLegacyErrorConversion(t *testing.T) {
|
|||
Error: reason,
|
||||
ErrorType: errType,
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, reason, nil),
|
||||
JobError: clienterrors.New(clienterrors.ErrorDNFDepsolveError, reason, nil),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue