@@ -1613,6 +1613,12 @@ func larger(a, b string) bool {
16131613 return a > b // Equal length, lexicographic order
16141614}
16151615
1616+ //When an AW is deleted, do not add such AWs to the event queue.
1617+ //AW can never be brought back when it is deleted by external client, so do not bother adding it to event queue.
1618+ //There will be a scenario, where an AW is in middle to dispatch and it is deleted. at that point when such an
1619+ //AW is added to etcd a conflict error will be raised. This is cause the current AW to be skipped.
1620+ //If there are large number of delete's will informer miss few delete events is under question for this simplification.
1621+ //For 1K AW all of them are delete from the system, and the next resubmitted AW begins processing after in less than 2 mins
16161622func (cc * XController ) deleteQueueJob (obj interface {}) {
16171623 qj , ok := obj .(* arbv1.AppWrapper )
16181624 if ! ok {
@@ -1628,12 +1634,22 @@ func (cc *XController) deleteQueueJob(obj interface{}) {
16281634 } else {
16291635 accessor .SetDeletionTimestamp (& current_ts )
16301636 }
1631- klog .V (3 ).Infof ("[Informer-deleteQJ] %s enqueue deletion, deletion ts = %v" , qj .Name , qj .GetDeletionTimestamp ())
1632- //Remove stale copy
1633- cc .eventQueue .Delete (qj )
1634- cc .qjqueue .Delete (qj )
1635- //Add fresh copy
1636- cc .eventQueue .Add (qj )
1637+ // validate that app wraper has not been marked for deletion by the infomer's delete handler
1638+ if qj .DeletionTimestamp != nil {
1639+ klog .V (3 ).Infof ("[Informer-deleteQJ] AW job=%s/%s set for deletion." , qj .Namespace , qj .Name )
1640+ // cleanup resources for running job, ignoring errors
1641+ if err00 := cc .Cleanup (context .Background (), qj ); err00 != nil {
1642+ klog .Warningf ("Failed to cleanup resources for app wrapper '%s/%s', err = %v" , qj .Namespace , qj .Name , err00 )
1643+ }
1644+ // empty finalizers and delete the queuejob again
1645+ if accessor , err00 := meta .Accessor (qj ); err00 == nil {
1646+ accessor .SetFinalizers (nil )
1647+ }
1648+ // we delete the job from the queue if it is there, ignoring errors
1649+ cc .qjqueue .Delete (qj )
1650+ cc .eventQueue .Delete (qj )
1651+ klog .V (3 ).Infof ("[Informer-deleteQJ] AW job=%s/%s deleted." , qj .Namespace , qj .Name )
1652+ }
16371653}
16381654
16391655func (cc * XController ) enqueue (obj interface {}) error {
@@ -1767,22 +1783,6 @@ func (cc *XController) worker() {
17671783}
17681784
17691785func (cc * XController ) syncQueueJob (ctx context.Context , qj * arbv1.AppWrapper ) error {
1770- // validate that app wraper has not been marked for deletion by the infomer's delete handler
1771- if qj .DeletionTimestamp != nil {
1772- klog .V (3 ).Infof ("[syncQueueJob] AW job=%s/%s set for deletion." , qj .Namespace , qj .Name )
1773- // cleanup resources for running job, ignoring errors
1774- if err00 := cc .Cleanup (ctx , qj ); err00 != nil {
1775- klog .Warningf ("Failed to cleanup resources for app wrapper '%s/%s', err = %v" , qj .Namespace , qj .Name , err00 )
1776- }
1777- // empty finalizers and delete the queuejob again
1778- if accessor , err00 := meta .Accessor (qj ); err00 == nil {
1779- accessor .SetFinalizers (nil )
1780- }
1781- // we delete the job from the queue if it is there, ignoring errors
1782- cc .qjqueue .Delete (qj )
1783- klog .V (3 ).Infof ("[syncQueueJob] AW job=%s/%s deleted." , qj .Namespace , qj .Name )
1784- return nil
1785- }
17861786 cacheAWJob , err := cc .getAppWrapper (qj .Namespace , qj .Name , "[syncQueueJob] get fresh appwrapper " )
17871787 if err != nil {
17881788 if apierrors .IsNotFound (err ) {
0 commit comments