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

cf tasks <app_name> returns all tasks which is problematic at scale #3274

Open
4 tasks done
Samze opened this issue Oct 31, 2024 · 0 comments
Open
4 tasks done

cf tasks <app_name> returns all tasks which is problematic at scale #3274

Samze opened this issue Oct 31, 2024 · 0 comments

Comments

@Samze
Copy link
Contributor

Samze commented Oct 31, 2024

Please fill out the issue checklist below and provide ALL the requested information.

  • I reviewed open and closed github issues that may be related to my problem.
  • I tried updating to the latest version of the CF CLI to see if it fixed my problem.
  • I attempted to run the command with CF_TRACE=1 to help debug the issue.
  • I am reporting a bug that others will be able to reproduce.

Describe the bug and the command you saw an issue with

Tasks allow you to run one-off commands on an app. Below is an example workflow in the CLI:

  1. Trigger the task
cf run-task app -c <my-command>
Creating task for app static1 in org org-1 / space space-1 as admin...
Task has been submitted successfully for execution.
OK

task name:   b0a3bce1
task id:     1309
OK
  1. Obtain result of task to see if it was it successful or not.
cf tasks static1
...
17     c25fabef   SUCCEEDED   Wed, 30 Oct 2024 16:42:01 UTC   ls
16     c76d2713   SUCCEEDED   Wed, 30 Oct 2024 16:42:01 UTC   ls
15     556f415b   SUCCEEDED   Wed, 30 Oct 2024 16:42:00 UTC   ls
14     c50052eb   SUCCEEDED   Wed, 30 Oct 2024 16:42:00 UTC   ls
13     9afdc979   SUCCEEDED   Wed, 30 Oct 2024 16:41:59 UTC   ls
12     9c52c14c   SUCCEEDED   Wed, 30 Oct 2024 16:41:48 UTC   ls
11     70d94489   SUCCEEDED   Wed, 30 Oct 2024 16:41:47 UTC   ls
10     4e24e204   SUCCEEDED   Wed, 30 Oct 2024 16:41:46 UTC   ls
9      afd1c3cc   SUCCEEDED   Wed, 30 Oct 2024 16:41:46 UTC   ls
8      2344f470   SUCCEEDED   Wed, 30 Oct 2024 16:41:45 UTC   ls
7      e6e83064   SUCCEEDED   Wed, 30 Oct 2024 16:41:45 UTC   ls
6      fdd65417   SUCCEEDED   Wed, 30 Oct 2024 16:41:44 UTC   ls
5      78af57a5   SUCCEEDED   Wed, 30 Oct 2024 16:41:43 UTC   ls
4      9ea642a8   SUCCEEDED   Wed, 30 Oct 2024 16:41:43 UTC   ls
3      e21a1c61   SUCCEEDED   Wed, 30 Oct 2024 16:41:42 UTC   ls
2      b94fe1ee   SUCCEEDED   Wed, 30 Oct 2024 16:41:35 UTC   ls
1      7788d026   SUCCEEDED   Wed, 30 Oct 2024 16:41:08 UTC   ls

What happened
Behind the scenes the cf cli fetches all tasks for an app. It does this without specifying the page size, so uses the default CAPI page size which is 50. See actor and api client. The result of this is that the CLI may make hundreds of calls. This causes lots of pressure on the CC API and causes the cf tasks <app> command to appear as though its hanging while its making all of these requests. When it eventually completes it will display all of results to the user making the command not very helpful once you get beyond ~50 or so results.

Cloud Controller does prune completed tasks every 31 days by default. However, even with this it is not unusual for periodic tasks to run and there to be thousands of tasks per app on large CF installations.

Expected behavior
cf tasks should not get all tasks by default

Theres a few things we could do here, in no particular order.

  1. Increase the page size of cf tasks to make fewer requests.
  2. Make cf tasks <app> return a sensible human readable number of results (e.g. 50) and introduce a --all flag for users who really want to see everything.
  3. Allow more flags to cf tasks <app> to return a sensible human readable number of results. For example --recent or --limit=50 so that it can be more efficient.
  4. Add a new cf get-task <id> command so that you can look up the result of an individual task rather than having to list all of them.

Exact Steps To Reproduce
Steps to reproduce the behavior; include the exact CLI commands and verbose output:

  1. Run cf run-task app -c <my-command> 1000 times.
  2. Run cf tasks app -v
  3. See pagination results, slowness and large result set.
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

No branches or pull requests

1 participant