@@ -1613,7 +1613,7 @@ func (cc *XController) addQueueJob(obj interface{}) {
16131613 qj .Name , time .Now ().Sub (qj .Status .ControllerFirstTimestamp .Time ).Seconds (), qj .CreationTimestamp , qj .Status .ControllerFirstTimestamp )
16141614
16151615 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+
16171617 // Requeue the item to be processed again in 30 seconds.
16181618 //TODO: tune the frequency of reprocessing an AW
16191619 hasCompletionStatus := false
@@ -1635,17 +1635,23 @@ func (cc *XController) addQueueJob(obj interface{}) {
16351635 go func () {
16361636 for {
16371637 time .Sleep (requeueInterval )
1638- latestAw , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
1638+ latestObj , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
16391639 if err != nil && ! exists {
16401640 klog .Warningf ("[Informer-addQJ] Recent copy of AW %s not found in cache" , qj .Name )
16411641 } 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 )
16441650 break //Exit the loop
16451651 }
16461652 // Enqueue the latest copy of the AW.
16471653 if (qj .Status .State != arbv1 .AppWrapperStateCompleted && qj .Status .State != arbv1 .AppWrapperStateFailed ) && hasCompletionStatus {
1648- cc .UpdateQueueJobs (latestAw .( * arbv1. AppWrapper ) )
1654+ cc .UpdateQueueJobs (latestAw )
16491655 klog .V (2 ).Infof ("[Informer-addQJ] requeing AW to determine completion status for AW" , qj .Name )
16501656 }
16511657
@@ -1665,23 +1671,30 @@ func (cc *XController) addQueueJob(obj interface{}) {
16651671 go func () {
16661672 for {
16671673 time .Sleep (requeueInterval )
1668- latestAw , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
1674+ latestObj , exists , err := cc .appwrapperInformer .Informer ().GetStore ().GetByKey (key )
16691675 if err != nil && ! exists {
16701676 klog .Warningf ("[Informer-addQJ] Recent copy of AW %s not found in cache" , qj .Name )
16711677 } 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 )
16741686 break //Exit the loop
16751687 }
16761688 // Enqueue the latest copy of the AW.
16771689 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 )
16791691 klog .V (2 ).Infof ("[Informer-addQJ] requeing AW to check minScheduling spec for AW" , qj .Name )
16801692 }
16811693 }
16821694 }
16831695 }()
16841696 }
1697+ cc .enqueue (qj )
16851698}
16861699
16871700func (cc * XController ) updateQueueJob (oldObj , newObj interface {}) {
0 commit comments