Skip to content

Commit bb5f3b1

Browse files
asm582openshift-merge-robot
authored andcommitted
fix duplicate requeues
1 parent 0aa05f3 commit bb5f3b1

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

Diff for: pkg/controller/queuejob/queuejob_controller_ex.go

+34-34
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,40 @@ func (cc *XController) addQueueJob(obj interface{}) {
16421642

16431643
klog.V(6).Infof("[Informer-addQJ] enqueue %s &qj=%p Version=%s Status=%+v", qj.Name, qj, qj.ResourceVersion, qj.Status)
16441644
cc.enqueue(qj)
1645+
// Requeue the item to be processed again in 30 seconds.
1646+
//TODO: tune the frequency of reprocessing an AW
1647+
hasCompletionStatus := false
1648+
for _, genericItem := range qj.Spec.AggrResources.GenericItems {
1649+
if len(genericItem.CompletionStatus) > 0 {
1650+
hasCompletionStatus = true
1651+
}
1652+
}
1653+
//When an AW entrs a system with completionstatus keep checking the AW until completed
1654+
//updatequeuejobs now runs as a part of informer machinery. optimization here is to not use etcd to pullout submitted AWs and operate
1655+
//on stale AWs. This has potential to improve performance at scale.
1656+
//if qj.Status.State != arbv1.AppWrapperStateCompleted && qj.Status.State != arbv1.AppWrapperStateFailed && qj.Status.State != "" {
1657+
requeueInterval := 30 * time.Second
1658+
key, err := cache.MetaNamespaceKeyFunc(qj)
1659+
if err == nil {
1660+
go func() {
1661+
for {
1662+
time.Sleep(requeueInterval)
1663+
latestAw, exists, err := cc.appwrapperInformer.Informer().GetStore().GetByKey(key)
1664+
if latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateActive && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateEnqueued && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateRunningHoldCompletion {
1665+
klog.V(2).Infof("[Informer-addQJ] Stopping requeue for AW %s with status %s", latestAw.(*arbv1.AppWrapper).Name, latestAw.(*arbv1.AppWrapper).Status.State)
1666+
break //Exit the loop
1667+
}
1668+
if err == nil && exists {
1669+
// Enqueue the latest copy of the AW.
1670+
if (qj.Status.State != arbv1.AppWrapperStateCompleted && qj.Status.State != arbv1.AppWrapperStateFailed) && hasCompletionStatus {
1671+
cc.UpdateQueueJobs(latestAw.(*arbv1.AppWrapper))
1672+
klog.V(2).Infof("[Informer-addQJ] Finished requeing AW to determine completion status")
1673+
}
1674+
}
1675+
}
1676+
}()
1677+
}
1678+
//}
16451679
}
16461680

16471681
func (cc *XController) updateQueueJob(oldObj, newObj interface{}) {
@@ -1685,40 +1719,6 @@ func (cc *XController) updateQueueJob(oldObj, newObj interface{}) {
16851719
// cc.eventQueue.Delete(oldObj)
16861720
if notBackedoff {
16871721
cc.enqueue(newQJ)
1688-
1689-
// Requeue the item to be processed again in 30 seconds.
1690-
//TODO: tune the frequency of reprocessing an AW
1691-
hasCompletionStatus := false
1692-
for _, genericItem := range newQJ.Spec.AggrResources.GenericItems {
1693-
if len(genericItem.CompletionStatus) > 0 {
1694-
hasCompletionStatus = true
1695-
}
1696-
}
1697-
//updatequeuejobs now runs as a part of informer machinery. optimization here is to not use etcd to pullout submitted AWs and operate
1698-
//on stale AWs. This has potential to improve performance at scale.
1699-
if newQJ.Status.State != arbv1.AppWrapperStateCompleted && newQJ.Status.State != arbv1.AppWrapperStateFailed && newQJ.Status.State != "" {
1700-
requeueInterval := 30 * time.Second
1701-
key, err := cache.MetaNamespaceKeyFunc(newQJ)
1702-
if err == nil {
1703-
go func() {
1704-
for {
1705-
time.Sleep(requeueInterval)
1706-
latestAw, exists, err := cc.appwrapperInformer.Informer().GetStore().GetByKey(key)
1707-
if latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateActive && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateEnqueued && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateRunningHoldCompletion || !exists {
1708-
klog.V(2).Infof("[Informer-updateQJ] Stopping requeue for AW %s with status %s", latestAw.(*arbv1.AppWrapper).Name, latestAw.(*arbv1.AppWrapper).Status.State)
1709-
break //Exit the loop
1710-
}
1711-
if err == nil && exists {
1712-
// Enqueue the latest copy of the AW.
1713-
if (newQJ.Status.State != arbv1.AppWrapperStateCompleted && newQJ.Status.State != arbv1.AppWrapperStateFailed) && hasCompletionStatus {
1714-
cc.UpdateQueueJobs(latestAw.(*arbv1.AppWrapper))
1715-
klog.V(2).Infof("[Informer-updateQJ] Finished requeing AW to determine completion status")
1716-
}
1717-
}
1718-
}
1719-
}()
1720-
}
1721-
}
17221722
}
17231723

17241724
}

0 commit comments

Comments
 (0)