Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all valid policy actions #387

Merged
merged 2 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/admission/admission_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 6 additions & 0 deletions pkg/admission/admit_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ func TestValidateExecution(t *testing.T) {
},
},
},
Policies: []v1alpha1.LifecyclePolicy{
{
Event: v1alpha1.PodEvictedEvent,
Action: v1alpha1.RestartTaskAction,
},
},
},
},
reviewResponse: v1beta1.AdmissionResponse{Allowed: true},
Expand Down
10 changes: 7 additions & 3 deletions pkg/apis/batch/v1alpha1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down