worker: Add worker server support for Search job
This adds support for sending a search job to the worker client, gathering results, and handling errors. The errors returned are the same as for the Depsolve job, since they both use the osbuild-depsolve-dnf script via images/pkg/dnfjson. Related: RHEL-60136
This commit is contained in:
parent
d8df7e7cd4
commit
bd55670dd9
1 changed files with 35 additions and 0 deletions
|
|
@ -203,6 +203,10 @@ func (s *Server) EnqueueDepsolve(job *DepsolveJob, channel string) (uuid.UUID, e
|
|||
return s.enqueue(JobTypeDepsolve, job, nil, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueSearchPackages(job *SearchPackagesJob, channel string) (uuid.UUID, error) {
|
||||
return s.enqueue(JobTypeSearchPackages, job, nil, channel)
|
||||
}
|
||||
|
||||
func (s *Server) EnqueueManifestJobByID(job *ManifestJobByID, dependencies []uuid.UUID, channel string) (uuid.UUID, error) {
|
||||
if len(dependencies) == 0 {
|
||||
panic("EnqueueManifestJobByID has no dependencies, expected at least a depsolve job")
|
||||
|
|
@ -262,6 +266,14 @@ func (s *Server) JobDependencyChainErrors(id uuid.UUID) (*clienterrors.Error, er
|
|||
}
|
||||
jobResult = &depsolveJR.JobResult
|
||||
|
||||
case JobTypeSearchPackages:
|
||||
var searchJR SearchPackagesJobResult
|
||||
jobInfo, err = s.SearchPackagesJobInfo(id, &searchJR)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
jobResult = &searchJR.JobResult
|
||||
|
||||
case JobTypeManifestIDOnly:
|
||||
var manifestJR ManifestJobByIDResult
|
||||
jobInfo, err = s.ManifestJobInfo(id, &manifestJR)
|
||||
|
|
@ -419,6 +431,21 @@ func (s *Server) DepsolveJobInfo(id uuid.UUID, result *DepsolveJobResult) (*JobI
|
|||
return jobInfo, nil
|
||||
}
|
||||
|
||||
// SearchPackagesJobInfo returns JobInfo for a Search job
|
||||
// and populates the result with the SearchJobResult data
|
||||
func (s *Server) SearchPackagesJobInfo(id uuid.UUID, result *SearchPackagesJobResult) (*JobInfo, error) {
|
||||
jobInfo, err := s.jobInfo(id, result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if jobInfo.JobType != JobTypeSearchPackages {
|
||||
return nil, fmt.Errorf("expected %q, found %q job instead", JobTypeSearchPackages, jobInfo.JobType)
|
||||
}
|
||||
|
||||
return jobInfo, nil
|
||||
}
|
||||
|
||||
func (s *Server) ManifestJobInfo(id uuid.UUID, result *ManifestJobByIDResult) (*JobInfo, error) {
|
||||
jobInfo, err := s.jobInfo(id, result)
|
||||
if err != nil {
|
||||
|
|
@ -797,6 +824,14 @@ func (s *Server) RequeueOrFinishJob(token uuid.UUID, maxRetries uint64, result j
|
|||
}
|
||||
jobResult = &depsolveJR.JobResult
|
||||
|
||||
case JobTypeSearchPackages:
|
||||
var searchJR SearchPackagesJobResult
|
||||
jobInfo, err = s.SearchPackagesJobInfo(jobId, &searchJR)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jobResult = &searchJR.JobResult
|
||||
|
||||
case JobTypeManifestIDOnly:
|
||||
var manifestJR ManifestJobByIDResult
|
||||
jobInfo, err = s.ManifestJobInfo(jobId, &manifestJR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue