Skip to content

feat(cmd): Implemented a CLI for task management#4609

Merged
gulyasgergely902 merged 1 commit intoEricsson:masterfrom
bruntib:async_store_2
Sep 23, 2025
Merged

feat(cmd): Implemented a CLI for task management#4609
gulyasgergely902 merged 1 commit intoEricsson:masterfrom
bruntib:async_store_2

Conversation

@bruntib
Copy link
Copy Markdown
Contributor

@bruntib bruntib commented Jun 24, 2025

Important

⛔ Blocked by #4317.

This is patch 2 of the Asynchronous Store Protocol (#3672).

This patch extends CodeChecker cmd with a new sub-command, serverside-tasks, which lets users and administrators deal with querying the status of running server-side tasks.

By default, the CLI queries the information of the task(s) specified by their token(s) in the --token argument from the server using getTaskInfo(token), and shows this information in either verbose "plain text" (available if precisely one task was specified), "table" or JSON formats.

In addition to --token, it also supports 19 more parameters, each of which correspond to a filter option in the TaskFilter API type. If any filters in addition to --token is specified, it will exercise getTasks(filter) instead. This mode is only available to administrators. The resulting more detailed information structs are printed in "table" or JSON formats.

Apart from querying the current status, two additional flags are available, irrespective of which query method is used to obtain a list of "matching tasks" after filtering:

  • --kill will call cancelTask(token) for each task.
  • --await will block execution until the specified task(s) terminate (in one way or another).

--await is implemented by calling the new await_task_termination library function, which is implemented with the goal of being reusable by other clients later.

Example outputs

Query that results in using the filters by default shows table format

Tip

Notice the showing of Machine ID in the output, as this is a query run by an administrator.

❯ build/CodeChecker/bin/CodeChecker cmd serverside-tasks --enqueued-after 2024:08:19 --status cancelled
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Token                                                            | Machine            | Type                   | Summary                         | Status    | Product | User | Enqueued            | Started             | Last seen           | Completed           | Cancelled?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8b62497c7d1b7e3945445f5b9c3951d97ae07e58f97cad60a0187221e7d1e2ba | xxxxxxxxxxxxx:8001 | taskService::DummyTask | Dummy task for testing purposes | CANCELLED |         |      | 2024-08-19 15:55:34 | 2024-08-19 15:55:34 | 2024-08-19 15:55:35 | 2024-08-19 15:55:35 | Yes
6fa0097a9bd1799572c7ccd2afc0272684ed036c11145da7eaf40cc8a07c7241 | xxxxxxxxxxxxx:8001 | taskService::DummyTask | Dummy task for testing purposes | CANCELLED |         |      | 2024-08-19 15:55:53 | 2024-08-19 15:55:53 | 2024-08-19 15:55:53 | 2024-08-19 15:55:53 | Yes
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

User can modify the output format via the usual --output parameter

❯ build/CodeChecker/bin/CodeChecker cmd serverside-tasks --token 8b62497c7d1b7e3945445f5b9c3951d97ae07e58f97cad60a0187221e7d1e2ba --output json
[{"token": "8b62497c7d1b7e3945445f5b9c3951d97ae07e58f97cad60a0187221e7d1e2ba", "taskKind": "taskService::DummyTask", "actorUsername": null, "summary": "Dummy task for testing purposes", "comments": "<unknown> at 2024-08-19 15:55:34.887164+00:00:\nSUPERUSER requested cancellation.\n----------\nSYSTEM[AbstractTask::execute()] at 2024-08-19 15:55:35.881162+00:00:\nCANCEL!\nCancel request of admin honoured by task.", "cancelFlagSet": true, "enqueuedAt": "2024-08-19 15:55:34", "startedAt": "2024-08-19 15:55:34", "completedAt": "2024-08-19 15:55:35", "lastHeartbeat": "2024-08-19 15:55:35", "status": "CANCELLED", "productEndpoint": null}]

Default behaviour when searching for a specific task (identified by token)

Tip

Comments are formatted as if they were e-mails or chat messages for better visual separation.

Caution

This output is only meant to be consumed by humans!

❯ build/CodeChecker/bin/CodeChecker cmd serverside-tasks --token 8b62497c7d1b7e3945445f5b9c3951d97ae07e58f97cad60a0187221e7d1e2ba
Task '8b62497c7d1b7e3945445f5b9c3951d97ae07e58f97cad60a0187221e7d1e2ba':
    - Type:         taskService::DummyTask
    - Summary:      Dummy task for testing purposes
    - Status:       CANCELLED
    - Enqueued at:  2024-08-19 15:55:34
    - Started at:   2024-08-19 15:55:34
    - Last seen:    2024-08-19 15:55:35
    - Completed at: 2024-08-19 15:55:35
 
Comments on task '8b62497c7d1b7e3945445f5b9c3951d97ae07e58f97cad60a0187221e7d1e2ba'...
 
<unknown> at 2024-08-19 15:55:34.887164+00:00:
> SUPERUSER requested cancellation.
----------
SYSTEM[AbstractTask::execute()] at 2024-08-19 15:55:35.881162+00:00:
> CANCEL!
> Cancel request of admin honoured by task.

@bruntib bruntib added this to the release 6.27.0 milestone Jun 24, 2025
@bruntib bruntib requested a review from gulyasgergely902 June 24, 2025 15:14
@bruntib bruntib requested review from dkrupp and vodorok as code owners June 24, 2025 15:14
@bruntib bruntib changed the title Async store 2 feat(cmd): Implemented a CLI for task management Jun 24, 2025
@bruntib bruntib force-pushed the async_store_2 branch 2 times, most recently from 888ff22 to f74e6e6 Compare August 12, 2025 08:07
This patch extends `CodeChecker cmd` with a new sub-command,
`serverside-tasks`, which lets users and administrators deal with
querying the status of running server-side tasks.

By default, the CLI queries the information of the task(s) specified by
their token(s) in the `--token` argument from the server using
`getTaskInfo(token)`, and shows this information in either verbose
"plain text" (available if precisely **one** task was specified), "table"
or JSON formats.

In addition to `--token`, it also supports 19 more parameters, each of
which correspond to a filter option in the `TaskFilter` API type.
If any filters in addition to `--token` is specified, it will exercise
`getTasks(filter)` instead.
This mode is only available to administrators.
The resulting, more detailed information structs are printed in "table"
or JSON formats.

Apart from querying the current status, two additional flags are
available, irrespective of which query method is used to obtain a list
of "matching tasks":

  * `--kill` will call `cancelTask(token)` for each task.
  * `--await` will block execution until the specified task(s) terminate
    (in one way or another).

`--await` is implemented by calling the new **`await_task_termination`**
library function, which is implemented with the goal of being reusable
by other clients later.
@gulyasgergely902 gulyasgergely902 merged commit 46340ca into Ericsson:master Sep 23, 2025
8 of 9 checks passed
@bruntib bruntib deleted the async_store_2 branch September 23, 2025 13:44
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.

3 participants