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
|
var args worker.AWSEC2CopyJob
|
||||||
err := job.Args(&args)
|
err := job.Args(&args)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
aws, err := getAWS(impl.AWSCreds, args.TargetRegion)
|
aws, err := getAWS(impl.AWSCreds, args.TargetRegion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Errorf("Error creating aws client: %v", err)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ami, err := aws.CopyImage(args.TargetName, args.Ami, args.SourceRegion)
|
ami, err := aws.CopyImage(args.TargetName, args.Ami, args.SourceRegion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Errorf("Error copying ami: %v", err)
|
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 {
|
if aerr, ok := err.(awserr.Error); ok {
|
||||||
switch aerr.Code() {
|
switch aerr.Code() {
|
||||||
case "InvalidRegion":
|
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":
|
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":
|
case "InvalidAMIID.NotFound":
|
||||||
fallthrough // CopyImage returns InvalidRequest instead of InvalidAMIID.NotFound
|
fallthrough // CopyImage returns InvalidRequest instead of InvalidAMIID.NotFound
|
||||||
case "InvalidRequest":
|
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
|
return err
|
||||||
|
|
@ -89,24 +89,24 @@ func (impl *AWSEC2ShareJobImpl) Run(job worker.Job) error {
|
||||||
var args worker.AWSEC2ShareJob
|
var args worker.AWSEC2ShareJob
|
||||||
err := job.Args(&args)
|
err := job.Args(&args)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.Ami == "" || args.Region == "" {
|
if args.Ami == "" || args.Region == "" {
|
||||||
if job.NDynamicArgs() != 1 {
|
if job.NDynamicArgs() != 1 {
|
||||||
logWithId.Error("No arguments given and dynamic args empty")
|
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
|
return nil
|
||||||
}
|
}
|
||||||
var cjResult worker.AWSEC2CopyJobResult
|
var cjResult worker.AWSEC2CopyJobResult
|
||||||
err = job.DynamicArgs(0, &cjResult)
|
err = job.DynamicArgs(0, &cjResult)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
if cjResult.JobError != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,22 +117,22 @@ func (impl *AWSEC2ShareJobImpl) Run(job worker.Job) error {
|
||||||
aws, err := getAWS(impl.AWSCreds, args.Region)
|
aws, err := getAWS(impl.AWSCreds, args.Region)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Errorf("Error creating aws client: %v", err)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = aws.ShareImage(args.Ami, args.ShareWithAccounts)
|
err = aws.ShareImage(args.Ami, args.ShareWithAccounts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Errorf("Error sharing image: %v", err)
|
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 {
|
if aerr, ok := err.(awserr.Error); ok {
|
||||||
switch aerr.Code() {
|
switch aerr.Code() {
|
||||||
case "InvalidAMIID.Malformed":
|
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":
|
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":
|
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
|
return err
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ func (impl *ContainerResolveJobImpl) Run(job worker.Job) error {
|
||||||
specs, err := resolver.Finish()
|
specs, err := resolver.Finish()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorContainerResolution, err.Error(), nil)
|
result.JobError = clienterrors.New(clienterrors.ErrorContainerResolution, err.Error(), nil)
|
||||||
} else {
|
} else {
|
||||||
for i, spec := range specs {
|
for i, spec := range specs {
|
||||||
result.Specs[i] = worker.ContainerSpec{
|
result.Specs[i] = worker.ContainerSpec{
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,16 @@ func workerClientErrorFrom(err error) (*clienterrors.Error, error) {
|
||||||
details := e.Reason
|
details := e.Reason
|
||||||
switch e.Kind {
|
switch e.Kind {
|
||||||
case "DepsolveError":
|
case "DepsolveError":
|
||||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, reason, details), nil
|
return clienterrors.New(clienterrors.ErrorDNFDepsolveError, reason, details), nil
|
||||||
case "MarkingErrors":
|
case "MarkingErrors":
|
||||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFMarkingErrors, reason, details), nil
|
return clienterrors.New(clienterrors.ErrorDNFMarkingErrors, reason, details), nil
|
||||||
case "RepoError":
|
case "RepoError":
|
||||||
return clienterrors.WorkerClientError(clienterrors.ErrorDNFRepoError, reason, details), nil
|
return clienterrors.New(clienterrors.ErrorDNFRepoError, reason, details), nil
|
||||||
default:
|
default:
|
||||||
err := fmt.Errorf("Unhandled dnf-json error in depsolve job: %v", err)
|
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
|
// This still has the kind/reason format but a kind that's returned
|
||||||
// by dnf-json and not explicitly handled here.
|
// 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:
|
default:
|
||||||
reason := "rpmmd error in depsolve job"
|
reason := "rpmmd error in depsolve job"
|
||||||
|
|
@ -101,7 +101,7 @@ func workerClientErrorFrom(err error) (*clienterrors.Error, error) {
|
||||||
details = err.Error()
|
details = err.Error()
|
||||||
}
|
}
|
||||||
// Error originates from internal/rpmmd, not from dnf-json
|
// 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 {
|
for _, baseurlstr := range repo.BaseURLs {
|
||||||
match, err := impl.RepositoryMTLSConfig.CompareBaseURL(baseurlstr)
|
match, err := impl.RepositoryMTLSConfig.CompareBaseURL(baseurlstr)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
if match {
|
if match {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func (impl *FileResolveJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
if result.Results == nil || len(result.Results) == 0 {
|
if result.Results == nil || len(result.Results) == 0 {
|
||||||
logWithId.Infof("Resolving file contents failed: %v", err)
|
logWithId.Infof("Resolving file contents failed: %v", err)
|
||||||
result.JobError = clienterrors.WorkerClientError(
|
result.JobError = clienterrors.New(
|
||||||
clienterrors.ErrorRemoteFileResolution,
|
clienterrors.ErrorRemoteFileResolution,
|
||||||
"Error resolving file contents",
|
"Error resolving file contents",
|
||||||
"All remote file contents returned empty",
|
"All remote file contents returned empty",
|
||||||
|
|
@ -70,7 +70,7 @@ func (impl *FileResolveJobImpl) Run(job worker.Job) error {
|
||||||
if len(resolutionErrors) == 0 {
|
if len(resolutionErrors) == 0 {
|
||||||
result.Success = true
|
result.Success = true
|
||||||
} else {
|
} else {
|
||||||
result.JobError = clienterrors.WorkerClientError(
|
result.JobError = clienterrors.New(
|
||||||
clienterrors.ErrorRemoteFileResolution,
|
clienterrors.ErrorRemoteFileResolution,
|
||||||
"at least one file resolution failed",
|
"at least one file resolution failed",
|
||||||
resolutionErrors,
|
resolutionErrors,
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
err := job.Args(args)
|
err := job.Args(args)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,13 +124,13 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
||||||
var osbuildResults []worker.OSBuildJobResult
|
var osbuildResults []worker.OSBuildJobResult
|
||||||
initArgs, osbuildResults, err = extractDynamicArgs(job)
|
initArgs, osbuildResults, err = extractDynamicArgs(job)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the dependencies early.
|
// Check the dependencies early.
|
||||||
if hasFailedDependency(*initArgs, osbuildResults) {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +149,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error {
|
||||||
kojiTargetResults := buildResult.TargetResultsByName(target.TargetNameKoji)
|
kojiTargetResults := buildResult.TargetResultsByName(target.TargetNameKoji)
|
||||||
// Only a single Koji target is allowed per osbuild job
|
// Only a single Koji target is allowed per osbuild job
|
||||||
if len(kojiTargetResults) != 1 {
|
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
|
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)
|
err = impl.kojiImport(args.Server, build, buildRoots, outputs, args.KojiDirectory, initArgs.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
kojiFinalizeJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, err.Error(), nil)
|
kojiFinalizeJobResult.JobError = clienterrors.New(clienterrors.ErrorKojiFinalize, err.Error(), nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ func (impl *KojiInitJobImpl) Run(job worker.Job) error {
|
||||||
var result worker.KojiInitJobResult
|
var result worker.KojiInitJobResult
|
||||||
result.Token, result.BuildID, err = impl.kojiInit(args.Server, args.Name, args.Version, args.Release)
|
result.Token, result.BuildID, err = impl.kojiInit(args.Server, args.Name, args.Version, args.Release)
|
||||||
if err != nil {
|
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)
|
err = job.Update(&result)
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ func validateResult(result *worker.OSBuildJobResult, jobID string) {
|
||||||
if result.OSBuildOutput == nil || !result.OSBuildOutput.Success {
|
if result.OSBuildOutput == nil || !result.OSBuildOutput.Success {
|
||||||
reason := "osbuild job was unsuccessful"
|
reason := "osbuild job was unsuccessful"
|
||||||
logWithId.Errorf("osbuild job failed: %s", reason)
|
logWithId.Errorf("osbuild job failed: %s", reason)
|
||||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, reason, nil)
|
result.JobError = clienterrors.New(clienterrors.ErrorBuildJob, reason, nil)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
logWithId.Infof("osbuild job succeeded")
|
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)
|
result, err := a.Upload(imagePath, bucket, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
return "", clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if public {
|
if public {
|
||||||
err := a.MarkS3ObjectAsPublic(bucket, key)
|
err := a.MarkS3ObjectAsPublic(bucket, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
return "", clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.Location, 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)
|
url, err := a.S3ObjectPresignedURL(bucket, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
return "", clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
return url, nil
|
return url, nil
|
||||||
|
|
@ -375,7 +375,7 @@ func makeJobErrorFromOsbuildOutput(osbuildOutput *osbuild.Result) *clienterrors.
|
||||||
if failedStage != "" {
|
if failedStage != "" {
|
||||||
reason += fmt.Sprintf(" in stage: %q", 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 {
|
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("Recovered from panic: %v", r)
|
||||||
logWithId.Errorf("%s", debug.Stack())
|
logWithId.Errorf("%s", debug.Stack())
|
||||||
|
|
||||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(
|
osbuildJobResult.JobError = clienterrors.New(
|
||||||
clienterrors.ErrorJobPanicked,
|
clienterrors.ErrorJobPanicked,
|
||||||
fmt.Sprintf("job panicked:\n%v\n\noriginal error:\n%v", r, osbuildJobResult.JobError),
|
fmt.Sprintf("job panicked:\n%v\n\noriginal error:\n%v", r, osbuildJobResult.JobError),
|
||||||
nil,
|
nil,
|
||||||
|
|
@ -430,7 +430,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
osbuildVersion, err := osbuild.OSBuildVersion()
|
osbuildVersion, err := osbuild.OSBuildVersion()
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
osbuildJobResult.OSBuildVersion = osbuildVersion
|
osbuildJobResult.OSBuildVersion = osbuildVersion
|
||||||
|
|
@ -459,13 +459,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
err = job.DynamicArgs(*jobArgs.ManifestDynArgsIdx, &manifestJR)
|
err = job.DynamicArgs(*jobArgs.ManifestDynArgsIdx, &manifestJR)
|
||||||
}
|
}
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip the job if the manifest generation failed
|
// skip the job if the manifest generation failed
|
||||||
if manifestJR.JobError != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
jobArgs.Manifest = manifestJR.Manifest
|
jobArgs.Manifest = manifestJR.Manifest
|
||||||
|
|
@ -473,7 +473,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(jobArgs.Manifest) == 0 {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -484,12 +484,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
var jobResult worker.JobResult
|
var jobResult worker.JobResult
|
||||||
err = job.DynamicArgs(idx, &jobResult)
|
err = job.DynamicArgs(idx, &jobResult)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if jobResult.JobError != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -503,7 +503,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
// get exports for all job's targets
|
// get exports for all job's targets
|
||||||
exports := jobArgs.OsbuildExports()
|
exports := jobArgs.OsbuildExports()
|
||||||
if len(exports) == 0 {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -533,18 +533,18 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
case "aws.ec2":
|
case "aws.ec2":
|
||||||
err = os.MkdirAll("/var/tmp/osbuild-composer", 0755)
|
err = os.MkdirAll("/var/tmp/osbuild-composer", 0755)
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
tmpDir, err := os.MkdirTemp("/var/tmp/osbuild-composer", "")
|
tmpDir, err := os.MkdirTemp("/var/tmp/osbuild-composer", "")
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
executor = osbuildexecutor.NewAWSEC2Executor(impl.OSBuildExecutor.IAMProfile, impl.OSBuildExecutor.KeyName, impl.OSBuildExecutor.CloudWatchGroup, job.Id().String(), tmpDir)
|
executor = osbuildexecutor.NewAWSEC2Executor(impl.OSBuildExecutor.IAMProfile, impl.OSBuildExecutor.KeyName, impl.OSBuildExecutor.CloudWatchGroup, job.Id().String(), tmpDir)
|
||||||
default:
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,7 +564,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
osbuildJobResult.OSBuildOutput, err = executor.RunOSBuild(jobArgs.Manifest, opts, os.Stderr)
|
osbuildJobResult.OSBuildOutput, err = executor.RunOSBuild(jobArgs.Manifest, opts, os.Stderr)
|
||||||
// First handle the case when "running" osbuild failed
|
// First handle the case when "running" osbuild failed
|
||||||
if err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -606,13 +606,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
imagePath := path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename)
|
imagePath := path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename)
|
||||||
f, err = os.Open(imagePath)
|
f, err = os.Open(imagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
err = job.UploadArtifact(jobTarget.ImageName, f)
|
err = job.UploadArtifact(jobTarget.ImageName, f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -630,7 +630,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
tempDirectory, err := os.MkdirTemp(impl.Output, job.Id().String()+"-vmware-*")
|
tempDirectory, err := os.MkdirTemp(impl.Output, job.Id().String()+"-vmware-*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -650,23 +650,23 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
err = os.Symlink(exportedImagePath, imagePath)
|
err = os.Symlink(exportedImagePath, imagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
err = vmware.ImportVmdk(credentials, imagePath)
|
err = vmware.ImportVmdk(credentials, imagePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if strings.HasSuffix(exportedImagePath, ".ova") {
|
} else if strings.HasSuffix(exportedImagePath, ".ova") {
|
||||||
err = vmware.ImportOva(credentials, exportedImagePath, jobTarget.ImageName)
|
err = vmware.ImportOva(credentials, exportedImagePath, jobTarget.ImageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -674,12 +674,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
targetResult = target.NewAWSTargetResult(nil, &artifact)
|
targetResult = target.NewAWSTargetResult(nil, &artifact)
|
||||||
a, err := impl.getAWS(targetOptions.Region, targetOptions.AccessKeyID, targetOptions.SecretAccessKey, targetOptions.SessionToken)
|
a, err := impl.getAWS(targetOptions.Region, targetOptions.AccessKeyID, targetOptions.SecretAccessKey, targetOptions.SessionToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetOptions.Key == "" {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -687,7 +687,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
if bucket == "" {
|
if bucket == "" {
|
||||||
bucket = impl.AWSBucket
|
bucket = impl.AWSBucket
|
||||||
if bucket == "" {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -701,25 +701,25 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
if strings.HasSuffix(imagePath, ".xz") {
|
if strings.HasSuffix(imagePath, ".xz") {
|
||||||
imagePath, err = extractXzArchive(imagePath)
|
imagePath, err = extractXzArchive(imagePath)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = a.Upload(imagePath, bucket, targetOptions.Key)
|
_, err = a.Upload(imagePath, bucket, targetOptions.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
ami, err := a.Register(jobTarget.ImageName, bucket, targetOptions.Key, targetOptions.ShareWithAccounts, arch.Current().String(), targetOptions.BootMode)
|
ami, err := a.Register(jobTarget.ImageName, bucket, targetOptions.Key, targetOptions.ShareWithAccounts, arch.Current().String(), targetOptions.BootMode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if ami == nil {
|
if ami == nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, "No ami returned", nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, "No ami returned", nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
targetResult.Options = &target.AWSTargetResultOptions{
|
targetResult.Options = &target.AWSTargetResultOptions{
|
||||||
|
|
@ -731,12 +731,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
targetResult = target.NewAWSS3TargetResult(nil, &artifact)
|
targetResult = target.NewAWSS3TargetResult(nil, &artifact)
|
||||||
a, bucket, err := impl.getAWSForS3Target(targetOptions)
|
a, bucket, err := impl.getAWSForS3Target(targetOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetOptions.Key == "" {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -751,7 +751,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
targetResult = target.NewAzureTargetResult(&artifact)
|
targetResult = target.NewAzureTargetResult(&artifact)
|
||||||
azureStorageClient, err := azure.NewStorageClient(targetOptions.StorageAccount, targetOptions.StorageAccessKey)
|
azureStorageClient, err := azure.NewStorageClient(targetOptions.StorageAccount, targetOptions.StorageAccessKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -771,7 +771,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -781,12 +781,12 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
g, err := impl.getGCP(targetOptions.Credentials)
|
g, err := impl.getGCP(targetOptions.Credentials)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetOptions.Object == "" {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -794,7 +794,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
if bucket == "" {
|
if bucket == "" {
|
||||||
bucket = impl.GCPConfig.Bucket
|
bucket = impl.GCPConfig.Bucket
|
||||||
if 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
|
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),
|
_, err = g.StorageObjectUpload(ctx, path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename),
|
||||||
bucket, targetOptions.Object, map[string]string{gcp.MetadataKeyImageName: jobTarget.ImageName})
|
bucket, targetOptions.Object, map[string]string{gcp.MetadataKeyImageName: jobTarget.ImageName})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -822,7 +822,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
// check error from ComputeImageInsert()
|
// check error from ComputeImageInsert()
|
||||||
if importErr != nil {
|
if importErr != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorImportingImage, importErr.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorImportingImage, importErr.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logWithId.Infof("[GCP] 💿 Image URL: %s", g.ComputeImageURL(jobTarget.ImageName))
|
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)
|
logWithId.Infof("[GCP] 🔗 Sharing the image with: %+v", targetOptions.ShareWithAccounts)
|
||||||
err = g.ComputeImageShare(ctx, jobTarget.ImageName, targetOptions.ShareWithAccounts)
|
err = g.ComputeImageShare(ctx, jobTarget.ImageName, targetOptions.ShareWithAccounts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorSharingTarget, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorSharingTarget, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -845,13 +845,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
if impl.AzureConfig.Creds == nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := azure.NewClient(*impl.AzureConfig.Creds, targetOptions.TenantID, targetOptions.SubscriptionID)
|
c, err := azure.NewClient(*impl.AzureConfig.Creds, targetOptions.TenantID, targetOptions.SubscriptionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidTargetConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Azure] 🔑 Logged in Azure")
|
logWithId.Info("[Azure] 🔑 Logged in Azure")
|
||||||
|
|
@ -860,7 +860,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
if location == "" {
|
if location == "" {
|
||||||
location, err = c.GetResourceGroupLocation(ctx, targetOptions.ResourceGroup)
|
location, err = c.GetResourceGroupLocation(ctx, targetOptions.ResourceGroup)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -876,7 +876,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
storageAccountTag,
|
storageAccountTag,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -893,7 +893,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
storageAccountTag,
|
storageAccountTag,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -905,13 +905,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
storageAccount,
|
storageAccount,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
azureStorageClient, err := azure.NewStorageClient(storageAccount, storageAccessKey)
|
azureStorageClient, err := azure.NewStorageClient(storageAccount, storageAccessKey)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -920,7 +920,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
logWithId.Info("[Azure] 📦 Ensuring that we have a storage container")
|
logWithId.Info("[Azure] 📦 Ensuring that we have a storage container")
|
||||||
err = azureStorageClient.CreateStorageContainerIfNotExist(ctx, storageAccount, storageContainer)
|
err = azureStorageClient.CreateStorageContainerIfNotExist(ctx, storageAccount, storageContainer)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -936,7 +936,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
if strings.HasSuffix(imagePath, ".xz") {
|
if strings.HasSuffix(imagePath, ".xz") {
|
||||||
imagePath, err = extractXzArchive(imagePath)
|
imagePath, err = extractXzArchive(imagePath)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -952,7 +952,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
impl.AzureConfig.UploadThreads,
|
impl.AzureConfig.UploadThreads,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -968,7 +968,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
location,
|
location,
|
||||||
)
|
)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Azure] 🎉 Image uploaded and registered!")
|
logWithId.Info("[Azure] 🎉 Image uploaded and registered!")
|
||||||
|
|
@ -980,13 +980,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
targetResult = target.NewKojiTargetResult(nil, &artifact)
|
targetResult = target.NewKojiTargetResult(nil, &artifact)
|
||||||
kojiServerURL, err := url.Parse(targetOptions.Server)
|
kojiServerURL, err := url.Parse(targetOptions.Server)
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
kojiServer, exists := impl.KojiServers[kojiServerURL.Hostname()]
|
kojiServer, exists := impl.KojiServers[kojiServerURL.Hostname()]
|
||||||
if !exists {
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -995,7 +995,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
kojiAPI, err := koji.NewFromGSSAPI(targetOptions.Server, &kojiServer.creds, kojiTransport)
|
kojiAPI, err := koji.NewFromGSSAPI(targetOptions.Server, &kojiServer.creds, kojiTransport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Warnf("[Koji] 🔑 login failed: %v", err) // DON'T EDIT: Used for Splunk dashboard
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Infof("[Koji] 🔑 Authenticated with %q", kojiServerURL.Hostname())
|
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))
|
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
||||||
if err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
defer file.Close()
|
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)
|
imageHash, imageSize, err := kojiAPI.Upload(file, targetOptions.UploadDirectory, jobTarget.ImageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Warnf("[Koji] ⬆ upload failed: %v", err) // DON'T EDIT: used for Splunk dashboard
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Koji] 🎉 Image successfully uploaded")
|
logWithId.Info("[Koji] 🎉 Image successfully uploaded")
|
||||||
|
|
@ -1026,7 +1026,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
err = json.Indent(&manifest, jobArgs.Manifest, "", " ")
|
err = json.Indent(&manifest, jobArgs.Manifest, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Warnf("[Koji] Indenting osbuild manifest failed: %v", err)
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Koji] ⬆ Uploading the osbuild manifest")
|
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)
|
manifestHash, manifestSize, err := kojiAPI.Upload(&manifest, targetOptions.UploadDirectory, manifestFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Warnf("[Koji] ⬆ upload failed: %v", err)
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Koji] 🎉 Manifest successfully uploaded")
|
logWithId.Info("[Koji] 🎉 Manifest successfully uploaded")
|
||||||
|
|
@ -1043,7 +1043,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
err = osbuildJobResult.OSBuildOutput.Write(&osbuildLog)
|
err = osbuildJobResult.OSBuildOutput.Write(&osbuildLog)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Warnf("[Koji] Converting osbuild log to text failed: %v", err)
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Koji] ⬆ Uploading the osbuild output log")
|
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)
|
osbuildOutputHash, osbuildOutputSize, err := kojiAPI.Upload(&osbuildLog, targetOptions.UploadDirectory, osbuildOutputFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Warnf("[Koji] ⬆ upload failed: %v", err)
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[Koji] 🎉 osbuild output log successfully uploaded")
|
logWithId.Info("[Koji] 🎉 osbuild output log successfully uploaded")
|
||||||
|
|
@ -1112,14 +1112,14 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
PrivateKey: targetOptions.PrivateKey,
|
PrivateKey: targetOptions.PrivateKey,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[OCI] 🔑 Logged in OCI")
|
logWithId.Info("[OCI] 🔑 Logged in OCI")
|
||||||
logWithId.Info("[OCI] ⬆ Uploading the image")
|
logWithId.Info("[OCI] ⬆ Uploading the image")
|
||||||
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
@ -1139,7 +1139,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
file,
|
file,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1155,7 +1155,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
jobTarget.ImageName,
|
jobTarget.ImageName,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1172,14 +1172,14 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
PrivateKey: targetOptions.PrivateKey,
|
PrivateKey: targetOptions.PrivateKey,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[OCI] 🔑 Logged in OCI")
|
logWithId.Info("[OCI] 🔑 Logged in OCI")
|
||||||
logWithId.Info("[OCI] ⬆ Uploading the image")
|
logWithId.Info("[OCI] ⬆ Uploading the image")
|
||||||
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
file, err := os.Open(path.Join(outputDirectory, jobTarget.OsbuildArtifact.ExportName, jobTarget.OsbuildArtifact.ExportFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
@ -1199,13 +1199,13 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
file,
|
file,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
uri, err := ociClient.PreAuthenticatedRequest(fmt.Sprintf("osbuild-upload-%d", i), bucket, namespace)
|
uri, err := ociClient.PreAuthenticatedRequest(fmt.Sprintf("osbuild-upload-%d", i), bucket, namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorGeneratingSignedURL, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorGeneratingSignedURL, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logWithId.Info("[OCI] 🎉 Image uploaded and pre-authenticated request generated!")
|
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)
|
client, err := impl.getContainerClient(destination, targetOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1233,7 +1233,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWithId.Infof("[container] 🙁 Upload of '%s' failed: %v", sourceRef, err)
|
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
|
break
|
||||||
}
|
}
|
||||||
logWithId.Printf("[container] 🎉 Image uploaded (%s)!", digest.String())
|
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)
|
client, err := impl.getPulpClient(targetOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorInvalidConfig, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
url, err := client.UploadAndDistributeCommit(archivePath, targetOptions.Repository, targetOptions.BasePath)
|
url, err := client.UploadAndDistributeCommit(archivePath, targetOptions.Repository, targetOptions.BasePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
targetResult.TargetError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
targetResult.TargetError = clienterrors.New(clienterrors.ErrorUploadingImage, err.Error(), nil)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
targetResult.Options = &target.PulpOSTreeTargetResultOptions{RepoURL: url}
|
targetResult.Options = &target.PulpOSTreeTargetResultOptions{RepoURL: url}
|
||||||
|
|
@ -1259,7 +1259,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
default:
|
default:
|
||||||
// TODO: we may not want to return completely here with multiple targets, because then no TargetErrors will be added to the JobError details
|
// 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.
|
// 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1272,7 +1272,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
||||||
|
|
||||||
targetErrors := osbuildJobResult.TargetErrors()
|
targetErrors := osbuildJobResult.TargetErrors()
|
||||||
if len(targetErrors) != 0 {
|
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 {
|
} else {
|
||||||
osbuildJobResult.Success = true
|
osbuildJobResult.Success = true
|
||||||
osbuildJobResult.UploadStatus = "success"
|
osbuildJobResult.UploadStatus = "success"
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,19 @@ type OSTreeResolveJobImpl struct {
|
||||||
func setError(err error, result *worker.OSTreeResolveJobResult) {
|
func setError(err error, result *worker.OSTreeResolveJobResult) {
|
||||||
switch err.(type) {
|
switch err.(type) {
|
||||||
case ostree.RefError:
|
case ostree.RefError:
|
||||||
result.JobError = clienterrors.WorkerClientError(
|
result.JobError = clienterrors.New(
|
||||||
clienterrors.ErrorOSTreeRefInvalid,
|
clienterrors.ErrorOSTreeRefInvalid,
|
||||||
"Invalid OSTree ref",
|
"Invalid OSTree ref",
|
||||||
err.Error(),
|
err.Error(),
|
||||||
)
|
)
|
||||||
case ostree.ResolveRefError:
|
case ostree.ResolveRefError:
|
||||||
result.JobError = clienterrors.WorkerClientError(
|
result.JobError = clienterrors.New(
|
||||||
clienterrors.ErrorOSTreeRefResolution,
|
clienterrors.ErrorOSTreeRefResolution,
|
||||||
"Error resolving OSTree ref",
|
"Error resolving OSTree ref",
|
||||||
err.Error(),
|
err.Error(),
|
||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
result.JobError = clienterrors.WorkerClientError(
|
result.JobError = clienterrors.New(
|
||||||
clienterrors.ErrorOSTreeParamsInvalid,
|
clienterrors.ErrorOSTreeParamsInvalid,
|
||||||
"Invalid OSTree parameters or parameter combination",
|
"Invalid OSTree parameters or parameter combination",
|
||||||
err.Error(),
|
err.Error(),
|
||||||
|
|
|
||||||
|
|
@ -496,7 +496,7 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
||||||
|
|
||||||
if len(dynArgs) == 0 {
|
if len(dynArgs) == 0 {
|
||||||
reason := "No dynamic arguments"
|
reason := "No dynamic arguments"
|
||||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorNoDynamicArgs, reason, nil)
|
jobResult.JobError = clienterrors.New(clienterrors.ErrorNoDynamicArgs, reason, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -504,28 +504,28 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
||||||
err = json.Unmarshal(dynArgs[0], &depsolveResults)
|
err = json.Unmarshal(dynArgs[0], &depsolveResults)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reason := "Error parsing dynamic arguments"
|
reason := "Error parsing dynamic arguments"
|
||||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorParsingDynamicArgs, reason, nil)
|
jobResult.JobError = clienterrors.New(clienterrors.ErrorParsingDynamicArgs, reason, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = workers.DepsolveJobInfo(depsolveJobID, &depsolveResults)
|
_, err = workers.DepsolveJobInfo(depsolveJobID, &depsolveResults)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reason := "Error reading depsolve status"
|
reason := "Error reading depsolve status"
|
||||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
jobResult.JobError = clienterrors.New(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if jobErr := depsolveResults.JobError; jobErr != nil {
|
if jobErr := depsolveResults.JobError; jobErr != nil {
|
||||||
if jobErr.ID == clienterrors.ErrorDNFDepsolveError || jobErr.ID == clienterrors.ErrorDNFMarkingErrors {
|
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
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(depsolveResults.PackageSpecs) == 0 {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -537,12 +537,12 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reason := "Error reading container resolve job status"
|
reason := "Error reading container resolve job status"
|
||||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
jobResult.JobError = clienterrors.New(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if jobErr := result.JobError; jobErr != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,12 +580,12 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reason := "Error reading ostree resolve job status"
|
reason := "Error reading ostree resolve job status"
|
||||||
logrus.Errorf("%s: %v", reason, err)
|
logrus.Errorf("%s: %v", reason, err)
|
||||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorReadingJobStatus, reason, nil)
|
jobResult.JobError = clienterrors.New(clienterrors.ErrorReadingJobStatus, reason, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if jobErr := result.JobError; jobErr != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -621,7 +621,7 @@ func serializeManifest(ctx context.Context, manifestSource *manifest.Manifest, w
|
||||||
ms, err := manifestSource.Serialize(depsolveResults.PackageSpecs, containerSpecs, ostreeCommitSpecs, depsolveResults.RepoConfigs)
|
ms, err := manifestSource.Serialize(depsolveResults.PackageSpecs, containerSpecs, ostreeCommitSpecs, depsolveResults.RepoConfigs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
reason := "Error serializing manifest"
|
reason := "Error serializing manifest"
|
||||||
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestGeneration, reason, nil)
|
jobResult.JobError = clienterrors.New(clienterrors.ErrorManifestGeneration, reason, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func TestKojiCompose(t *testing.T) {
|
||||||
{
|
{
|
||||||
initResult: worker.KojiInitJobResult{
|
initResult: worker.KojiInitJobResult{
|
||||||
JobResult: worker.JobResult{
|
JobResult: worker.JobResult{
|
||||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiInit, "Koji init error", nil),
|
JobError: clienterrors.New(clienterrors.ErrorKojiInit, "Koji init error", nil),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
buildResult: worker.OSBuildJobResult{
|
buildResult: worker.OSBuildJobResult{
|
||||||
|
|
@ -240,7 +240,7 @@ func TestKojiCompose(t *testing.T) {
|
||||||
Success: true,
|
Success: true,
|
||||||
},
|
},
|
||||||
JobResult: worker.JobResult{
|
JobResult: worker.JobResult{
|
||||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "Koji build error", nil),
|
JobError: clienterrors.New(clienterrors.ErrorBuildJob, "Koji build error", nil),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
composeReplyCode: http.StatusCreated,
|
composeReplyCode: http.StatusCreated,
|
||||||
|
|
@ -346,7 +346,7 @@ func TestKojiCompose(t *testing.T) {
|
||||||
},
|
},
|
||||||
finalizeResult: worker.KojiFinalizeJobResult{
|
finalizeResult: worker.KojiFinalizeJobResult{
|
||||||
JobResult: worker.JobResult{
|
JobResult: worker.JobResult{
|
||||||
JobError: clienterrors.WorkerClientError(clienterrors.ErrorKojiFinalize, "Koji finalize error", nil),
|
JobError: clienterrors.New(clienterrors.ErrorKojiFinalize, "Koji finalize error", nil),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
composeReplyCode: http.StatusCreated,
|
composeReplyCode: http.StatusCreated,
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
|
||||||
}
|
}
|
||||||
|
|
||||||
if failDepsolve {
|
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)
|
rawMsg, err := json.Marshal(dJR)
|
||||||
|
|
@ -112,7 +112,7 @@ func newV2Server(t *testing.T, dir string, depsolveChannels []string, enableJWT
|
||||||
}
|
}
|
||||||
|
|
||||||
if failDepsolve {
|
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)
|
rawMsg, err := json.Marshal(oJR)
|
||||||
|
|
@ -800,7 +800,7 @@ func TestComposeJobError(t *testing.T) {
|
||||||
}`, jobId, jobId))
|
}`, jobId, jobId))
|
||||||
|
|
||||||
jobErr := worker.JobResult{
|
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})
|
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -865,7 +865,7 @@ func TestComposeDependencyError(t *testing.T) {
|
||||||
}`, jobId, jobId))
|
}`, jobId, jobId))
|
||||||
|
|
||||||
jobErr := worker.JobResult{
|
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})
|
jobResult, err := json.Marshal(worker.OSBuildJobResult{JobResult: jobErr})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
@ -942,12 +942,12 @@ func TestComposeTargetErrors(t *testing.T) {
|
||||||
{
|
{
|
||||||
Name: "org.osbuild.aws",
|
Name: "org.osbuild.aws",
|
||||||
Options: target.AWSTargetResultOptions{Ami: "", Region: ""},
|
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{
|
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
|
oJR.JobResult = jobErr
|
||||||
jobResult, err := json.Marshal(oJR)
|
jobResult, err := json.Marshal(oJR)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func (r *Resolver) Finish() []Spec {
|
||||||
|
|
||||||
var resultError *clienterrors.Error
|
var resultError *clienterrors.Error
|
||||||
if result.err != nil {
|
if result.err != nil {
|
||||||
resultError = clienterrors.WorkerClientError(
|
resultError = clienterrors.New(
|
||||||
clienterrors.ErrorRemoteFileResolution,
|
clienterrors.ErrorRemoteFileResolution,
|
||||||
result.err.Error(),
|
result.err.Error(),
|
||||||
result.url,
|
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"}}`),
|
resultJSON: []byte(`{"name":"org.osbuild.aws","target_error":{"id":11,"reason":"failed to uplad image","details":"detail"}}`),
|
||||||
expectedResult: &TargetResult{
|
expectedResult: &TargetResult{
|
||||||
Name: TargetNameAWS,
|
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
|
// unknown target name
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ func TestComposeStatusFromJobError(t *testing.T) {
|
||||||
require.Equal(t, jobId, j)
|
require.Equal(t, jobId, j)
|
||||||
|
|
||||||
jobResult := worker.OSBuildJobResult{}
|
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)
|
rawResult, err := json.Marshal(jobResult)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = api.workers.FinishJob(token, rawResult)
|
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{
|
return &Error{
|
||||||
ID: code,
|
ID: code,
|
||||||
Reason: reason,
|
Reason: reason,
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ func (j *OSBuildJobResult) TargetErrors() []*clienterrors.Error {
|
||||||
// Add the target name to the error details, because the error reason
|
// Add the target name to the error details, because the error reason
|
||||||
// may not contain any information to determine the type of the target
|
// may not contain any information to determine the type of the target
|
||||||
// which failed.
|
// 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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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{
|
targetErrors: []*clienterrors.Error{
|
||||||
clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
clienterrors.New(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
||||||
clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "can't upload image to VMWare", target.TargetNameVMWare),
|
clienterrors.New(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.ErrorUploadingImage, "failed to upload image to AWS S3", target.TargetNameAWSS3),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -44,20 +44,20 @@ func TestOSBuildJobResultTargetErrors(t *testing.T) {
|
||||||
TargetResults: []*target.TargetResult{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.TargetNameVMWare,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWSS3,
|
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{
|
targetErrors: []*clienterrors.Error{
|
||||||
clienterrors.WorkerClientError(clienterrors.ErrorInvalidTargetConfig, "can't login to AWS", target.TargetNameAWS),
|
clienterrors.New(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.ErrorUploadingImage, "failed to upload image to AWS S3", target.TargetNameAWSS3),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -99,19 +99,19 @@ func TestOSBuildJobResultTargetResultsByName(t *testing.T) {
|
||||||
TargetResults: []*target.TargetResult{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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{
|
targetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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{
|
targetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameVMWare,
|
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,
|
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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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{
|
targetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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,
|
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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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{
|
targetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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{
|
targetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameVMWare,
|
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,
|
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{
|
TargetResults: []*target.TargetResult{
|
||||||
{
|
{
|
||||||
Name: target.TargetNameAWS,
|
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.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,
|
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,
|
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)
|
logrus.Infof("Removing unresponsive job: %s\n", id)
|
||||||
|
|
||||||
missingHeartbeatResult := JobResult{
|
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),
|
fmt.Sprintf("Workers running this job stopped responding more than %d times.", maxHeartbeatRetries),
|
||||||
nil),
|
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.JobError == nil && !jobInfo.JobStatus.Finished.IsZero() {
|
||||||
if result.OSBuildOutput == nil {
|
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 {
|
} 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 {
|
} 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
|
// 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 != "" {
|
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
|
return jobInfo, nil
|
||||||
|
|
@ -382,7 +382,7 @@ func (s *Server) KojiFinalizeJobInfo(id uuid.UUID, result *KojiFinalizeJobResult
|
||||||
}
|
}
|
||||||
|
|
||||||
if result.JobError == nil && result.KojiError != "" {
|
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
|
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.JobError == nil && result.Error != "" {
|
||||||
if result.ErrorType == DepsolveErrorType {
|
if result.ErrorType == DepsolveErrorType {
|
||||||
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorDNFDepsolveError, result.Error, nil)
|
result.JobError = clienterrors.New(clienterrors.ErrorDNFDepsolveError, result.Error, nil)
|
||||||
} else {
|
} 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,
|
Error: reason,
|
||||||
ErrorType: errType,
|
ErrorType: errType,
|
||||||
JobResult: worker.JobResult{
|
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