Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix to update conditions in backoff.
Signed-off-by: Diana Arroyo <darroyo@us.ibm.com>
  • Loading branch information
dmatch01 committed Nov 16, 2020
commit f17c7fd29f5848b543273fbc0a026f2e55f57e21
50 changes: 35 additions & 15 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,21 +803,41 @@ func (cc *XController) updateEtcd(qj *arbv1.AppWrapper, at string) error {
}

func (qjm *XController) backoff(q *arbv1.AppWrapper, reason string, message string) {
q.Status.QueueJobState = arbv1.AppWrapperCondBackoff
cond := GenerateAppWrapperCondition(arbv1.AppWrapperCondBackoff, v1.ConditionTrue, reason, message)
q.Status.Conditions = append(q.Status.Conditions, cond)
q.Status.FilterIgnore = true // update QueueJobState only, no work needed
qjm.updateEtcd(q, "[backoff]Rejoining")
qjm.qjqueue.AddUnschedulableIfNotPresent(q)
glog.V(3).Infof("[backoff] %s move to unschedulableQ before sleep for %d seconds. activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v", q.Name, qjm.serverOption.BackoffTime, qjm.qjqueue.IfExistActiveQ((q)), qjm.qjqueue.IfExistUnschedulableQ((q)), q, q.ResourceVersion, q.Status)
time.Sleep(time.Duration(qjm.serverOption.BackoffTime) * time.Second)
qjm.qjqueue.MoveToActiveQueueIfExists(q)
q.Status.QueueJobState = arbv1.AppWrapperCondQueueing
returnCond := GenerateAppWrapperCondition(arbv1.AppWrapperCondQueueing, v1.ConditionTrue, "BackoffTimerExpired.", "")
q.Status.Conditions = append(q.Status.Conditions, returnCond)
q.Status.FilterIgnore = true // update QueueJobState only, no work needed
qjm.updateEtcd(q, "[backoff] Queueing")
glog.V(3).Infof("[backoff] %s activeQ.Add after sleep for %d seconds. activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v", q.Name, qjm.serverOption.BackoffTime, qjm.qjqueue.IfExistActiveQ((q)), qjm.qjqueue.IfExistUnschedulableQ((q)), q, q.ResourceVersion, q.Status)
var workingAW *arbv1.AppWrapper
apiCacheAWJob, e := qjm.queueJobLister.AppWrappers(q.Namespace).Get(q.Name)
// Update condition
if (e == nil) {
workingAW = apiCacheAWJob
apiCacheAWJob.Status.QueueJobState = arbv1.AppWrapperCondBackoff
cond := GenerateAppWrapperCondition(arbv1.AppWrapperCondBackoff, v1.ConditionTrue, reason, message)
workingAW.Status.Conditions = append(workingAW.Status.Conditions, cond)
workingAW.Status.FilterIgnore = true // update QueueJobState only, no work needed
qjm.updateEtcd(workingAW, "backoff - Rejoining")
} else {
workingAW = q
glog.Errorf("[backoff] Failed to retrieve cached object for %s/%s. Continuing with possible stale object without updating conditions.", workingAW.Namespace,workingAW.Name)
}
qjm.qjqueue.AddUnschedulableIfNotPresent(workingAW)
glog.V(3).Infof("[backoff] %s move to unschedulableQ before sleep for %d seconds. activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v", workingAW.Name,
qjm.serverOption.BackoffTime, qjm.qjqueue.IfExistActiveQ((workingAW)), qjm.qjqueue.IfExistUnschedulableQ((workingAW)), workingAW, workingAW.ResourceVersion, workingAW.Status)
time.Sleep(time.Duration(qjm.serverOption.BackoffTime) * time.Second)
qjm.qjqueue.MoveToActiveQueueIfExists(workingAW)

// Update condition after backoff
apiCacheAWJob, e = qjm.queueJobLister.AppWrappers(q.Namespace).Get(q.Name)
if (e == nil) {
workingAW = apiCacheAWJob
workingAW.Status.QueueJobState = arbv1.AppWrapperCondQueueing
returnCond := GenerateAppWrapperCondition(arbv1.AppWrapperCondQueueing, v1.ConditionTrue, "BackoffTimerExpired.", "")
workingAW.Status.Conditions = append(workingAW.Status.Conditions, returnCond)
workingAW.Status.FilterIgnore = true // update QueueJobState only, no work needed
qjm.updateEtcd(workingAW, "backoff - Queueing")
}
glog.V(3).Infof("[backoff] %s activeQ.Add after sleep for %d seconds. activeQ=%t Unsched=%t &aw=%p Version=%s Status=%+v", workingAW.Name,
qjm.serverOption.BackoffTime, qjm.qjqueue.IfExistActiveQ((workingAW)), qjm.qjqueue.IfExistUnschedulableQ((workingAW)), workingAW, workingAW.ResourceVersion, workingAW.Status)
}

// Run start AppWrapper Controller
}

// Run start AppWrapper Controller
Expand Down