@@ -1613,7 +1613,7 @@ func (cc *XController) addQueueJob(obj interface{}) {
1613
1613
qj .Name , time .Now ().Sub (qj .Status .ControllerFirstTimestamp .Time ).Seconds (), qj .CreationTimestamp , qj .Status .ControllerFirstTimestamp )
1614
1614
1615
1615
klog .V (6 ).Infof ("[Informer-addQJ] enqueue %s &qj=%p Version=%s Status=%+v" , qj .Name , qj , qj .ResourceVersion , qj .Status )
1616
- cc . enqueue ( qj )
1616
+
1617
1617
// Requeue the item to be processed again in 30 seconds.
1618
1618
//TODO: tune the frequency of reprocessing an AW
1619
1619
hasCompletionStatus := false
@@ -1635,17 +1635,23 @@ func (cc *XController) addQueueJob(obj interface{}) {
1635
1635
go func () {
1636
1636
for {
1637
1637
time .Sleep (requeueInterval )
1638
- latestAw , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
1638
+ latestObj , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
1639
1639
if err != nil && ! exists {
1640
1640
klog .Warningf ("[Informer-addQJ] Recent copy of AW %s not found in cache" , qj .Name )
1641
1641
} else {
1642
- if latestAw .(* arbv1.AppWrapper ).Status .State != arbv1 .AppWrapperStateActive && latestAw .(* arbv1.AppWrapper ).Status .State != arbv1 .AppWrapperStateEnqueued && latestAw .(* arbv1.AppWrapper ).Status .State != arbv1 .AppWrapperStateRunningHoldCompletion {
1643
- klog .V (2 ).Infof ("[Informer-addQJ] Stopping requeue for AW %s with status %s" , latestAw .(* arbv1.AppWrapper ).Name , latestAw .(* arbv1.AppWrapper ).Status .State )
1642
+ var latestAw * arbv1.AppWrapper
1643
+ if latestObj != nil {
1644
+ latestAw = latestObj .(* arbv1.AppWrapper )
1645
+ } else {
1646
+ latestAw = qj
1647
+ }
1648
+ if latestAw .Status .State != arbv1 .AppWrapperStateActive && latestAw .Status .State != arbv1 .AppWrapperStateEnqueued && latestAw .Status .State != arbv1 .AppWrapperStateRunningHoldCompletion {
1649
+ klog .V (2 ).Infof ("[Informer-addQJ] Stopping requeue for AW %s with status %s" , latestAw .Name , latestAw .Status .State )
1644
1650
break //Exit the loop
1645
1651
}
1646
1652
// Enqueue the latest copy of the AW.
1647
1653
if (qj .Status .State != arbv1 .AppWrapperStateCompleted && qj .Status .State != arbv1 .AppWrapperStateFailed ) && hasCompletionStatus {
1648
- cc .UpdateQueueJobs (latestAw .( * arbv1. AppWrapper ) )
1654
+ cc .UpdateQueueJobs (latestAw )
1649
1655
klog .V (2 ).Infof ("[Informer-addQJ] requeing AW to determine completion status for AW" , qj .Name )
1650
1656
}
1651
1657
@@ -1665,23 +1671,30 @@ func (cc *XController) addQueueJob(obj interface{}) {
1665
1671
go func () {
1666
1672
for {
1667
1673
time .Sleep (requeueInterval )
1668
- latestAw , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
1674
+ latestObj , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
1669
1675
if err != nil && ! exists {
1670
1676
klog .Warningf ("[Informer-addQJ] Recent copy of AW %s not found in cache" , qj .Name )
1671
1677
} else {
1672
- if latestAw .(* arbv1.AppWrapper ).Status .State != arbv1 .AppWrapperStateActive && latestAw .(* arbv1.AppWrapper ).Status .State != arbv1 .AppWrapperStateEnqueued && latestAw .(* arbv1.AppWrapper ).Status .State != arbv1 .AppWrapperStateRunningHoldCompletion {
1673
- klog .V (2 ).Infof ("[Informer-addQJ] Stopping requeue for AW %s with status %s" , latestAw .(* arbv1.AppWrapper ).Name , latestAw .(* arbv1.AppWrapper ).Status .State )
1678
+ var latestAw * arbv1.AppWrapper
1679
+ if latestObj != nil {
1680
+ latestAw = latestObj .(* arbv1.AppWrapper )
1681
+ } else {
1682
+ latestAw = qj
1683
+ }
1684
+ if latestAw .Status .State != arbv1 .AppWrapperStateActive && latestAw .Status .State != arbv1 .AppWrapperStateEnqueued && latestAw .Status .State != arbv1 .AppWrapperStateRunningHoldCompletion {
1685
+ klog .V (2 ).Infof ("[Informer-addQJ] Stopping requeue for AW %s with status %s" , latestAw .Name , latestAw .Status .State )
1674
1686
break //Exit the loop
1675
1687
}
1676
1688
// Enqueue the latest copy of the AW.
1677
1689
if (qj .Status .State != arbv1 .AppWrapperStateCompleted && qj .Status .State != arbv1 .AppWrapperStateFailed ) && (qj .Spec .SchedSpec .MinAvailable > 0 ) {
1678
- cc .PreemptQueueJobs (latestAw .( * arbv1. AppWrapper ) )
1690
+ cc .PreemptQueueJobs (latestAw )
1679
1691
klog .V (2 ).Infof ("[Informer-addQJ] requeing AW to check minScheduling spec for AW" , qj .Name )
1680
1692
}
1681
1693
}
1682
1694
}
1683
1695
}()
1684
1696
}
1697
+ cc .enqueue (qj )
1685
1698
}
1686
1699
1687
1700
func (cc * XController ) updateQueueJob (oldObj , newObj interface {}) {
0 commit comments