diff --git a/api/evaluations.go b/api/evaluations.go index 5aa893469..f8ec94329 100644 --- a/api/evaluations.go +++ b/api/evaluations.go @@ -67,6 +67,7 @@ type Evaluation struct { Status string StatusDescription string Wait time.Duration + WaitUntil time.Time NextEval string PreviousEval string BlockedEval string diff --git a/api/jobs_test.go b/api/jobs_test.go index 41fb41140..5d7a26750 100644 --- a/api/jobs_test.go +++ b/api/jobs_test.go @@ -140,7 +140,7 @@ func TestJobs_Canonicalize(t *testing.T) { Interval: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr("exponential"), Delay: helper.TimeToPtr(30 * time.Second), - DelayCeiling: helper.TimeToPtr(1 * time.Hour), + MaxDelay: helper.TimeToPtr(1 * time.Hour), Unlimited: helper.BoolToPtr(true), }, Tasks: []*Task{ @@ -210,7 +210,7 @@ func TestJobs_Canonicalize(t *testing.T) { Interval: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr("exponential"), Delay: helper.TimeToPtr(30 * time.Second), - DelayCeiling: helper.TimeToPtr(1 * time.Hour), + MaxDelay: helper.TimeToPtr(1 * time.Hour), Unlimited: helper.BoolToPtr(true), }, Tasks: []*Task{ @@ -347,7 +347,7 @@ func TestJobs_Canonicalize(t *testing.T) { Interval: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr("exponential"), Delay: helper.TimeToPtr(30 * time.Second), - DelayCeiling: helper.TimeToPtr(1 * time.Hour), + MaxDelay: helper.TimeToPtr(1 * time.Hour), Unlimited: helper.BoolToPtr(true), }, EphemeralDisk: &EphemeralDisk{ @@ -566,7 +566,7 @@ func TestJobs_Canonicalize(t *testing.T) { Interval: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr("exponential"), Delay: helper.TimeToPtr(30 * time.Second), - DelayCeiling: helper.TimeToPtr(1 * time.Hour), + MaxDelay: helper.TimeToPtr(1 * time.Hour), Unlimited: helper.BoolToPtr(true), }, Update: &UpdateStrategy{ @@ -606,7 +606,7 @@ func TestJobs_Canonicalize(t *testing.T) { Interval: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr("exponential"), Delay: helper.TimeToPtr(30 * time.Second), - DelayCeiling: helper.TimeToPtr(1 * time.Hour), + MaxDelay: helper.TimeToPtr(1 * time.Hour), Unlimited: helper.BoolToPtr(true), }, Update: &UpdateStrategy{ diff --git a/api/tasks.go b/api/tasks.go index ef123fa06..5bf957800 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -95,8 +95,8 @@ type ReschedulePolicy struct { // attempts. Valid values are "exponential", "linear", and "fibonacci". DelayFunction *string `mapstructure:"delay_function"` - // DelayCeiling is an upper bound on the delay. - DelayCeiling *time.Duration `mapstructure:"delay_ceiling"` + // MaxDelay is an upper bound on the delay. + MaxDelay *time.Duration `mapstructure:"max_delay"` // Unlimited allows rescheduling attempts until they succeed Unlimited *bool `mapstructure:"unlimited"` @@ -115,8 +115,8 @@ func (r *ReschedulePolicy) Merge(rp *ReschedulePolicy) { if rp.DelayFunction != nil { r.DelayFunction = rp.DelayFunction } - if rp.DelayCeiling != nil { - r.DelayCeiling = rp.DelayCeiling + if rp.MaxDelay != nil { + r.MaxDelay = rp.MaxDelay } if rp.Unlimited != nil { r.Unlimited = rp.Unlimited @@ -346,7 +346,7 @@ func (g *TaskGroup) Canonicalize(job *Job) { Interval: helper.TimeToPtr(structs.DefaultServiceJobReschedulePolicy.Interval), Delay: helper.TimeToPtr(structs.DefaultServiceJobReschedulePolicy.Delay), DelayFunction: helper.StringToPtr(structs.DefaultServiceJobReschedulePolicy.DelayFunction), - DelayCeiling: helper.TimeToPtr(structs.DefaultServiceJobReschedulePolicy.DelayCeiling), + MaxDelay: helper.TimeToPtr(structs.DefaultServiceJobReschedulePolicy.MaxDelay), Unlimited: helper.BoolToPtr(structs.DefaultServiceJobReschedulePolicy.Unlimited), } case "batch": @@ -355,7 +355,7 @@ func (g *TaskGroup) Canonicalize(job *Job) { Interval: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Interval), Delay: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Delay), DelayFunction: helper.StringToPtr(structs.DefaultBatchJobReschedulePolicy.DelayFunction), - DelayCeiling: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.DelayCeiling), + MaxDelay: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.MaxDelay), Unlimited: helper.BoolToPtr(structs.DefaultBatchJobReschedulePolicy.Unlimited), } default: diff --git a/api/tasks_test.go b/api/tasks_test.go index 284b6e8a4..3280507ad 100644 --- a/api/tasks_test.go +++ b/api/tasks_test.go @@ -288,7 +288,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Interval: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Interval), Delay: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Delay), DelayFunction: helper.StringToPtr(structs.DefaultBatchJobReschedulePolicy.DelayFunction), - DelayCeiling: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.DelayCeiling), + MaxDelay: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.MaxDelay), Unlimited: helper.BoolToPtr(structs.DefaultBatchJobReschedulePolicy.Unlimited), }, }, @@ -298,7 +298,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(0), Interval: helper.TimeToPtr(0), Delay: helper.TimeToPtr(0), - DelayCeiling: helper.TimeToPtr(0), + MaxDelay: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr(""), Unlimited: helper.BoolToPtr(false), }, @@ -307,7 +307,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(0), Interval: helper.TimeToPtr(0), Delay: helper.TimeToPtr(0), - DelayCeiling: helper.TimeToPtr(0), + MaxDelay: helper.TimeToPtr(0), DelayFunction: helper.StringToPtr(""), Unlimited: helper.BoolToPtr(false), }, @@ -318,7 +318,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(1), Interval: helper.TimeToPtr(20 * time.Second), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(10 * time.Minute), + MaxDelay: helper.TimeToPtr(10 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -327,7 +327,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(1), Interval: helper.TimeToPtr(20 * time.Second), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(10 * time.Minute), + MaxDelay: helper.TimeToPtr(10 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -339,7 +339,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(5), Interval: helper.TimeToPtr(2 * time.Minute), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(10 * time.Minute), + MaxDelay: helper.TimeToPtr(10 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -347,7 +347,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(5), Interval: helper.TimeToPtr(2 * time.Minute), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(10 * time.Minute), + MaxDelay: helper.TimeToPtr(10 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -355,9 +355,9 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { { desc: "Merge from job", jobReschedulePolicy: &ReschedulePolicy{ - Attempts: helper.IntToPtr(1), - Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(10 * time.Minute), + Attempts: helper.IntToPtr(1), + Delay: helper.TimeToPtr(20 * time.Second), + MaxDelay: helper.TimeToPtr(10 * time.Minute), }, taskReschedulePolicy: &ReschedulePolicy{ Interval: helper.TimeToPtr(5 * time.Minute), @@ -368,7 +368,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(1), Interval: helper.TimeToPtr(5 * time.Minute), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(10 * time.Minute), + MaxDelay: helper.TimeToPtr(10 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -376,13 +376,13 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { { desc: "Override from group", jobReschedulePolicy: &ReschedulePolicy{ - Attempts: helper.IntToPtr(1), - DelayCeiling: helper.TimeToPtr(10 * time.Second), + Attempts: helper.IntToPtr(1), + MaxDelay: helper.TimeToPtr(10 * time.Second), }, taskReschedulePolicy: &ReschedulePolicy{ Attempts: helper.IntToPtr(5), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(20 * time.Minute), + MaxDelay: helper.TimeToPtr(20 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -390,7 +390,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Attempts: helper.IntToPtr(5), Interval: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Interval), Delay: helper.TimeToPtr(20 * time.Second), - DelayCeiling: helper.TimeToPtr(20 * time.Minute), + MaxDelay: helper.TimeToPtr(20 * time.Minute), DelayFunction: helper.StringToPtr("linear"), Unlimited: helper.BoolToPtr(false), }, @@ -406,7 +406,7 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) { Interval: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Interval), Delay: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Delay), DelayFunction: helper.StringToPtr(structs.DefaultBatchJobReschedulePolicy.DelayFunction), - DelayCeiling: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.DelayCeiling), + MaxDelay: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.MaxDelay), Unlimited: helper.BoolToPtr(structs.DefaultBatchJobReschedulePolicy.Unlimited), }, }, diff --git a/command/agent/job_endpoint.go b/command/agent/job_endpoint.go index a059343ab..dc64afcfa 100644 --- a/command/agent/job_endpoint.go +++ b/command/agent/job_endpoint.go @@ -643,7 +643,7 @@ func ApiTgToStructsTG(taskGroup *api.TaskGroup, tg *structs.TaskGroup) { Interval: *taskGroup.ReschedulePolicy.Interval, Delay: *taskGroup.ReschedulePolicy.Delay, DelayFunction: *taskGroup.ReschedulePolicy.DelayFunction, - DelayCeiling: *taskGroup.ReschedulePolicy.DelayCeiling, + MaxDelay: *taskGroup.ReschedulePolicy.MaxDelay, Unlimited: *taskGroup.ReschedulePolicy.Unlimited, } diff --git a/command/agent/job_endpoint_test.go b/command/agent/job_endpoint_test.go index ccc58276a..dc50dd77e 100644 --- a/command/agent/job_endpoint_test.go +++ b/command/agent/job_endpoint_test.go @@ -1177,7 +1177,7 @@ func TestJobs_ApiJobToStructsJob(t *testing.T) { DelayFunction: helper.StringToPtr("linear"), Delay: helper.TimeToPtr(30 * time.Second), Unlimited: helper.BoolToPtr(true), - DelayCeiling: helper.TimeToPtr(20 * time.Minute), + MaxDelay: helper.TimeToPtr(20 * time.Minute), }, EphemeralDisk: &api.EphemeralDisk{ SizeMB: helper.IntToPtr(100), @@ -1393,7 +1393,7 @@ func TestJobs_ApiJobToStructsJob(t *testing.T) { DelayFunction: "linear", Delay: 30 * time.Second, Unlimited: true, - DelayCeiling: 20 * time.Minute, + MaxDelay: 20 * time.Minute, }, EphemeralDisk: &structs.EphemeralDisk{ SizeMB: 100, diff --git a/jobspec/parse.go b/jobspec/parse.go index 20e06016c..d6f235e05 100644 --- a/jobspec/parse.go +++ b/jobspec/parse.go @@ -448,7 +448,7 @@ func parseReschedulePolicy(final **api.ReschedulePolicy, list *ast.ObjectList) e "interval", "unlimited", "delay", - "delay_ceiling", + "max_delay", "delay_function", } if err := helper.CheckHCLKeys(obj.Val, valid); err != nil { diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 45831a577..dbf120057 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -713,7 +713,7 @@ func TestParse(t *testing.T) { Reschedule: &api.ReschedulePolicy{ DelayFunction: helper.StringToPtr("exponential"), Delay: helper.TimeToPtr(10 * time.Second), - DelayCeiling: helper.TimeToPtr(120 * time.Second), + MaxDelay: helper.TimeToPtr(120 * time.Second), Unlimited: helper.BoolToPtr(true), }, TaskGroups: []*api.TaskGroup{ diff --git a/jobspec/test-fixtures/reschedule-job-unlimited.hcl b/jobspec/test-fixtures/reschedule-job-unlimited.hcl index b2840c123..c51be506a 100644 --- a/jobspec/test-fixtures/reschedule-job-unlimited.hcl +++ b/jobspec/test-fixtures/reschedule-job-unlimited.hcl @@ -4,7 +4,7 @@ job "foo" { reschedule { delay = "10s", delay_function = "exponential" - delay_ceiling="120s" + max_delay="120s" unlimited = true } group "bar" { diff --git a/nomad/structs/diff_test.go b/nomad/structs/diff_test.go index 52f28938b..09453b382 100644 --- a/nomad/structs/diff_test.go +++ b/nomad/structs/diff_test.go @@ -1502,7 +1502,7 @@ func TestTaskGroupDiff(t *testing.T) { Attempts: 1, Interval: 15 * time.Second, Delay: 5 * time.Second, - DelayCeiling: 20 * time.Second, + MaxDelay: 20 * time.Second, DelayFunction: "exponential", Unlimited: false, }, @@ -1526,12 +1526,6 @@ func TestTaskGroupDiff(t *testing.T) { Old: "", New: "5000000000", }, - { - Type: DiffTypeAdded, - Name: "DelayCeiling", - Old: "", - New: "20000000000", - }, { Type: DiffTypeAdded, Name: "DelayFunction", @@ -1544,6 +1538,12 @@ func TestTaskGroupDiff(t *testing.T) { Old: "", New: "15000000000", }, + { + Type: DiffTypeAdded, + Name: "MaxDelay", + Old: "", + New: "20000000000", + }, { Type: DiffTypeAdded, Name: "Unlimited", @@ -1562,7 +1562,7 @@ func TestTaskGroupDiff(t *testing.T) { Attempts: 1, Interval: 15 * time.Second, Delay: 5 * time.Second, - DelayCeiling: 20 * time.Second, + MaxDelay: 20 * time.Second, DelayFunction: "exponential", Unlimited: false, }, @@ -1587,12 +1587,6 @@ func TestTaskGroupDiff(t *testing.T) { Old: "5000000000", New: "", }, - { - Type: DiffTypeDeleted, - Name: "DelayCeiling", - Old: "20000000000", - New: "", - }, { Type: DiffTypeDeleted, Name: "DelayFunction", @@ -1605,6 +1599,12 @@ func TestTaskGroupDiff(t *testing.T) { Old: "15000000000", New: "", }, + { + Type: DiffTypeDeleted, + Name: "MaxDelay", + Old: "20000000000", + New: "", + }, { Type: DiffTypeDeleted, Name: "Unlimited", @@ -1624,7 +1624,7 @@ func TestTaskGroupDiff(t *testing.T) { Interval: 1 * time.Second, DelayFunction: "exponential", Delay: 20 * time.Second, - DelayCeiling: 1 * time.Minute, + MaxDelay: 1 * time.Minute, Unlimited: false, }, }, @@ -1634,7 +1634,7 @@ func TestTaskGroupDiff(t *testing.T) { Interval: 2 * time.Second, DelayFunction: "linear", Delay: 30 * time.Second, - DelayCeiling: 1 * time.Minute, + MaxDelay: 1 * time.Minute, Unlimited: true, }, }, @@ -1713,12 +1713,6 @@ func TestTaskGroupDiff(t *testing.T) { Old: "0", New: "0", }, - { - Type: DiffTypeNone, - Name: "DelayCeiling", - Old: "0", - New: "0", - }, { Type: DiffTypeNone, Name: "DelayFunction", @@ -1731,6 +1725,12 @@ func TestTaskGroupDiff(t *testing.T) { Old: "1000000000", New: "2000000000", }, + { + Type: DiffTypeNone, + Name: "MaxDelay", + Old: "0", + New: "0", + }, { Type: DiffTypeNone, Name: "Unlimited", diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 8a2c09004..2999026b6 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2660,7 +2660,7 @@ var ( DefaultServiceJobReschedulePolicy = ReschedulePolicy{ Delay: 30 * time.Second, DelayFunction: "exponential", - DelayCeiling: 1 * time.Hour, + MaxDelay: 1 * time.Hour, Unlimited: true, } DefaultBatchJobReschedulePolicy = ReschedulePolicy{ @@ -2770,8 +2770,8 @@ type ReschedulePolicy struct { // attempts. Valid values are "exponential", "linear", and "fibonacci". DelayFunction string - // DelayCeiling is an upper bound on the delay. - DelayCeiling time.Duration + // MaxDelay is an upper bound on the delay. + MaxDelay time.Duration // Unlimited allows infinite rescheduling attempts. Only allowed when delay is set // between reschedule attempts. @@ -2812,14 +2812,14 @@ func (r *ReschedulePolicy) Validate() error { delayPreCheck = false } - // Validate DelayCeiling if not using linear delay progression + // Validate MaxDelay if not using linear delay progression if r.DelayFunction != "linear" { - if r.DelayCeiling.Nanoseconds() < ReschedulePolicyMinDelay.Nanoseconds() { + if r.MaxDelay.Nanoseconds() < ReschedulePolicyMinDelay.Nanoseconds() { multierror.Append(&mErr, fmt.Errorf("Delay Ceiling cannot be less than %v (got %v)", ReschedulePolicyMinDelay, r.Delay)) delayPreCheck = false } - if r.DelayCeiling < r.Delay { - multierror.Append(&mErr, fmt.Errorf("Delay Ceiling cannot be less than Delay %v (got %v)", r.Delay, r.DelayCeiling)) + if r.MaxDelay < r.Delay { + multierror.Append(&mErr, fmt.Errorf("Delay Ceiling cannot be less than Delay %v (got %v)", r.Delay, r.MaxDelay)) delayPreCheck = false } @@ -2862,7 +2862,7 @@ func (r *ReschedulePolicy) validateDelayParams() error { "delay function %q", possibleAttempts, r.Interval, r.Delay, r.DelayFunction)) } else { multierror.Append(&mErr, fmt.Errorf("Nomad can only make %v attempts in %v with initial delay %v, "+ - "delay function %q, and delay ceiling %v", possibleAttempts, r.Interval, r.Delay, r.DelayFunction, r.DelayCeiling)) + "delay function %q, and delay ceiling %v", possibleAttempts, r.Interval, r.Delay, r.DelayFunction, r.MaxDelay)) } multierror.Append(&mErr, fmt.Errorf("Set the interval to at least %v to accommodate %v attempts", recommendedInterval.Round(time.Minute), r.Attempts)) return mErr.ErrorOrNil() @@ -2882,8 +2882,8 @@ func (r *ReschedulePolicy) viableAttempts() (bool, int, time.Duration) { case "exponential": for i := 0; i < r.Attempts; i++ { nextDelay := time.Duration(math.Pow(2, float64(i))) * r.Delay - if nextDelay > r.DelayCeiling { - nextDelay = r.DelayCeiling + if nextDelay > r.MaxDelay { + nextDelay = r.MaxDelay recommendedInterval += nextDelay } else { recommendedInterval = nextDelay @@ -2904,11 +2904,11 @@ func (r *ReschedulePolicy) viableAttempts() (bool, int, time.Duration) { var nextDelay time.Duration if reachedCeiling { //switch to linear - nextDelay = slots[i-1] + r.DelayCeiling + nextDelay = slots[i-1] + r.MaxDelay } else { nextDelay = slots[i-1] + slots[i-2] - if nextDelay > r.DelayCeiling { - nextDelay = r.DelayCeiling + if nextDelay > r.MaxDelay { + nextDelay = r.MaxDelay reachedCeiling = true } } @@ -5556,7 +5556,7 @@ func (a *Allocation) NextDelay() time.Duration { fibN2Delay := events[len(events)-2].Delay // Handle reset of delay ceiling which should cause // a new series to start - if fibN2Delay == policy.DelayCeiling && fibN1Delay == policy.Delay { + if fibN2Delay == policy.MaxDelay && fibN1Delay == policy.Delay { delayDur = fibN1Delay } else { delayDur = fibN1Delay + fibN2Delay @@ -5565,8 +5565,8 @@ func (a *Allocation) NextDelay() time.Duration { default: return delayDur } - if policy.DelayCeiling > 0 && delayDur > policy.DelayCeiling { - delayDur = policy.DelayCeiling + if policy.MaxDelay > 0 && delayDur > policy.MaxDelay { + delayDur = policy.MaxDelay // check if delay needs to be reset lastRescheduleEvent := a.RescheduleTracker.Events[len(a.RescheduleTracker.Events)-1] diff --git a/nomad/structs/structs_test.go b/nomad/structs/structs_test.go index 15cf24e42..d249d30c5 100644 --- a/nomad/structs/structs_test.go +++ b/nomad/structs/structs_test.go @@ -2464,7 +2464,7 @@ func TestReschedulePolicy_Validate(t *testing.T) { Attempts: 5, Interval: 1 * time.Hour, Delay: 30 * time.Second, - DelayCeiling: 5 * time.Minute, + MaxDelay: 5 * time.Minute, DelayFunction: "exponential"}, }, { @@ -2473,7 +2473,7 @@ func TestReschedulePolicy_Validate(t *testing.T) { Attempts: 5, Interval: 15 * time.Minute, Delay: 10 * time.Second, - DelayCeiling: 5 * time.Minute, + MaxDelay: 5 * time.Minute, DelayFunction: "fibonacci"}, }, { @@ -2495,7 +2495,7 @@ func TestReschedulePolicy_Validate(t *testing.T) { Interval: 8 * time.Second, DelayFunction: "exponential", Delay: 15 * time.Second, - DelayCeiling: 5 * time.Second}, + MaxDelay: 5 * time.Second}, errors: []error{ fmt.Errorf("Delay Ceiling cannot be less than Delay %v (got %v)", 15*time.Second, 5*time.Second), @@ -2535,7 +2535,7 @@ func TestReschedulePolicy_Validate(t *testing.T) { Attempts: 10, Interval: 30 * time.Minute, Delay: 5 * time.Minute, - DelayCeiling: 40 * time.Minute, + MaxDelay: 40 * time.Minute, DelayFunction: "exponential", }, errors: []error{ @@ -2554,7 +2554,7 @@ func TestReschedulePolicy_Validate(t *testing.T) { Attempts: 10, Interval: 1 * time.Hour, Delay: 20 * time.Minute, - DelayCeiling: 80 * time.Minute, + MaxDelay: 80 * time.Minute, DelayFunction: "fibonacci", }, errors: []error{ @@ -2572,7 +2572,7 @@ func TestReschedulePolicy_Validate(t *testing.T) { Unlimited: true, DelayFunction: "exponential", Delay: 5 * time.Minute, - DelayCeiling: 1 * time.Hour, + MaxDelay: 1 * time.Hour, }, }, { @@ -3115,7 +3115,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "exponential", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3132,7 +3132,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "exponential", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3164,7 +3164,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "exponential", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3205,7 +3205,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "exponential", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3253,7 +3253,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "fibonacci", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3269,7 +3269,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "fibonacci", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3297,7 +3297,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "fibonacci", Delay: 5 * time.Second, - DelayCeiling: 90 * time.Second, + MaxDelay: 90 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3337,7 +3337,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "fibonacci", Delay: 5 * time.Second, - DelayCeiling: 50 * time.Second, + MaxDelay: 50 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3381,7 +3381,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "fibonacci", Delay: 5 * time.Second, - DelayCeiling: 50 * time.Second, + MaxDelay: 50 * time.Second, Unlimited: true, }, alloc: &Allocation{ @@ -3425,7 +3425,7 @@ func TestAllocation_NextDelay(t *testing.T) { reschedulePolicy: &ReschedulePolicy{ DelayFunction: "fibonacci", Delay: 5 * time.Second, - DelayCeiling: 50 * time.Second, + MaxDelay: 50 * time.Second, Unlimited: true, }, alloc: &Allocation{ diff --git a/scheduler/generic_sched_test.go b/scheduler/generic_sched_test.go index 349a59782..5b21034eb 100644 --- a/scheduler/generic_sched_test.go +++ b/scheduler/generic_sched_test.go @@ -2733,7 +2733,7 @@ func TestServiceSched_Reschedule_OnceNow(t *testing.T) { Attempts: 1, Interval: 15 * time.Minute, Delay: 5 * time.Second, - DelayCeiling: 1 * time.Minute, + MaxDelay: 1 * time.Minute, DelayFunction: "linear", } tgName := job.TaskGroups[0].Name @@ -2846,7 +2846,7 @@ func TestServiceSched_Reschedule_Later(t *testing.T) { Attempts: 1, Interval: 15 * time.Minute, Delay: delayDuration, - DelayCeiling: 1 * time.Minute, + MaxDelay: 1 * time.Minute, DelayFunction: "linear", } tgName := job.TaskGroups[0].Name @@ -3072,7 +3072,7 @@ func TestServiceSched_Reschedule_PruneEvents(t *testing.T) { job.TaskGroups[0].Count = 2 job.TaskGroups[0].ReschedulePolicy = &structs.ReschedulePolicy{ DelayFunction: "exponential", - DelayCeiling: 1 * time.Hour, + MaxDelay: 1 * time.Hour, Delay: 5 * time.Second, Unlimited: true, } @@ -4270,7 +4270,7 @@ func Test_updateRescheduleTracker(t *testing.T) { PrevAllocID: prevAlloc.ID, PrevNodeID: prevAlloc.NodeID, Delay: 5 * time.Second}}, - reschedPolicy: &structs.ReschedulePolicy{Unlimited: false, Interval: 24 * time.Hour, Attempts: 2, Delay: 5 * time.Second, DelayFunction: "fibonacci", DelayCeiling: 60 * time.Second}, + reschedPolicy: &structs.ReschedulePolicy{Unlimited: false, Interval: 24 * time.Hour, Attempts: 2, Delay: 5 * time.Second, DelayFunction: "fibonacci", MaxDelay: 60 * time.Second}, reschedTime: t1, expectedRescheduleEvents: []*structs.RescheduleEvent{ { @@ -4339,7 +4339,7 @@ func Test_updateRescheduleTracker(t *testing.T) { Delay: 105 * time.Second, }, }, - reschedPolicy: &structs.ReschedulePolicy{Unlimited: true, Delay: 5 * time.Second, DelayFunction: "fibonacci", DelayCeiling: 240 * time.Second}, + reschedPolicy: &structs.ReschedulePolicy{Unlimited: true, Delay: 5 * time.Second, DelayFunction: "fibonacci", MaxDelay: 240 * time.Second}, reschedTime: t1, expectedRescheduleEvents: []*structs.RescheduleEvent{ { @@ -4408,7 +4408,7 @@ func Test_updateRescheduleTracker(t *testing.T) { Delay: 40 * time.Second, }, }, - reschedPolicy: &structs.ReschedulePolicy{Unlimited: false, Interval: 1 * time.Hour, Attempts: 5, Delay: 5 * time.Second, DelayFunction: "exponential", DelayCeiling: 240 * time.Second}, + reschedPolicy: &structs.ReschedulePolicy{Unlimited: false, Interval: 1 * time.Hour, Attempts: 5, Delay: 5 * time.Second, DelayFunction: "exponential", MaxDelay: 240 * time.Second}, reschedTime: t1, expectedRescheduleEvents: []*structs.RescheduleEvent{ { diff --git a/scheduler/reconcile_test.go b/scheduler/reconcile_test.go index 7866a2096..34f6eddbf 100644 --- a/scheduler/reconcile_test.go +++ b/scheduler/reconcile_test.go @@ -1456,7 +1456,7 @@ func TestReconciler_RescheduleLater_Service(t *testing.T) { now := time.Now() // Set up reschedule policy delayDur := 15 * time.Second - job.TaskGroups[0].ReschedulePolicy = &structs.ReschedulePolicy{Attempts: 1, Interval: 24 * time.Hour, Delay: delayDur, DelayCeiling: 1 * time.Hour} + job.TaskGroups[0].ReschedulePolicy = &structs.ReschedulePolicy{Attempts: 1, Interval: 24 * time.Hour, Delay: delayDur, MaxDelay: 1 * time.Hour} // Create 5 existing allocations var allocs []*structs.Allocation @@ -1526,7 +1526,7 @@ func TestReconciler_RescheduleNow_Service(t *testing.T) { tgName := job.TaskGroups[0].Name now := time.Now() // Set up reschedule policy - job.TaskGroups[0].ReschedulePolicy = &structs.ReschedulePolicy{Attempts: 1, Interval: 24 * time.Hour, Delay: 5 * time.Second, DelayCeiling: 1 * time.Hour} + job.TaskGroups[0].ReschedulePolicy = &structs.ReschedulePolicy{Attempts: 1, Interval: 24 * time.Hour, Delay: 5 * time.Second, MaxDelay: 1 * time.Hour} // Create 5 existing allocations var allocs []*structs.Allocation