Extra comments, remove unnecessary if condition

This commit is contained in:
Preetha Appan 2018-03-07 18:02:22 -06:00
parent c6f333c90f
commit 4d5e9bcb45
No known key found for this signature in database
GPG key ID: 9F7C19990A50EAFC

View file

@ -5502,7 +5502,7 @@ func (a *Allocation) LastEventTime() time.Time {
return lastEventTime return lastEventTime
} }
// NextRescheduleTime returns a time delta after which the allocation is eligible to be rescheduled // NextRescheduleTime returns a time on or after which the allocation is eligible to be rescheduled,
// and whether the next reschedule time is within policy's interval if the policy doesn't allow unlimited reschedules // and whether the next reschedule time is within policy's interval if the policy doesn't allow unlimited reschedules
func (a *Allocation) NextRescheduleTime(reschedulePolicy *ReschedulePolicy) (time.Time, bool) { func (a *Allocation) NextRescheduleTime(reschedulePolicy *ReschedulePolicy) (time.Time, bool) {
failTime := a.LastEventTime() failTime := a.LastEventTime()
@ -5527,6 +5527,8 @@ func (a *Allocation) NextRescheduleTime(reschedulePolicy *ReschedulePolicy) (tim
return nextRescheduleTime, rescheduleEligible return nextRescheduleTime, rescheduleEligible
} }
// NextDelay returns a duration after which the allocation can be rescheduled.
// It is calculated according to the delay function and previous reschedule attempts.
func (a *Allocation) NextDelay(policy *ReschedulePolicy) time.Duration { func (a *Allocation) NextDelay(policy *ReschedulePolicy) time.Duration {
delayDur := policy.Delay delayDur := policy.Delay
if a.RescheduleTracker == nil || a.RescheduleTracker.Events == nil || len(a.RescheduleTracker.Events) == 0 { if a.RescheduleTracker == nil || a.RescheduleTracker.Events == nil || len(a.RescheduleTracker.Events) == 0 {
@ -5554,13 +5556,13 @@ func (a *Allocation) NextDelay(policy *ReschedulePolicy) time.Duration {
if policy.DelayCeiling > 0 && delayDur > policy.DelayCeiling { if policy.DelayCeiling > 0 && delayDur > policy.DelayCeiling {
delayDur = policy.DelayCeiling delayDur = policy.DelayCeiling
// check if delay needs to be reset // check if delay needs to be reset
if len(a.RescheduleTracker.Events) > 0 {
lastRescheduleEvent := a.RescheduleTracker.Events[len(a.RescheduleTracker.Events)-1] lastRescheduleEvent := a.RescheduleTracker.Events[len(a.RescheduleTracker.Events)-1]
timeDiff := a.LastEventTime().UTC().UnixNano() - lastRescheduleEvent.RescheduleTime timeDiff := a.LastEventTime().UTC().UnixNano() - lastRescheduleEvent.RescheduleTime
if timeDiff > delayDur.Nanoseconds() { if timeDiff > delayDur.Nanoseconds() {
delayDur = policy.Delay delayDur = policy.Delay
}
} }
} }
return delayDur return delayDur
@ -5670,12 +5672,11 @@ type AllocListStub struct {
ClientDescription string ClientDescription string
TaskStates map[string]*TaskState TaskStates map[string]*TaskState
DeploymentStatus *AllocDeploymentStatus DeploymentStatus *AllocDeploymentStatus
FollowupEvalID string
FollowupEvalID string CreateIndex uint64
CreateIndex uint64 ModifyIndex uint64
ModifyIndex uint64 CreateTime int64
CreateTime int64 ModifyTime int64
ModifyTime int64
} }
// SetEventDisplayMessage populates the display message if its not already set, // SetEventDisplayMessage populates the display message if its not already set,