jobrunner

package
v2.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultJobWatcherTimeout = 30 * time.Minute
)

Variables

View Source
var BuildKitImage = "972525491246.dkr.ecr.us-east-1.amazonaws.com/furan-builder:v0.11.6-rootless"
View Source
var JobLabel = "created-by:furan-v2"

JobLabel is a label added to every build job to aid search/aggregation

View Source
var (
	PodMaxLines = int64(1000)
)

Functions

func FuranJobFunc

func FuranJobFunc(info ImageInfo, build *models.Build, bkresources [2]corev1.ResourceList) *batchv1.Job

FuranJobFunc is a JobFactoryFunc that generates a Kubernetes Job to execute a build

Types

type FakeJob

type FakeJob struct {
	ErrorChan   chan error
	RunningChan chan struct{}
	LogContent  map[string]map[string][]byte
}

func NewFakeJob

func NewFakeJob(logs map[string]map[string][]byte) *FakeJob

func (*FakeJob) Close

func (fj *FakeJob) Close()

func (*FakeJob) Error

func (fj *FakeJob) Error() chan error

func (*FakeJob) Logs

func (fj *FakeJob) Logs() (map[string]map[string][]byte, error)

func (*FakeJob) Running

func (fj *FakeJob) Running() chan struct{}

type FakeJobRunner

type FakeJobRunner struct {
	RunFunc func(build *models.Build) (models.Job, error)
}

func (*FakeJobRunner) Run

func (fj *FakeJobRunner) Run(build *models.Build) (models.Job, error)

type ImageInfo

type ImageInfo struct {
	Namespace, PodName, Image, ServiceAccount string
	ImagePullSecrets                          []string
	RootArgs                                  []string // All args prior to the "server" command (secrets setup, etc)
	Resources                                 [2]corev1.ResourceList
	EnvVars                                   []corev1.EnvVar // any env vars that reference k8s secrets
}

ImageInfo models information about /this/ currently running Furan pod/container These are the values that are injected into build jobs

type JobFactoryFunc

type JobFactoryFunc func(info ImageInfo, build *models.Build, bkresources [2]corev1.ResourceList) *batchv1.Job

JobFactoryFunc is a function that generates a new image build Job given an ImageInfo and an optional set of buildkit resource requests and limits

type JobWatcher

type JobWatcher struct {
	JobName, JobNamespace string
	// contains filtered or unexported fields
}

JobWatcher is an object that keeps track of a newly-created k8s Job and signals when it succeeds or fails

func (*JobWatcher) Error

func (jw *JobWatcher) Error() chan error

func (*JobWatcher) Logs

func (jw *JobWatcher) Logs() (map[string]map[string][]byte, error)

Logs fetches the logs for pods associated with this job and returns a map of pod name to a map of container name to the last PodMaxLines of log output for that container. Ex: logByteSlice := output["pod-name-xyz111"]["app-container"]

func (*JobWatcher) Running

func (jw *JobWatcher) Running() chan struct{}

type K8sJobRunner

type K8sJobRunner struct {
	JobFunc JobFactoryFunc
	LogFunc func(msg string, args ...interface{})
	// contains filtered or unexported fields
}

func NewInClusterRunner

func NewInClusterRunner(dl datalayer.DataLayer) (*K8sJobRunner, error)

func (K8sJobRunner) Run

func (kr K8sJobRunner) Run(build *models.Build) (models.Job, error)

Run starts a new Furan build job and returns immediately

func (K8sJobRunner) StartCleanup

func (kr K8sJobRunner) StartCleanup(ctx context.Context, interval, age time.Duration, label string) error

StartCleanup begins an asynchronous cleanup process every interval that deletes old build jobs older than now - age. Build jobs are identified in the current namespace by label, which is expected to be in the form "<key>:<value>". Cancel the context to signal the process to exit.

Jump to

Keyboard shortcuts

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