diff --git a/pkg/admission/admission_controller.go b/pkg/admission/admission_controller.go index bafca92277..7df0fcc504 100644 --- a/pkg/admission/admission_controller.go +++ b/pkg/admission/admission_controller.go @@ -64,10 +64,12 @@ var policyEventMap = map[v1alpha1.Event]bool{ var policyActionMap = map[v1alpha1.Action]bool{ v1alpha1.AbortJobAction: true, v1alpha1.RestartJobAction: true, + v1alpha1.RestartTaskAction: true, v1alpha1.TerminateJobAction: true, v1alpha1.CompleteJobAction: true, v1alpha1.ResumeJobAction: true, v1alpha1.SyncJobAction: false, + v1alpha1.EnqueueAction: false, } func init() { diff --git a/pkg/admission/admit_job_test.go b/pkg/admission/admit_job_test.go index 83310c9f5f..69c648d177 100644 --- a/pkg/admission/admit_job_test.go +++ b/pkg/admission/admit_job_test.go @@ -72,6 +72,12 @@ func TestValidateExecution(t *testing.T) { }, }, }, + Policies: []v1alpha1.LifecyclePolicy{ + { + Event: v1alpha1.PodEvictedEvent, + Action: v1alpha1.RestartTaskAction, + }, + }, }, }, reviewResponse: v1beta1.AdmissionResponse{Allowed: true}, diff --git a/pkg/apis/batch/v1alpha1/job.go b/pkg/apis/batch/v1alpha1/job.go index 5895b1830c..760b9a6a5c 100644 --- a/pkg/apis/batch/v1alpha1/job.go +++ b/pkg/apis/batch/v1alpha1/job.go @@ -132,13 +132,15 @@ const ( // 1. Task Unschedulable, this is triggered when part of // pods can't be scheduled while some are already running in gang-scheduling case. JobUnknownEvent Event = "Unknown" + // TaskCompletedEvent is triggered if the 'Replicas' amount of pods in one task are succeed + TaskCompletedEvent Event = "TaskCompleted" + + // Note: events below are used internally, should not be used by users. // OutOfSyncEvent is triggered if Pod/Job were updated OutOfSyncEvent Event = "OutOfSync" // CommandIssuedEvent is triggered if a command is raised by user CommandIssuedEvent Event = "CommandIssued" - // TaskCompletedEvent is triggered if the 'Replicas' amount of pods in one task are succeed - TaskCompletedEvent Event = "TaskCompleted" ) // Action is the action that Job controller will take according to the event. @@ -158,9 +160,11 @@ const ( TerminateJobAction Action = "TerminateJob" // CompleteJobAction if this action is set, the unfinished pods will be killed, job completed. CompleteJobAction Action = "CompleteJob" - // ResumeJobAction is the action to resume an aborted job. ResumeJobAction Action = "ResumeJob" + + // Note: actions below are only used internally, should not be used by users. + // SyncJobAction is the action to sync Job/Pod status. SyncJobAction Action = "SyncJob" // EnqueueAction is the action to sync Job inqueue status.