Documentation ¶
Index ¶
- Constants
- Variables
- func DeletePod(client runtime_client.Client, pod *corev1.Pod) error
- func GetCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) *apiv1.JobCondition
- func GetPod(client runtime_client.Client, namespace string, name string) (*corev1.Pod, error)
- func GetReplicaStatus(pods []corev1.Pod) *commonv1.ReplicaStatus
- func GetReplicaTypePods(client runtime_client.Client, job *elasticv1alpha1.ElasticJob, ...) ([]corev1.Pod, error)
- func HasCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) bool
- func InitializeJobStatuses(jobStatus *elasticv1alpha1.ElasticJobStatus, rtype apiv1.ReplicaType)
- func IsFailed(status apiv1.JobStatus) bool
- func IsSucceeded(status apiv1.JobStatus) bool
- func NewCondition(conditionType apiv1.JobConditionType, reason, message string) apiv1.JobCondition
- func NewPod(job *elasticv1alpha1.ElasticJob, podTemplate *corev1.PodTemplateSpec, ...) *corev1.Pod
- func NewService(job *elasticv1alpha1.ElasticJob, name string, port int, ...) *corev1.Service
- func SetCondition(status *apiv1.JobStatus, condition apiv1.JobCondition)
- func UpdateJobConditions(jobStatus *apiv1.JobStatus, conditionType apiv1.JobConditionType, ...) error
- func UpdateStatus(jobStatus *elasticv1alpha1.ElasticJobStatus, ...) error
- type ReplicaManager
Constants ¶
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" )
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 ¶
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 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 IsSucceeded ¶
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