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

[v8] Make retrieval of tasks in bulk instead of small increments #3276

Merged

Conversation

joaopapereira
Copy link
Contributor

@joaopapereira joaopapereira commented Nov 1, 2024

Description of the Change

In this PR we change the way tasks are retrieved in CLI to lower the load that it currently has in CAPI when there are a big number of tasks associated with a particular application

Related to #3274

@@ -69,3 +64,25 @@ func (requester RealRequester) wrapFirstPage(request *cloudcontroller.Request, o

return wrapper, warnings, nil
}

func (requester RealRequester) bulkRetrieval(request *cloudcontroller.Request, obj interface{}, appendToExternalList func(interface{}) error) (IncludedResources, Warnings, error) {
Copy link
Contributor

@Samze Samze Nov 4, 2024

Choose a reason for hiding this comment

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

question Do we need this at all? Can we just do

query := []ccv3.Query{{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}}

and pass it through here and use the existing pagination methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could but I am trying to make it more generic and only apply to the commands that we want

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm probably not understanding, what is the difference here between the new bulkRetrieval function and and an specific actor setting MaxPerPage like here and calling the existing paginate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I see what you mean.
In the end, I do not have a strong preference here it felt more natural to abstract this into the requests than to have this logic scattered around every action, but I also see the argument of reusability of the paginate function, specially because of the strange interface of that function that ignores outputs of the requests......

If you want I can make the change as you mentioned.

- Fix issue, where code was always doing 2 requests even when it was
  able to get all the tasks in the first request

Signed-off-by: João Pereira <[email protected]>
Signed-off-by: João Pereira <[email protected]>
@@ -12,3 +12,14 @@ type IncludedResources struct {
ServicePlans []resources.ServicePlan `json:"service_plans,omitempty"`
Apps []resources.Application `json:"apps,omitempty"`
}

Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion Perhaps including a small test result showing the difference in time for cf tasks between the old and new behaviour would be useful? Maybe with an app with like 10,000 tasks?

gururajsh
gururajsh previously approved these changes Nov 6, 2024
Copy link
Member

@gururajsh gururajsh left a comment

Choose a reason for hiding this comment

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

LGTM. I see both yours and Sam's point here. I'm ok either way.

Copy link
Member

@gururajsh gururajsh left a comment

Choose a reason for hiding this comment

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

LGTM

@joaopapereira joaopapereira merged commit 0845499 into cloudfoundry:v8 Nov 6, 2024
20 checks passed
@joaopapereira joaopapereira deleted the bulk-retrieval-of-tasks-v8 branch November 6, 2024 22:38
Copy link
Member

@a-b a-b left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants