worker

package
v0.0.0-...-1c35d90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobTypeOSBuild          string = "osbuild"
	JobTypeKojiInit         string = "koji-init"
	JobTypeKojiFinalize     string = "koji-finalize"
	JobTypeDepsolve         string = "depsolve"
	JobTypeManifestIDOnly   string = "manifest-id-only"
	JobTypeContainerResolve string = "container-resolve"
	JobTypeFileResolve      string = "file-resolve"
	JobTypeOSTreeResolve    string = "ostree-resolve"
	JobTypeAWSEC2Copy       string = "aws-ec2-copy"
	JobTypeAWSEC2Share      string = "aws-ec2-share"
)

Variables

View Source
var ErrClientRequestJobTimeout = errors.New("Dequeue timed out, retry")
View Source
var ErrInvalidJobType = errors.New("job has invalid type")
View Source
var ErrInvalidToken = errors.New("token does not exist")
View Source
var ErrJobNotRunning = errors.New("job isn't running")

Functions

This section is empty.

Types

type AWSEC2CopyJob

type AWSEC2CopyJob struct {
	Ami          string `json:"ami"`
	SourceRegion string `json:"source_region"`
	TargetRegion string `json:"target_region"`
	TargetName   string `json:"target_name"`
}

type AWSEC2CopyJobResult

type AWSEC2CopyJobResult struct {
	JobResult

	Ami    string `json:"ami"`
	Region string `json:"region"`
}

type AWSEC2ShareJob

type AWSEC2ShareJob struct {
	Ami               string   `json:"ami"`
	Region            string   `json:"region"`
	ShareWithAccounts []string `json:"shareWithAccounts"`
}

type AWSEC2ShareJobResult

