mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
fix restart policy for system jobs with no lifecycle
This commit is contained in:
committed by
Mahmood Ali
parent
43fab7d46d
commit
dcd317745d
@@ -21,7 +21,7 @@ const (
|
||||
)
|
||||
|
||||
func NewRestartTracker(policy *structs.RestartPolicy, jobType string, tlc *structs.TaskLifecycleConfig) *RestartTracker {
|
||||
onSuccess := jobType == structs.JobTypeService
|
||||
onSuccess := jobType != structs.JobTypeBatch
|
||||
if tlc != nil && tlc.Hook == structs.TaskLifecycleHookPrestart {
|
||||
onSuccess = tlc.BlockUntil != structs.TaskLifecycleBlockUntilCompleted
|
||||
}
|
||||
|
||||
@@ -210,6 +210,13 @@ func TestClient_RestartTracker_Lifecycle(t *testing.T) {
|
||||
shouldRestartOnSuccess bool
|
||||
shouldRestartOnFailure bool
|
||||
}{
|
||||
{
|
||||
name: "system job no lifecycle",
|
||||
taskLifecycleConfig: nil,
|
||||
jobType: structs.JobTypeSystem,
|
||||
shouldRestartOnSuccess: true,
|
||||
shouldRestartOnFailure: true,
|
||||
},
|
||||
{
|
||||
name: "service job no lifecycle",
|
||||
taskLifecycleConfig: nil,
|
||||
@@ -224,6 +231,26 @@ func TestClient_RestartTracker_Lifecycle(t *testing.T) {
|
||||
shouldRestartOnSuccess: false,
|
||||
shouldRestartOnFailure: true,
|
||||
},
|
||||
{
|
||||
name: "system job w/ lifecycle completed",
|
||||
taskLifecycleConfig: &structs.TaskLifecycleConfig{
|
||||
Hook: structs.TaskLifecycleHookPrestart,
|
||||
BlockUntil: structs.TaskLifecycleBlockUntilCompleted,
|
||||
},
|
||||
jobType: structs.JobTypeSystem,
|
||||
shouldRestartOnSuccess: false,
|
||||
shouldRestartOnFailure: true,
|
||||
},
|
||||
{
|
||||
name: "system job w/ lifecycle running",
|
||||
taskLifecycleConfig: &structs.TaskLifecycleConfig{
|
||||
Hook: structs.TaskLifecycleHookPrestart,
|
||||
BlockUntil: structs.TaskLifecycleBlockUntilRunning,
|
||||
},
|
||||
jobType: structs.JobTypeSystem,
|
||||
shouldRestartOnSuccess: true,
|
||||
shouldRestartOnFailure: true,
|
||||
},
|
||||
{
|
||||
name: "service job w/ lifecycle completed",
|
||||
taskLifecycleConfig: &structs.TaskLifecycleConfig{
|
||||
|
||||
Reference in New Issue
Block a user