-
Notifications
You must be signed in to change notification settings - Fork 63
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
refactor updatequeuejob thread logic in informer #624
Merged
openshift-merge-robot
merged 11 commits into
project-codeflare:main
from
asm582:rem_uqj_thrd
Sep 9, 2023
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eda97ac
remove preempt queue job thread
asm582 213e6bd
fix typo in comment
asm582 5947878
fix unit tests
asm582 1b2604d
add break condition
asm582 5e2dd28
do not requeue if AW does not exists
asm582 12109c0
merge
asm582 9135383
fix break condition
asm582 f20eda1
fix duplicate requeues
asm582 f821d18
address review
asm582 333b699
handle nil AW
asm582 43e2f6d
fix tests
asm582 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1613,7 +1613,7 @@ func (cc *XController) addQueueJob(obj interface{}) { | |
qj.Name, time.Now().Sub(qj.Status.ControllerFirstTimestamp.Time).Seconds(), qj.CreationTimestamp, qj.Status.ControllerFirstTimestamp) | ||
|
||
klog.V(6).Infof("[Informer-addQJ] enqueue %s &qj=%p Version=%s Status=%+v", qj.Name, qj, qj.ResourceVersion, qj.Status) | ||
cc.enqueue(qj) | ||
|
||
// Requeue the item to be processed again in 30 seconds. | ||
//TODO: tune the frequency of reprocessing an AW | ||
hasCompletionStatus := false | ||
|
@@ -1635,17 +1635,23 @@ func (cc *XController) addQueueJob(obj interface{}) { | |
go func() { | ||
for { | ||
time.Sleep(requeueInterval) | ||
latestAw, exists, err := cc.appwrapperInformer.Informer().GetStore().GetByKey(key) | ||
latestObj, exists, err := cc.appwrapperInformer.Informer().GetStore().GetByKey(key) | ||
if err != nil && !exists { | ||
klog.Warningf("[Informer-addQJ] Recent copy of AW %s not found in cache", qj.Name) | ||
} else { | ||
if latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateActive && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateEnqueued && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateRunningHoldCompletion { | ||
klog.V(2).Infof("[Informer-addQJ] Stopping requeue for AW %s with status %s", latestAw.(*arbv1.AppWrapper).Name, latestAw.(*arbv1.AppWrapper).Status.State) | ||
var latestAw *arbv1.AppWrapper | ||
if latestObj != nil { | ||
latestAw = latestObj.(*arbv1.AppWrapper) | ||
} else { | ||
latestAw = qj | ||
} | ||
if latestAw.Status.State != arbv1.AppWrapperStateActive && latestAw.Status.State != arbv1.AppWrapperStateEnqueued && latestAw.Status.State != arbv1.AppWrapperStateRunningHoldCompletion { | ||
klog.V(2).Infof("[Informer-addQJ] Stopping requeue for AW %s with status %s", latestAw.Name, latestAw.Status.State) | ||
break //Exit the loop | ||
} | ||
// Enqueue the latest copy of the AW. | ||
if (qj.Status.State != arbv1.AppWrapperStateCompleted && qj.Status.State != arbv1.AppWrapperStateFailed) && hasCompletionStatus { | ||
cc.UpdateQueueJobs(latestAw.(*arbv1.AppWrapper)) | ||
cc.UpdateQueueJobs(latestAw) | ||
klog.V(2).Infof("[Informer-addQJ] requeing AW to determine completion status for AW", qj.Name) | ||
} | ||
|
||
|
@@ -1665,23 +1671,30 @@ func (cc *XController) addQueueJob(obj interface{}) { | |
go func() { | ||
for { | ||
time.Sleep(requeueInterval) | ||
latestAw, exists, err := cc.appwrapperInformer.Informer().GetStore().GetByKey(key) | ||
latestObj, exists, err := cc.appwrapperInformer.Informer().GetStore().GetByKey(key) | ||
if err != nil && !exists { | ||
klog.Warningf("[Informer-addQJ] Recent copy of AW %s not found in cache", qj.Name) | ||
} else { | ||
if latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateActive && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateEnqueued && latestAw.(*arbv1.AppWrapper).Status.State != arbv1.AppWrapperStateRunningHoldCompletion { | ||
klog.V(2).Infof("[Informer-addQJ] Stopping requeue for AW %s with status %s", latestAw.(*arbv1.AppWrapper).Name, latestAw.(*arbv1.AppWrapper).Status.State) | ||
var latestAw *arbv1.AppWrapper | ||
if latestObj != nil { | ||
latestAw = latestObj.(*arbv1.AppWrapper) | ||
} else { | ||
latestAw = qj | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder what happens here to |
||
} | ||
if latestAw.Status.State != arbv1.AppWrapperStateActive && latestAw.Status.State != arbv1.AppWrapperStateEnqueued && latestAw.Status.State != arbv1.AppWrapperStateRunningHoldCompletion { | ||
klog.V(2).Infof("[Informer-addQJ] Stopping requeue for AW %s with status %s", latestAw.Name, latestAw.Status.State) | ||
break //Exit the loop | ||
} | ||
// Enqueue the latest copy of the AW. | ||
if (qj.Status.State != arbv1.AppWrapperStateCompleted && qj.Status.State != arbv1.AppWrapperStateFailed) && (qj.Spec.SchedSpec.MinAvailable > 0) { | ||
cc.PreemptQueueJobs(latestAw.(*arbv1.AppWrapper)) | ||
cc.PreemptQueueJobs(latestAw) | ||
klog.V(2).Infof("[Informer-addQJ] requeing AW to check minScheduling spec for AW", qj.Name) | ||
} | ||
} | ||
} | ||
}() | ||
} | ||
cc.enqueue(qj) | ||
} | ||
|
||
func (cc *XController) updateQueueJob(oldObj, newObj interface{}) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.AfterFunc
seems a better construct to use here rather thango func() + time.Sleep
.On a side node, it seems it'll be valuable to move to used a delaying queue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to wake the thread up every so often, from what I understand time.AfterFunc would wake up only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, maybe requeuing within the function passed to
time.AfterFunc
(possibly callingtime.AfterFunc
)?