type AWSEC2ShareJobResult struct {
	JobResult

	Ami    string `json:"ami"`
	Region string `json:"region"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conf ClientConfig) (*Client, error)

func NewClientUnix

func NewClientUnix(conf ClientConfig) *Client

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, headers map[string]string, body io.ReadSeeker) (*http.Response, error)

func (*Client) RequestJob

func (c *Client) RequestJob(types []string, arch string) (Job, error)

type ClientConfig

type ClientConfig struct {
	BaseURL      string
	TlsConfig    *tls.Config
	OfflineToken string
	OAuthURL     string
	ClientId     string
	ClientSecret string
	BasePath     string
	ProxyURL     string
}

type Config

type Config struct {
	ArtifactsDir         string
	RequestJobTimeout    time.Duration
	BasePath             string
	JWTEnabled           bool
	TenantProviderFields []string
	JobTimeout           time.Duration
	JobWatchFreq         time.Duration
	WorkerTimeout        time.Duration
	WorkerWatchFreq      time.Duration
}

type ContainerResolveJob

type ContainerResolveJob struct {
	Arch  string          `json:"arch"`
	Specs []ContainerSpec `json:"specs"`
}

type ContainerResolveJobResult

type ContainerResolveJobResult struct {
	Specs []ContainerSpec `json:"specs"`

	JobResult
}

type ContainerSpec

type ContainerSpec struct {
	Source    string `json:"source"`
	Name      string `json:"name"`
	TLSVerify *bool  `json:"tls-verify,omitempty"`

	ImageID    string `json:"image_id"`
	Digest     string `json:"digest"`
	ListDigest string `json:"list-digest,omitempty"`
}

type DepsolveJob

type DepsolveJob struct {
	PackageSets      map[string][]rpmmd.PackageSet `json:"grouped_package_sets"`
	ModulePlatformID string                        `json:"module_platform_id"`
	Arch             string                        `json:"arch"`
	Releasever       string                        `json:"releasever"`

	// NB: for now, the worker supports only a single SBOM type, but keep the options
	// open for the future by passing the actual type and not just bool.
	SbomType sbom.StandardType `json:"sbom_type,omitempty"`
}

DepsolveJob defines the parameters of one or more depsolve jobs. Each named list of package sets defines a separate job. Lists with multiple package sets are depsolved in a chain, combining the results of sequential depsolves into a single PackageSpec list in the result. Each PackageSet defines the repositories it will be depsolved against.

type DepsolveJobResult

type DepsolveJobResult struct {
	PackageSpecs map[string][]rpmmd.PackageSpec `json:"package_specs"`
	SbomDocs     map[string]SbomDoc             `json:"sbom_docs,omitempty"`
	RepoConfigs  map[string][]rpmmd.RepoConfig  `json:"repo_configs"`
	Error        string                         `json:"error"`
	ErrorType    ErrorType                      `json:"error_type"`
	JobResult
}

type ErrorType

type ErrorType string
const (
	DepsolveErrorType ErrorType = "depsolve"
	OtherErrorType    ErrorType = "other"
)

type FileResolveJob

type FileResolveJob struct {
	URLs []string `json:"urls"`
}

type FileResolveJobResult

type FileResolveJobResult struct {
	Success bool                       `json:"success"`
	Results []FileResolveJobResultItem `json:"results"`
	JobResult
}

func (*FileResolveJobResult) ResolutionErrors

func (j *FileResolveJobResult) ResolutionErrors() []*clienterrors.Error

type FileResolveJobResultItem

type FileResolveJobResultItem struct {
	URL             string              `json:"url"`
	Content         []byte              `json:"content"`
	ResolutionError *clienterrors.Error `json:"target_error,omitempty"`
}

type Job

type Job interface {
	Id() uuid.UUID
	Type() string
	Args(args interface{}) error
	DynamicArgs(i int, args interface{}) error
	NDynamicArgs() int
	Update(result interface{}) error
	Canceled() (bool, error)
	UploadArtifact(name string, readSeeker io.ReadSeeker) error
}

type JobInfo

type JobInfo struct {
	JobType    string
	Channel    string
	JobStatus  *JobStatus
	Deps       []uuid.UUID
	Dependents []uuid.UUID
}

type JobResult

type JobResult struct {
	JobError *clienterrors.Error `json:"job_error,omitempty"`
}

type JobStatus

type JobStatus struct {
	Queued   time.Time
	Started  time.Time
	Finished time.Time
	Canceled bool
}

type KojiFinalizeJob

type KojiFinalizeJob struct {
	Server  string `json:"server"`
	Name    string `json:"name"`
	Version string `json:"version"`
	Release string `json:"release"`
	// TODO: eventually deprecate and remove KojiFilenames, since the image filenames are now set in the KojiTargetResultOptions.
	KojiFilenames []string `json:"koji_filenames"`
	KojiDirectory string   `json:"koji_directory"`
	TaskID        uint64   `json:"task_id"` /* https://pagure.io/koji/issue/215 */
	StartTime     uint64   `json:"start_time"`
}

type KojiFinalizeJobResult

type KojiFinalizeJobResult struct {
	KojiError string `json:"koji_error"`
	JobResult
}

type KojiInitJob

type KojiInitJob struct {
	Server  string `json:"server"`
	Name    string `json:"name"`
	Version string `json:"version"`
	Release string `json:"release"`
}

type KojiInitJobResult

type KojiInitJobResult struct {
	BuildID   uint64 `json:"build_id"`
	Token     string `json:"token"`
	KojiError string `json:"koji_error"`
	JobResult
}

type ManifestInfo

type ManifestInfo struct {
	OSBuildComposerVersion string `json:"osbuild_composer_version"`
	// List of relevant modules used by osbuild-composer which
	// could affect the manifest content.
	OSBuildComposerDeps []*OSBuildComposerDepModule `json:"osbuild_composer_deps,omitempty"`
}

ManifestInfo contains information about the environment in which the manifest was produced and which could affect its content.

type ManifestJobByID

type ManifestJobByID struct{}

type ManifestJobByIDResult

type ManifestJobByIDResult struct {
	Manifest     manifest.OSBuildManifest `json:"data,omitempty"`
	ManifestInfo ManifestInfo             `json:"info,omitempty"`
	Error        string                   `json:"error"`
	JobResult
}

type OSBuildComposerDepModule

type OSBuildComposerDepModule struct {
	Path    string                    `json:"path"`
	Version string                    `json:"version"`
	Replace *OSBuildComposerDepModule `json:"replace,omitempty"`
}

OSBuildComposerDepModule contains information about a module used by osbuild-composer which could affect the manifest content.

func ComposerDepModuleFromDebugModule

func ComposerDepModuleFromDebugModule(module *debug.Module) *OSBuildComposerDepModule

ComposerDepModuleFromDebugModule converts a debug.Module instance to an OSBuildComposerDepModule instance.

type OSBuildJob

type OSBuildJob struct {
	Manifest manifest.OSBuildManifest `json:"manifest,omitempty"`

	// Index of the ManifestJobByIDResult instance in the job's dynamic arguments slice
	ManifestDynArgsIdx *int `json:"manifest_dyn_args_idx,omitempty"`

	// Index of the DepsolveJobResult instance in the job's dynamic arguments slice
	// This is used only for Koji composes, which need to have access to SBOMs produced
	// as part of the depsolve job, so that they can be uploaded to Koji.
	DepsolveDynArgsIdx *int `json:"depsolve_dyn_args_idx,omitempty"`

	Targets       []*target.Target `json:"targets,omitempty"`
	PipelineNames *PipelineNames   `json:"pipeline_names,omitempty"`

	// The ImageBootMode is just copied to the result by the worker, so that
	// the value can be accessed job which depend on it.
	// (string representation of distro.BootMode values)
	ImageBootMode string `json:"image_boot_mode,omitempty"`
}

func (OSBuildJob) MarshalJSON

func (j OSBuildJob) MarshalJSON() ([]byte, error)

func (OSBuildJob) OsbuildExports

func (j OSBuildJob) OsbuildExports() []string

OsbuildExports returns a slice of osbuild pipeline names, which should be exported as part of running osbuild image build for the job. The pipeline names are gathered from the targets specified in the job.

func (*OSBuildJob) UnmarshalJSON

func (j *OSBuildJob) UnmarshalJSON(data []byte) error

type OSBuildJobResult

type OSBuildJobResult struct {
	Success       bool                   `json:"success"`
	OSBuildOutput *osbuild.Result        `json:"osbuild_output,omitempty"`
	TargetResults []*target.TargetResult `json:"target_results,omitempty"`
	UploadStatus  string                 `json:"upload_status"`
	PipelineNames *PipelineNames         `json:"pipeline_names,omitempty"`
	// Host OS of the worker which handled the job
	HostOS string `json:"host_os"`
	// Architecture of the worker which handled the job
	Arch string `json:"arch"`
	// Boot mode supported by the image
	// (string representation of distro.BootMode values)
	ImageBootMode string `json:"image_boot_mode,omitempty"`
	// Version of the osbuild binary used by the worker to build the image
	OSBuildVersion string `json:"osbuild_version,omitempty"`
	JobResult
}

func (*OSBuildJobResult) TargetErrors

func (j *OSBuildJobResult) TargetErrors() []*clienterrors.Error

TargetErrors returns a slice of *clienterrors.Error gathered from the job result's target results. If there were no target errors then the returned slice will be empty.

func (*OSBuildJobResult) TargetResultsByName

func (j *OSBuildJobResult) TargetResultsByName(name target.TargetName) []*target.TargetResult

TargetResultsByName iterates over TargetResults attached to the Job result and returns a slice of Target results of the provided name (type). If there were no TargetResults of the desired type attached to the Job results, the returned slice will be empty.

func (*OSBuildJobResult) TargetResultsFilterByName

func (j *OSBuildJobResult) TargetResultsFilterByName(excludeNames []target.TargetName) []*target.TargetResult

TargetResultsFilterByName iterates over TargetResults attached to the Job result and returns a slice of Target results excluding the provided names (types). If there were no TargetResults left after filtering, the returned slice will be empty.

func (*OSBuildJobResult) UnmarshalJSON

func (j *OSBuildJobResult) UnmarshalJSON(data []byte) error

type OSTreeResolveJob

type OSTreeResolveJob struct {
	Specs []OSTreeResolveSpec `json:"ostree_resolve_specs"`
}

type OSTreeResolveJobResult

type OSTreeResolveJobResult struct {
	Specs []OSTreeResolveResultSpec `json:"ostree_resolve_result_specs"`

	JobResult
}

type OSTreeResolveResultSpec

type OSTreeResolveResultSpec struct {
	URL      string `json:"url"`
	Ref      string `json:"ref"`
	Checksum string `json:"checksum"`
	RHSM     bool   `json:"bool"` // NOTE: kept for backwards compatibility; remove after a few releases
	Secrets  string `json:"secrets"`
}

type OSTreeResolveSpec

type OSTreeResolveSpec struct {
	URL  string `json:"url"`
	Ref  string `json:"ref"`
	RHSM bool   `json:"rhsm"`
}

type PipelineNames

type PipelineNames struct {
	Build   []string `json:"build"`
	Payload []string `json:"payload"`
}

PipelineNames is used to provide two pieces of information related to a job: 1. A categorization of each pipeline into one of two groups 2. A pipeline ordering when the lists are concatenated: build -> os

func (*PipelineNames) All

func (pn *PipelineNames) All() []string

Returns a concatenated list of the pipeline names

type SbomDoc

type SbomDoc struct {
	DocType  sbom.StandardType `json:"type"`
	Document json.RawMessage   `json:"document"`
}

SbomDoc represents a single SBOM document result.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(logger *log.Logger, jobs jobqueue.JobQueue, config Config) *Server

func (*Server) AWSEC2CopyJobInfo

func (s *Server) AWSEC2CopyJobInfo(id uuid.UUID, result *AWSEC2CopyJobResult) (*JobInfo, error)

func (*Server) AWSEC2ShareJobInfo

func (s *Server) AWSEC2ShareJobInfo(id uuid.UUID, result *AWSEC2ShareJobResult) (*JobInfo, error)

func (*Server) Cancel

func (s *Server) Cancel(id uuid.UUID) error

func (*Server) ContainerResolveJobInfo

func (s *Server) ContainerResolveJobInfo(id uuid.UUID, result *ContainerResolveJobResult) (*JobInfo, error)

func (*Server) DeleteArtifacts

func (s *Server) DeleteArtifacts(id uuid.UUID) error

Deletes all artifacts for job `id`.

func (*Server) DepsolveJobInfo

func (s *Server) DepsolveJobInfo(id uuid.UUID, result *DepsolveJobResult) (*JobInfo, error)

func (*Server) EnqueueAWSEC2CopyJob

func (s *Server) EnqueueAWSEC2CopyJob(job *AWSEC2CopyJob, parent uuid.UUID, channel string) (uuid.UUID, error)

func (*Server) EnqueueAWSEC2ShareJob

func (s *Server) EnqueueAWSEC2ShareJob(job *AWSEC2ShareJob, parent uuid.UUID, channel string) (uuid.UUID, error)

func (*Server) EnqueueContainerResolveJob

func (s *Server) EnqueueContainerResolveJob(job *ContainerResolveJob, channel string) (uuid.UUID, error)

func (*Server) EnqueueDepsolve

func (s *Server) EnqueueDepsolve(job *DepsolveJob, channel string) (uuid.UUID, error)

func (*Server) EnqueueFileResolveJob

func (s *Server) EnqueueFileResolveJob(job *FileResolveJob, channel string) (uuid.UUID, error)

func (*Server) EnqueueKojiFinalize

func (s *Server) EnqueueKojiFinalize(job *KojiFinalizeJob, initID uuid.UUID, buildIDs []uuid.UUID, channel string) (uuid.UUID, error)

func (*Server) EnqueueKojiInit

func (s *Server) EnqueueKojiInit(job *KojiInitJob, channel string) (uuid.UUID, error)

func (*Server) EnqueueManifestJobByID

func (s *Server) EnqueueManifestJobByID(job *ManifestJobByID, dependencies []uuid.UUID, channel string) (uuid.UUID, error)

func (*Server) EnqueueOSBuild

func (s *Server) EnqueueOSBuild(arch string, job *OSBuildJob, channel string) (uuid.UUID, error)

func (*Server) EnqueueOSBuildAsDependency

func (s *Server) EnqueueOSBuildAsDependency(arch string, job *OSBuildJob, dependencies []uuid.UUID, channel string) (uuid.UUID, error)

func (*Server) EnqueueOSTreeResolveJob

func (s *Server) EnqueueOSTreeResolveJob(job *OSTreeResolveJob, channel string) (uuid.UUID, error)

func (*Server) FileResolveJobInfo

func (s *Server) FileResolveJobInfo(id uuid.UUID, result *FileResolveJobResult) (*JobInfo, error)

func (*Server) FinishJob

func (s *Server) FinishJob(token uuid.UUID, result json.RawMessage) error

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) JobArtifact

func (s *Server) JobArtifact(id uuid.UUID, name string) (io.Reader, int64, error)

Provides access to artifacts of a job. Returns an io.Reader for the artifact and the artifact's size.

func (*Server) JobChannel

func (s *Server) JobChannel(id uuid.UUID) (string, error)

func (*Server) JobDependencyChainErrors

func (s *Server) JobDependencyChainErrors(id uuid.UUID) (*clienterrors.Error, error)

DependencyChainErrors recursively gathers all errors from job's dependencies, which caused it to fail. If the job didn't fail, `nil` is returned.

func (*Server) JobType

func (s *Server) JobType(id uuid.UUID) (string, error)

JobType returns the type of the job

func (*Server) KojiFinalizeJobInfo

func (s *Server) KojiFinalizeJobInfo(id uuid.UUID, result *KojiFinalizeJobResult) (*JobInfo, error)

func (*Server) KojiInitJobInfo

func (s *Server) KojiInitJobInfo(id uuid.UUID, result *KojiInitJobResult) (*JobInfo, error)

func (*Server) ManifestJobInfo

func (s *Server) ManifestJobInfo(id uuid.UUID, result *ManifestJobByIDResult) (*JobInfo, error)

func (*Server) OSBuildJob

func (s *Server) OSBuildJob(id uuid.UUID, job *OSBuildJob) error

OSBuildJob returns the parameters of an OSBuildJob

func (*Server) OSBuildJobInfo

func (s *Server) OSBuildJobInfo(id uuid.UUID, result *OSBuildJobResult) (*JobInfo, error)

func (*Server) OSTreeResolveJobInfo

func (s *Server) OSTreeResolveJobInfo(id uuid.UUID, result *OSTreeResolveJobResult) (*JobInfo, error)

func (*Server) RegisterWorker

func (s *Server) RegisterWorker(c, a string) (uuid.UUID, error)

func (*Server) RequestJob

func (s *Server) RequestJob(ctx context.Context, arch string, jobTypes, channels []string, workerID uuid.UUID) (uuid.UUID, uuid.UUID, string, json.RawMessage, []json.RawMessage, error)

func (*Server) RequestJobById

func (s *Server) RequestJobById(ctx context.Context, arch string, requestedJobId uuid.UUID) (uuid.UUID, uuid.UUID, string, json.RawMessage, []json.RawMessage, error)

func (*Server) RequeueOrFinishJob

func (s *Server) RequeueOrFinishJob(token uuid.UUID, maxRetries uint64, result json.RawMessage) error

func (*Server) SetFailed

func (s *Server) SetFailed(id uuid.UUID, error *clienterrors.Error) error

SetFailed sets the given job id to "failed" with the given error

func (*Server) WatchHeartbeats

func (s *Server) WatchHeartbeats()

With default durations it goes through all running jobs every 30 seconds and fails any unresponsive ones. Unresponsive jobs haven't checked whether or not they're cancelled in the past 2 minutes.

func (*Server) WatchWorkers

func (s *Server) WatchWorkers()

This function should be started as a goroutine Every 5 minutes it goes through all workers, removing any unresponsive ones.

func (*Server) WorkerAvailableForArch

func (s *Server) WorkerAvailableForArch(a string) (bool, error)

Directories

Path Synopsis
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL