Skip to content
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
merged 11 commits into from
Sep 9, 2023

Conversation

asm582
Copy link
Member

@asm582 asm582 commented Sep 7, 2023

Issue link

#602

What changes have been made

Removed independent updatequeuejob thread that looped through all the AWs in etcd to determine completion status and update pod count. the fix adds updatequeuejob logic to the informer's machinery which has promise to improve MCADs updatestatus performance at scale.

Verification steps

I have verified that the fix works manually.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • Testing is not required for this change

pkg/controller/queuejob/queuejob_controller_ex.go Outdated Show resolved Hide resolved
pkg/controller/queuejob/queuejob_controller_ex.go Outdated Show resolved Hide resolved
pkg/controller/queuejob/queuejob_controller_ex.go Outdated Show resolved Hide resolved
requeueInterval := 30 * time.Second
key, err := cache.MetaNamespaceKeyFunc(qj)
if err == nil {
go func() {
Copy link
Contributor

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 than go func() + time.Sleep.

On a side node, it seems it'll be valuable to move to used a delaying queue.

Copy link
Member Author

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.

Copy link
Contributor

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 calling time.AfterFunc)?

pkg/controller/queuejob/queuejob_controller_ex.go Outdated Show resolved Hide resolved
if latestObj != nil {
latestAw = latestObj.(*arbv1.AppWrapper)
} else {
latestAw = qj
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder what happens here to qj when we leave the scope of this function. This seems really dangerous. This for loop is going to keep retrying qj outside of addQueueJob since it is a thread. Does it retain a copy of qj? I'm not saying we should change it, I'm just concerned.

Copy link
Collaborator

@metalcycling metalcycling left a comment

Choose a reason for hiding this comment

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

I don't know if you are planning to change the for+sleep logic, but if not I'm OK with merging this PR. LGTM.

@openshift-ci
Copy link

openshift-ci bot commented Sep 9, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: metalcycling

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Sep 9, 2023
@openshift-merge-robot openshift-merge-robot merged commit 203e938 into project-codeflare:main Sep 9, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants