Add pagination support for listing VM events (#386)

* Add pagination support for listing VM events

Introduced a paginated event listing API, added support for pagination parameters in the request, and included cursor-based navigation using headers. Relevant tests and Badger store implementations were updated to support the new logic.

* Remove support for ordering VM events

Dropped `ListOrder` type, `order` query parameter, and related logic for ordering VM events. Updated tests, API schema, and Badger store to reflect the removal.

* Remove invalid VM events ordering test

Deleted a test case for invalid VM events ordering since the `order` query parameter and related functionality have been removed.

* Add support for ordering VM events

Implemented `order` query parameter for specifying sort order (ascending/descending) of VM events. Updated API schema, Badger store, and added related tests.

* Add support for limiting and ordering VM logs

Introduced `--limit` and `--order` flags for controlling the number of log lines and their sort order (ascending/descending). Updated API client to handle new options.

* Update internal/controller/store/badger/badger_events.go

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>

* fix: address PR review feedback

- switch logs CLI to --tail with desc ordering
- reuse ParseLogsOrder in controller with helpful errors
- always use ListEventsPage and scope event cursors
- move events pagination coverage to integration test

🤖 Generated with [Codex](https://chatgpt.com/codex)

Co-Authored-By: Codex <codex@openai.com>

* refactor: simplify prefix trimming and improve error formatting

- Replaced manual prefix check with `bytes.TrimPrefix` in Badger store.
- Enhanced error message formatting in VM logs controller.

* fix: address PR review feedback

- use suggested reverse seek in badger events pagination
- add events pagination client helper and use it in integration test

🤖 Generated with [Codex](https://chatgpt.com/codex)

Co-Authored-By: Codex <codex@openai.com>

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Fedor Korotkov
2026-01-22 09:22:53 -05:00
committed by GitHub
co-authored by Codex Nikolay Edigaryev
parent ea89d01760
commit 6fe523ef69
9 changed files with 470 additions and 24 deletions
+25
View File
@@ -326,9 +326,34 @@ paths:
summary: "Retrieve events for a given VM"
tags:
- vms
parameters:
- in: query
name: limit
description: Maximum number of events to return.
schema:
type: integer
minimum: 1
- in: query
name: order
description: Sort order of events; asc (default) or desc.
schema:
type: string
enum:
- asc
- desc
- in: query
name: cursor
description: Opaque cursor from the X-Next-Cursor response header.
schema:
type: string
responses:
'200':
description: OK
headers:
X-Next-Cursor:
description: Opaque cursor for the next page of events, if any.
schema:
type: string
content:
application/json:
schema: