worker: Remove ellipsis operator from clienterrors.Error
The ellipsis operator was used as a hack to not need to pass any details as an argument, but it makes what the end object will actually look like less obvious. It also makes it impossible to pass an array to details without getting a nested array. Fixes #2874
This commit is contained in:
parent
1fb6a574cb
commit
111feda1f5
14 changed files with 103 additions and 108 deletions
|
|
@ -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())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorContainerResolution, err.Error(), nil)
|
||||
} else {
|
||||
for i, spec := range specs {
|
||||
result.Specs[i] = worker.ContainerSpec{
|
||||
|
|
|
|||
|
|
@ -50,20 +50,20 @@ func (impl *DepsolveJobImpl) Run(job worker.Job) error {
|
|||
// Error originates from dnf-json
|
||||
switch e.Kind {
|
||||
case "DepsolveError":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, err.Error())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, err.Error(), nil)
|
||||
case "MarkingErrors":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFMarkingErrors, err.Error())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFMarkingErrors, err.Error(), nil)
|
||||
case "RepoError":
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFRepoError, err.Error())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFRepoError, err.Error(), nil)
|
||||
default:
|
||||
// This still has the kind/reason format but a kind that's returned
|
||||
// by dnf-json and not explicitly handled here.
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, err.Error())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, err.Error(), nil)
|
||||
logWithId.Errorf("Unhandled dnf-json error in depsolve job: %v", err)
|
||||
}
|
||||
case error:
|
||||
// Error originates from internal/rpmmd, not from dnf-json
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorRPMMDError, err.Error())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorRPMMDError, err.Error(), nil)
|
||||
logWithId.Errorf("rpmmd error in depsolve job: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
|
||||
// Check the dependencies early.
|
||||
if hasFailedDependency(*initArgs, osbuildResults) {
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFailedDependency, "At least one job dependency failed")
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFailedDependency, "At least one job dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
kojiTargetResults := buildArgs.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")
|
||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Exactly one Koji target result is expected per osbuild job", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
|||
var result worker.KojiFinalizeJobResult
|
||||
err = impl.kojiImport(args.Server, build, buildRoots, images, args.KojiDirectory, initArgs.Token)
|
||||
if err != nil {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, err.Error())
|
||||
result.JobError = clienterrors.WorkerClientError(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())
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, err.Error(), nil)
|
||||
}
|
||||
|
||||
err = job.Update(&result)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,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)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, nil)
|
||||
return
|
||||
} else {
|
||||
logWithId.Infof("osbuild job succeeded")
|
||||
|
|
@ -195,13 +195,13 @@ func uploadToS3(a *awscloud.AWS, outputDirectory, exportPath, bucket, key, filen
|
|||
|
||||
_, err := a.Upload(imagePath, bucket, key)
|
||||
if err != nil {
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
|
||||
}
|
||||
|
||||
url, err := a.S3ObjectPresignedURL(bucket, key)
|
||||
if err != nil {
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
}
|
||||
|
||||
return url, nil
|
||||
|
|
@ -248,7 +248,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
hostOS, err := common.GetRedHatRelease()
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, err.Error())
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, err.Error(), nil)
|
||||
return nil
|
||||
}
|
||||
osbuildJobResult.HostOS = hostOS
|
||||
|
|
@ -298,20 +298,20 @@ 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")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(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")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
jobArgs.Manifest = manifestJR.Manifest
|
||||
}
|
||||
|
||||
if len(jobArgs.Manifest) == 0 {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, "Job has no manifest")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, "Job has no manifest", nil)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -322,12 +322,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")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, "Error parsing dynamic args", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
if jobResult.JobError != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorJobDependency, "Job dependency failed")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorJobDependency, "Job dependency failed", nil)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -338,7 +338,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")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "no osbuild export specified for the job", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
osbuildJobResult.OSBuildOutput, err = osbuild.RunOSBuild(jobArgs.Manifest, impl.Store, outputDirectory, exports, nil, extraEnv, true, os.Stderr)
|
||||
// First handle the case when "running" osbuild failed
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", nil)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
// Second handle the case when the build failed, but osbuild finished successfully
|
||||
if !osbuildJobResult.OSBuildOutput.Success {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed")
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -394,13 +394,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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
tempDirectory, err := ioutil.TempDir(impl.Output, job.Id().String()+"-vmware-*")
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -435,13 +435,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
exportedImagePath := path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename)
|
||||
err = os.Symlink(exportedImagePath, imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
err = vmware.UploadImage(credentials, imagePath)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewAWSTargetResult(nil)
|
||||
a, err := impl.getAWS(targetOptions.Region, targetOptions.AccessKeyID, targetOptions.SecretAccessKey, targetOptions.SessionToken)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -479,18 +479,18 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
_, err = a.Upload(imagePath, bucket, key)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
ami, err := a.Register(jobTarget.ImageName, bucket, key, targetOptions.ShareWithAccounts, common.CurrentArch())
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
if ami == nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, "No ami returned")
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, "No ami returned", nil)
|
||||
break
|
||||
}
|
||||
targetResult.Options = &target.AWSTargetResultOptions{
|
||||
|
|
@ -502,7 +502,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewAWSS3TargetResult(nil)
|
||||
a, bucket, err := impl.getAWSForS3Target(targetOptions)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -517,7 +517,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewAzureTargetResult()
|
||||
azureStorageClient, err := azure.NewStorageClient(targetOptions.StorageAccount, targetOptions.StorageAccessKey)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -537,7 +537,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
)
|
||||
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -547,7 +547,7 @@ 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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
_, err = g.StorageObjectUpload(ctx, path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename),
|
||||
targetOptions.Bucket, targetOptions.Object, map[string]string{gcp.MetadataKeyImageName: jobTarget.ImageName})
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
// check error from ComputeImageInsert()
|
||||
if importErr != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, importErr.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, importErr.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Infof("[GCP] 💿 Image URL: %s", g.ComputeImageURL(jobTarget.ImageName))
|
||||
|
|
@ -583,7 +583,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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -597,13 +597,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
ctx := context.Background()
|
||||
|
||||
if impl.AzureCreds == nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, "osbuild job has org.osbuild.azure.image target but this worker doesn't have azure credentials")
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(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.AzureCreds, targetOptions.TenantID)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Azure] 🔑 Logged in Azure")
|
||||
|
|
@ -620,7 +620,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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("searching for a storage account failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -638,7 +638,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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("creating a new storage account failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
@ -651,13 +651,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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("creating the storage client failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -666,7 +666,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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("cannot create a storage container: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -698,7 +698,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
azure.DefaultUploadThreads,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, fmt.Sprintf("uploading the image failed: %v", err))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, fmt.Sprintf("uploading the image failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -714,7 +714,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetOptions.Location,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, fmt.Sprintf("registering the image failed: %v", err))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, fmt.Sprintf("registering the image failed: %v", err), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Azure] 🎉 Image uploaded and registered!")
|
||||
|
|
@ -726,13 +726,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
targetResult = target.NewKojiTargetResult(nil)
|
||||
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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(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()))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("Koji server has not been configured: %s", kojiServerURL.Hostname()), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -740,7 +740,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
|
||||
kojiAPI, err := koji.NewFromGSSAPI(targetOptions.Server, &kojiServer.creds, kojiTransport)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, fmt.Sprintf("failed to authenticate with Koji server %q: %v", kojiServerURL.Hostname(), err))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(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())
|
||||
|
|
@ -753,7 +753,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))
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorKojiBuild, fmt.Sprintf("failed to open the image for reading: %v", err), nil)
|
||||
break
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
@ -761,7 +761,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
logWithId.Info("[Koji] ⬆ Uploading the image")
|
||||
imageHash, imageSize, err := kojiAPI.Upload(file, targetOptions.UploadDirectory, jobTarget.ImageName)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[Koji] 🎉 Image successfully uploaded")
|
||||
|
|
@ -782,14 +782,14 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
PrivateKey: targetOptions.PrivateKey,
|
||||
})
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
defer file.Close()
|
||||
|
|
@ -803,7 +803,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
jobTarget.ImageName,
|
||||
)
|
||||
if err != nil {
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Info("[OCI] 🎉 Image uploaded and registered!")
|
||||
|
|
@ -817,7 +817,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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
|
||||
|
|
@ -832,7 +832,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())
|
||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||
break
|
||||
}
|
||||
logWithId.Printf("[container] 🎉 Image uploaded (%s)!", digest.String())
|
||||
|
|
@ -841,7 +841,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))
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTarget, fmt.Sprintf("invalid target type: %s", jobTarget.Name), nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID
|
|||
|
||||
if len(dynArgs) == 0 {
|
||||
reason := "No dynamic arguments"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -288,35 +288,35 @@ func generateManifest(ctx context.Context, workers *worker.Server, depsolveJobID
|
|||
err = json.Unmarshal(dynArgs[0], &depsolveResults)
|
||||
if err != nil {
|
||||
reason := "Error parsing dynamic arguments"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(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)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(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")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency input, bad package set requested", nil)
|
||||
return
|
||||
}
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDepsolveDependency, "Error in depsolve job dependency", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if len(depsolveResults.PackageSpecs) == 0 {
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyPackageSpecs, "Received empty package specs", nil)
|
||||
return
|
||||
}
|
||||
|
||||
manifest, err := imageType.Manifest(b, options, repos, depsolveResults.PackageSpecs, nil, seed)
|
||||
if err != nil {
|
||||
reason := "Error generating manifest"
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason)
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
{
|
||||
initResult: worker.KojiInitJobResult{
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, "Koji init error"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, "Koji init error", nil),
|
||||
},
|
||||
},
|
||||
buildResult: worker.OSBuildJobResult{
|
||||
|
|
@ -205,7 +205,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
Success: true,
|
||||
},
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Koji build error"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Koji build error", nil),
|
||||
},
|
||||
},
|
||||
composeReplyCode: http.StatusCreated,
|
||||
|
|
@ -215,7 +215,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
"image_status": {
|
||||
"status": "failure",
|
||||
"error": {
|
||||
"details": null,
|
||||
"id": 10,
|
||||
"reason": "Koji build error"
|
||||
}
|
||||
|
|
@ -224,7 +223,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
{
|
||||
"status": "failure",
|
||||
"error": {
|
||||
"details": null,
|
||||
"id": 10,
|
||||
"reason": "Koji build error"
|
||||
}
|
||||
|
|
@ -299,7 +297,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
},
|
||||
finalizeResult: worker.KojiFinalizeJobResult{
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji finalize error"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji finalize error", nil),
|
||||
},
|
||||
},
|
||||
composeReplyCode: http.StatusCreated,
|
||||
|
|
@ -346,6 +344,7 @@ func TestKojiCompose(t *testing.T) {
|
|||
clienterrors.WorkerClientError(
|
||||
clienterrors.ErrorDNFOtherError,
|
||||
"DNF Error",
|
||||
nil,
|
||||
),
|
||||
),
|
||||
},
|
||||
|
|
@ -359,7 +358,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
"details": [
|
||||
{
|
||||
"id": 22,
|
||||
"details": null,
|
||||
"reason": "DNF Error"
|
||||
}
|
||||
],
|
||||
|
|
@ -374,7 +372,6 @@ func TestKojiCompose(t *testing.T) {
|
|||
"details": [
|
||||
{
|
||||
"id": 22,
|
||||
"details": null,
|
||||
"reason": "DNF Error"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ func TestComposeJobError(t *testing.T) {
|
|||
}`, jobId, jobId))
|
||||
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Error building image"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Error building image", nil),
|
||||
}
|
||||
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||
require.NoError(t, err)
|
||||
|
|
@ -835,9 +835,9 @@ func TestComposeDependencyError(t *testing.T) {
|
|||
}`, jobId, jobId))
|
||||
|
||||
jobErr := worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed"),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, "Manifest dependency failed", nil),
|
||||
}
|
||||
jobErr.JobError.Details = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, "DNF Error")
|
||||
jobErr.JobError.Details = clienterrors.WorkerClientError(clienterrors.ErrorDNFOtherError, "DNF Error", nil)
|
||||
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -851,7 +851,6 @@ func TestComposeDependencyError(t *testing.T) {
|
|||
"image_status": {
|
||||
"error": {
|
||||
"details": {
|
||||
"details": null,
|
||||
"id": 22,
|
||||
"reason": "DNF Error"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func TestTargetResultUnmarshal(t *testing.T) {
|
|||
},
|
||||
// target results with error without options
|
||||
{
|
||||
resultJSON: []byte(`{"name":"org.osbuild.aws","target_error":{"id":11,"reason":"failed to uplad image","details":["detail"]}}`),
|
||||
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"),
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func TestComposeStatusFromJobError(t *testing.T) {
|
|||
require.Equal(t, jobId, j)
|
||||
|
||||
jobResult := worker.OSBuildJobResult{}
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "Upload error")
|
||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "Upload error", nil)
|
||||
rawResult, err := json.Marshal(jobResult)
|
||||
require.NoError(t, err)
|
||||
err = api.workers.FinishJob(token, rawResult)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ func (e *Error) IsDependencyError() bool {
|
|||
}
|
||||
}
|
||||
|
||||
func WorkerClientError(code ClientErrorCode, reason string, details ...interface{}) *Error {
|
||||
func WorkerClientError(code ClientErrorCode, reason string, details interface{}) *Error {
|
||||
return &Error{
|
||||
ID: code,
|
||||
Reason: reason,
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ func TestOSBuildJobResultTargetErrors(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -44,14 +44,14 @@ func TestOSBuildJobResultTargetErrors(t *testing.T) {
|
|||
TargetResults: []*target.TargetResult{
|
||||
{
|
||||
Name: target.TargetNameAWS,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS"),
|
||||
TargetError: clienterrors.WorkerClientError(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"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -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"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3"),
|
||||
TargetError: clienterrors.WorkerClientError(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"),
|
||||
TargetError: clienterrors.WorkerClientError(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"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3"),
|
||||
TargetError: clienterrors.WorkerClientError(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"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(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"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameVMWare,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", nil),
|
||||
},
|
||||
{
|
||||
Name: target.TargetNameAWSS3,
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3"),
|
||||
TargetError: clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "failed to upload image to AWS S3", nil),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ func (s *Server) WatchHeartbeats() {
|
|||
logrus.Infof("Removing unresponsive job: %s\n", id)
|
||||
|
||||
missingHeartbeatResult := JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorJobMissingHeartbeat, "Worker running this job stopped responding."),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorJobMissingHeartbeat, "Worker running this job stopped responding.", nil),
|
||||
}
|
||||
|
||||
resJson, err := json.Marshal(missingHeartbeatResult)
|
||||
|
|
@ -240,7 +240,6 @@ func (s *Server) JobDependencyChainErrors(id uuid.UUID) (*clienterrors.Error, er
|
|||
if len(depErrors) > 0 {
|
||||
jobError.Details = depErrors
|
||||
}
|
||||
|
||||
return jobError, nil
|
||||
}
|
||||
|
||||
|
|
@ -259,9 +258,9 @@ 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")
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed", nil)
|
||||
} else if len(result.OSBuildOutput.Error) > 0 {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, string(result.OSBuildOutput.Error))
|
||||
result.JobError = clienterrors.WorkerClientError(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())
|
||||
}
|
||||
|
|
@ -286,7 +285,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)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, result.KojiError, nil)
|
||||
}
|
||||
|
||||
return jobInfo, nil
|
||||
|
|
@ -303,7 +302,7 @@ func (s *Server) KojiFinalizeJobInfo(id uuid.UUID, result *KojiFinalizeJobResult
|
|||
}
|
||||
|
||||
if result.JobError == nil && result.KojiError != "" {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, result.KojiError)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorOldResultCompatible, result.KojiError, nil)
|
||||
}
|
||||
|
||||
return jobInfo, nil
|
||||
|
|
@ -321,9 +320,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)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, result.Error, nil)
|
||||
} else {
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorRPMMDError, result.Error)
|
||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorRPMMDError, result.Error, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ func TestDepsolveLegacyErrorConversion(t *testing.T) {
|
|||
Error: reason,
|
||||
ErrorType: errType,
|
||||
JobResult: worker.JobResult{
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, reason),
|
||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, reason, nil),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue