jobframework

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{}

Functions

func ApplyDefaultForSuspend

func ApplyDefaultForSuspend(job GenericJob, manageJobsWithoutQueueName bool)

func GetWorkloadNameForOwnerRef

func GetWorkloadNameForOwnerRef(owner *metav1.OwnerReference) (string, error)

func GetWorkloadNameForOwnerWithGVK

func GetWorkloadNameForOwnerWithGVK(ownerName string, ownerGVK schema.GroupVersionKind) string

func IsMPIJob

func IsMPIJob(owner *metav1.OwnerReference) bool

func KnownWorkloadOwner

func KnownWorkloadOwner(owner *metav1.OwnerReference) bool

func KnownWorkloadOwnerObject added in v0.3.2

func KnownWorkloadOwnerObject(owner *metav1.OwnerReference) client.Object

func ParentWorkloadName

func ParentWorkloadName(job GenericJob) string

func QueueName

func QueueName(job GenericJob) string

func QueueNameForObject added in v0.3.2

func QueueNameForObject(object client.Object) string

func SetupWorkloadOwnerIndex

func SetupWorkloadOwnerIndex(ctx context.Context, indexer client.FieldIndexer, gvk schema.GroupVersionKind) error

func ValidateAnnotationAsCRDName

func ValidateAnnotationAsCRDName(job GenericJob, crdNameAnnotation string) field.ErrorList

func ValidateCreateForQueueName

func ValidateCreateForQueueName(job GenericJob) field.ErrorList

func ValidateUpdateForOriginalNodeSelectors

func ValidateUpdateForOriginalNodeSelectors(oldJob, newJob GenericJob) field.ErrorList

func ValidateUpdateForParentWorkload

func ValidateUpdateForParentWorkload(oldJob, newJob GenericJob) field.ErrorList

func ValidateUpdateForQueueName

func ValidateUpdateForQueueName(oldJob, newJob GenericJob) field.ErrorList

Types

type GenericJob

type GenericJob interface {
	// Object returns the job instance.
	Object() client.Object
	// IsSuspended returns whether the job is suspended or not.
	IsSuspended() bool
	// Suspend will suspend the job.
	Suspend()
	// ResetStatus will reset the job status to the original state.
	// If true, status is modified, if not, status is as it was.
	ResetStatus() bool
	// RunWithNodeAffinity will inject the node affinity extracting from workload to job and unsuspend the job.
	RunWithNodeAffinity(nodeSelectors []PodSetNodeSelector)
	// RestoreNodeAffinity will restore the original node affinity of job.
	RestoreNodeAffinity(nodeSelectors []PodSetNodeSelector)
	// Finished means whether the job is completed/failed or not,
	// condition represents the workload finished condition.
	Finished() (condition metav1.Condition, finished bool)
	// PodSets will build workload podSets corresponding to the job.
	PodSets() []kueue.PodSet
	// EquivalentToWorkload validates whether the workload is semantically equal to the job.
	EquivalentToWorkload(wl kueue.Workload) bool
	// PriorityClass returns the job's priority class name.
	PriorityClass() string
	// IsActive returns true if there are any running pods.
	IsActive() bool
	// PodsReady instructs whether job derived pods are all ready now.
	PodsReady() bool
	// GetGVK returns GVK (Group Version Kind) for the job.
	GetGVK() schema.GroupVersionKind
}

type JobReconciler

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

JobReconciler reconciles a GenericJob object

func NewReconciler

func NewReconciler(
	scheme *runtime.Scheme,
	client client.Client,
	record record.EventRecorder,
	opts ...Option) *JobReconciler

func (*JobReconciler) ReconcileGenericJob

func (r *JobReconciler) ReconcileGenericJob(ctx context.Context, req ctrl.Request, job GenericJob) (ctrl.Result, error)

type Option

type Option func(*Options)

Option configures the reconciler.

func WithManageJobsWithoutQueueName

func WithManageJobsWithoutQueueName(f bool) Option

WithManageJobsWithoutQueueName indicates if the controller should reconcile jobs that don't set the queue name annotation.

func WithWaitForPodsReady

func WithWaitForPodsReady(f bool) Option

WithWaitForPodsReady indicates if the controller should add the PodsReady condition to the workload when the corresponding job has all pods ready or succeeded.

type Options

type Options struct {
	ManageJobsWithoutQueueName bool
	WaitForPodsReady           bool
}

type PodSetNodeSelector

type PodSetNodeSelector struct {
	Name         string            `json:"name"`
	NodeSelector map[string]string `json:"nodeSelector"`
}

Jump to

Keyboard shortcuts

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