Skip to content

try to provide most recent copy of AW to enable fast deletion #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 10, 2023
Merged
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
16 changes: 13 additions & 3 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ func (qjm *XController) ScheduleNext() {
// the appwrapper from being added in syncjob
defer qjm.schedulingAWAtomicSet(nil)

scheduleNextRetrier := retrier.New(retrier.ExponentialBackoff(10, 100*time.Millisecond), &EtcdErrorClassifier{})
scheduleNextRetrier := retrier.New(retrier.ExponentialBackoff(1, 100*time.Millisecond), &EtcdErrorClassifier{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are doing this, I think you are better off removing the retry logic from here and using it only when updating etcd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, adding retry at the relevant spot is TDB.

scheduleNextRetrier.SetJitter(0.05)
// Retry the execution
err = scheduleNextRetrier.Run(func() error {
Expand Down Expand Up @@ -1018,7 +1018,8 @@ func (qjm *XController) ScheduleNext() {
retryErr = qjm.updateStatusInEtcd(ctx, qj, "ScheduleNext - setHOL")
if retryErr != nil {
if apierrors.IsConflict(retryErr) {
klog.Warningf("[ScheduleNext] Conflict error detected when updating status in etcd for app wrapper '%s/%s, status = %+v. Retrying update.", qj.Namespace, qj.Name, qj.Status)
klog.Warningf("[ScheduleNext] Conflict error detected when updating status in etcd for app wrapper '%s/%s, status = %+v this may be due to appwrapper deletion.", qj.Namespace, qj.Name, qj.Status)
return nil
} else {
klog.Errorf("[ScheduleNext] Failed to updated status in etcd for app wrapper '%s/%s', status = %+v, err=%v", qj.Namespace, qj.Name, qj.Status, retryErr)
}
Expand Down Expand Up @@ -1068,6 +1069,8 @@ func (qjm *XController) ScheduleNext() {
}
return retryErr
}
//Remove stale copy
qjm.eventQueue.Delete(qj)
if err00 := qjm.eventQueue.Add(qj); err00 != nil { // unsuccessful add to eventQueue, add back to activeQ
klog.Errorf("[ScheduleNext] [Dispatcher Mode] Fail to add %s to eventQueue, activeQ.Add_toSchedulingQueue &qj=%p Version=%s Status=%+v err=%#v", qj.Name, qj, qj.ResourceVersion, qj.Status, err)
qjm.qjqueue.MoveToActiveQueueIfExists(qj)
Expand Down Expand Up @@ -1224,6 +1227,8 @@ func (qjm *XController) ScheduleNext() {
}
tempAW.DeepCopyInto(qj)
// add to eventQueue for dispatching to Etcd
// Remove stale copy
qjm.eventQueue.Delete(qj)
if err00 := qjm.eventQueue.Add(qj); err00 != nil { // unsuccessful add to eventQueue, add back to activeQ
klog.Errorf("[ScheduleNext] [Agent Mode] Failed to add '%s/%s' to eventQueue, activeQ.Add_toSchedulingQueue &qj=%p Version=%s Status=%+v err=%#v", qj.Namespace,
qj.Name, qj, qj.ResourceVersion, qj.Status, err)
Expand Down Expand Up @@ -1587,7 +1592,11 @@ func (cc *XController) deleteQueueJob(obj interface{}) {
accessor.SetDeletionTimestamp(&current_ts)
}
klog.V(3).Infof("[Informer-deleteQJ] %s enqueue deletion, deletion ts = %v", qj.Name, qj.GetDeletionTimestamp())
cc.enqueue(qj)
//Remove stale copy
cc.eventQueue.Delete(qj)
cc.qjqueue.Delete(qj)
//Add fresh copy
cc.eventQueue.Add(qj)
}

func (cc *XController) enqueue(obj interface{}) error {
Expand Down Expand Up @@ -2146,6 +2155,7 @@ func (cc *XController) Cleanup(ctx context.Context, appwrapper *arbv1.AppWrapper
}
func (cc *XController) getAppWrapper(namespace string, name string, caller string) (*arbv1.AppWrapper, error) {
klog.V(5).Infof("[getAppWrapper] getting a copy of '%s/%s' when called by '%s'.", namespace, name, caller)

apiCacheAWJob, err := cc.appWrapperLister.AppWrappers(namespace).Get(name)
if err != nil {
if !apierrors.IsNotFound(err) {
Expand Down