common

package
v0.0.0-...-9490451 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0, BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JobCreatedReason is added in a job when it is created.
	JobCreatedReason = "JobCreated"
	// JobSucceededReason is added in a job when it is succeeded.
	JobSucceededReason = "JobSucceeded"
	// JobRunningReason is added in a job when it is running.
	JobRunningReason = "JobRunning"
	// JobFailedReason is added in a job when it is failed.
	JobFailedReason = "JobFailed"
	// JobRestartingReason is added in a job when it is restarting.
	JobRestartingReason = "JobRestarting"
	// JobPendingReason is added in a job when it is pending.
	JobPendingReason = "JobPending"
	// JobScalingReason is added in a job when it is scaling up/down Pods.
	JobScalingReason = "JobScaling"
)
View Source
const (

	// LabelReplicaTypeKey is the key of ReplicaType in labels
	LabelReplicaTypeKey = "elasticjob.dlrover/replica-type"
	// LabelReplicaIndexKey is the key of ReplicaIndex in labels
	LabelReplicaIndexKey = "elasticjob.dlrover/replica-index"
	// LabelRankIndexKey is the key of rankIndex.
	LabelRankIndexKey = "elasticjob.dlrover/rank-index"
)

Variables

View Source
var ReplicaManagers = make(map[commonv1.ReplicaType]ReplicaManager)

ReplicaManagers contains the manager for each ReplicaType

Functions

func DeletePod

func DeletePod(client runtime_client.Client, pod *corev1.Pod) error

DeletePod remove a Pod

func GetCondition

func GetCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) *apiv1.JobCondition

GetCondition returns the condition with the provided type.

func GetPod

func GetPod(
	client runtime_client.Client,
	namespace string,
	name string,
) (*corev1.Pod, error)

GetPod gets a Pod object

func GetReplicaStatus

func GetReplicaStatus(pods []corev1.Pod) *commonv1.ReplicaStatus

GetReplicaStatus gets ReplicaStatus from ReplicaType Pods

func GetReplicaTypePods

func GetReplicaTypePods(
	client runtime_client.Client,
	job *elasticv1alpha1.ElasticJob,
	replicaType commonv1.ReplicaType,
) ([]corev1.Pod, error)

GetReplicaTypePods get all ReplicaType Pods of a job

func HasCondition

func HasCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) bool

HasCondition check wether there is the conditionType in jobStatus.

func InitializeJobStatuses

func InitializeJobStatuses(jobStatus *elasticv1alpha1.ElasticJobStatus, rtype apiv1.ReplicaType)

InitializeJobStatuses initializes the ReplicaStatuses for TrainingJob.

func IsFailed

func IsFailed(status apiv1.JobStatus) bool

IsFailed checks if the job is failed

func IsSucceeded

func IsSucceeded(status apiv1.JobStatus) bool

IsSucceeded checks if the job is succeeded

func NewCondition

func NewCondition(conditionType apiv1.JobConditionType, reason, message string) apiv1.JobCondition

NewCondition creates a new job condition.

func NewPod

func NewPod(
	job *elasticv1alpha1.ElasticJob,
	podTemplate *corev1.PodTemplateSpec,
	podName string,
) *corev1.Pod

NewPod creates a Pod according to a PodTemplateSpec

func NewService

func NewService(job *elasticv1alpha1.ElasticJob, name string, port int, selector map[string]string) *corev1.Service

NewService create a service

func SetCondition

func SetCondition(status *apiv1.JobStatus, condition apiv1.JobCondition)

SetCondition updates the job to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

func UpdateJobConditions

func UpdateJobConditions(jobStatus *apiv1.JobStatus, conditionType apiv1.JobConditionType, reason, message string) error

UpdateJobConditions adds to the jobStatus a new condition if needed, with the conditionType, reason, and message

func UpdateStatus

func UpdateStatus(jobStatus *elasticv1alpha1.ElasticJobStatus, conditionType apiv1.JobConditionType, reason, message string) error

UpdateStatus adds to the jobStatus a new condition if needed, with the conditionType, reason, and message.

Types

type ReplicaManager

type ReplicaManager interface {
	ReconcilePods(client runtime_client.Client, job *elasticv1alpha1.ElasticJob, scalePlan *elasticv1alpha1.ScalePlan) error

	SyncJobState(client runtime_client.Client, job *elasticv1alpha1.ElasticJob) error

	HandleFaultPods(client runtime_client.Client, job *elasticv1alpha1.ElasticJob) error

	StopRunningPods(client runtime_client.Client, job *elasticv1alpha1.ElasticJob) error
}

ReplicaManager manage pods of ReplicaType

Directories

Path Synopsis
api
v1

Jump to

Keyboard shortcuts

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