Address code review comments

This commit is contained in:
Preetha Appan
2018-01-22 19:58:23 -06:00
parent e41f68d7fa
commit 162f75e834
3 changed files with 18 additions and 5 deletions

View File

@@ -92,12 +92,12 @@ type Allocation struct {
DeploymentStatus *AllocDeploymentStatus
PreviousAllocation string
NextAllocation string
RescheduleTracker *RescheduleTracker
CreateIndex uint64
ModifyIndex uint64
AllocModifyIndex uint64
CreateTime int64
ModifyTime int64
RescheduleTracker *RescheduleTracker
}
// AllocationMetric is used to deserialize allocation metrics.
@@ -132,11 +132,11 @@ type AllocationListStub struct {
ClientDescription string
TaskStates map[string]*TaskState
DeploymentStatus *AllocDeploymentStatus
RescheduleTracker *RescheduleTracker
CreateIndex uint64
ModifyIndex uint64
CreateTime int64
ModifyTime int64
RescheduleTracker *RescheduleTracker
}
// AllocDeploymentStatus captures the status of the allocation as part of the

View File

@@ -321,7 +321,7 @@ func (g *TaskGroup) Canonicalize(job *Job) {
jobReschedule := job.Reschedule.Copy()
jobReschedule.Merge(g.ReschedulePolicy)
g.ReschedulePolicy = jobReschedule
} else if jr && !job.Reschedule.Empty() {
} else if jr {
jobReschedule := job.Reschedule.Copy()
g.ReschedulePolicy = jobReschedule
}

View File

@@ -296,8 +296,8 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) {
},
taskReschedulePolicy: nil,
expected: &ReschedulePolicy{
Attempts: helper.IntToPtr(structs.DefaultBatchJobReschedulePolicy.Attempts),
Interval: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Interval),
Attempts: helper.IntToPtr(0),
Interval: helper.TimeToPtr(0),
},
},
{
@@ -337,6 +337,19 @@ func TestTaskGroup_Canonicalize_ReschedulePolicy(t *testing.T) {
Interval: helper.TimeToPtr(5 * time.Minute),
},
},
{
desc: "Override from group",
jobReschedulePolicy: &ReschedulePolicy{
Attempts: helper.IntToPtr(1),
},
taskReschedulePolicy: &ReschedulePolicy{
Attempts: helper.IntToPtr(5),
},
expected: &ReschedulePolicy{
Attempts: helper.IntToPtr(5),
Interval: helper.TimeToPtr(structs.DefaultBatchJobReschedulePolicy.Interval),
},
},
{
desc: "Attempts from job, default interval",
jobReschedulePolicy: &ReschedulePolicy{