Skip to content

Commit

Permalink
add defaults for task restart/reschedule policy [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi18av committed Mar 12, 2024
1 parent 9b62e1a commit 0c8a4cb
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import io.nomadproject.client.models.Job
import io.nomadproject.client.models.JobRegisterRequest
import io.nomadproject.client.models.JobRegisterResponse
import io.nomadproject.client.models.JobSummary
import io.nomadproject.client.models.ReschedulePolicy
import io.nomadproject.client.models.Resources
import io.nomadproject.client.models.RestartPolicy
import io.nomadproject.client.models.Task
import io.nomadproject.client.models.TaskGroup
import io.nomadproject.client.models.TaskGroupSummary
Expand Down Expand Up @@ -103,10 +105,18 @@ class NomadService implements Closeable{
}

TaskGroup createTaskGroup(TaskRun taskRun, List<String> args, Map<String, String>env){
final TASK_RESCHEDULE_ATTEMPTS = 0
final TASK_RESTART_ATTEMPTS = 0

final ReschedulePolicy taskReschedulePolicy = new ReschedulePolicy().attempts(TASK_RESCHEDULE_ATTEMPTS)
final RestartPolicy taskRestartPolicy = new RestartPolicy().attempts(TASK_RESTART_ATTEMPTS)

def task = createTask(taskRun, args, env)
def taskGroup = new TaskGroup(
name: "group",
tasks: [ task ]
tasks: [ task ],
reschedulePolicy: taskReschedulePolicy,
restartPolicy: taskRestartPolicy
)


Expand Down Expand Up @@ -139,6 +149,7 @@ class NomadService implements Closeable{
final workingDir = task.workDir.toAbsolutePath().toString()
final taskResources = getResources(task)


def taskDef = new Task(
name: "nf-task",
driver: DRIVER,
Expand Down

0 comments on commit 0c8a4cb

Please sign in to comment.