Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper) error {
// Call Resource Controller of ar.Type to issue REST call to Etcd for resource creation
err00 := cc.qjobResControls[ar.Type].SyncQueueJob(qj, &ar)
if err00 != nil {
dispatchFailureMessage = fmt.Sprintf("Failed to create item: %s/%s", qj.Namespace, qj.Name)
dispatchFailureMessage = fmt.Sprintf("%s/%s creation failure: %+v", qj.Namespace, qj.Name, err00)
glog.V(3).Infof("[worker-manageQJ] Error dispatching job=%s type=%v Status=%+v err=%+v", qj.Name, ar.Type, qj.Status, err00)
dispatched = false
break
Expand All @@ -1252,7 +1252,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper) error {
glog.V(10).Infof("[worker-manageQJ] before dispatch Generic.SyncQueueJob %s &qj=%p Version=%s Status=%+v", qj.Name, qj, qj.ResourceVersion, qj.Status)
_, err00 := cc.genericresources.SyncQueueJob(qj, &ar)
if err00 != nil {
dispatchFailureMessage = fmt.Sprintf("Failed to create generic item: %s/%s", qj.Namespace, qj.Name)
dispatchFailureMessage = fmt.Sprintf("%s/%s creation failure: %+v", qj.Namespace, qj.Name, err00)
glog.Errorf("[worker-manageQJ] Error dispatching job=%s Status=%+v err=%+v", qj.Name, qj.Status, err00)
dispatched = false
}
Expand All @@ -1268,8 +1268,10 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper) error {
} else {
qj.Status.State = arbv1.AppWrapperStateFailed
qj.Status.QueueJobState = arbv1.AppWrapperCondFailed
cond := GenerateAppWrapperCondition(arbv1.AppWrapperCondFailed, v1.ConditionTrue, dispatchFailureReason, dispatchFailureMessage)
qj.Status.Conditions = append(qj.Status.Conditions, cond)
if ( !isLastConditionDuplicate(qj,arbv1.AppWrapperCondFailed, v1.ConditionTrue, dispatchFailureReason, dispatchFailureMessage) ) {
cond := GenerateAppWrapperCondition(arbv1.AppWrapperCondFailed, v1.ConditionTrue, dispatchFailureReason, dispatchFailureMessage)
qj.Status.Conditions = append(qj.Status.Conditions, cond)
}
cc.Cleanup(qj)
}

Expand Down
22 changes: 22 additions & 0 deletions pkg/controller/queuejob/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,25 @@ func GenerateAppWrapperCondition(condType arbv1.AppWrapperConditionType, condSta
}
}

// AppWrapperCondition returns condition of a AppWrapper condition.
func isLastConditionDuplicate(aw *arbv1.AppWrapper, condType arbv1.AppWrapperConditionType, condStatus corev1.ConditionStatus, condReason string, condMsg string) bool {
if (aw.Status.Conditions == nil) {
return false
}

lastIndex := len(aw.Status.Conditions) - 1

if (lastIndex < 0) {
return false
}

lastCond := aw.Status.Conditions[lastIndex]
if (lastCond.Type == condType) &&
(lastCond.Status == condStatus) &&
(lastCond.Reason == condReason) &&
(lastCond.Message == condMsg) {
return true
} else {
return false
}
}