public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [RFC http-server/manager 0/2] add pvesh record subcommand
@ 2026-06-17 16:47 Hannes Laimer
  2026-06-17 16:47 ` [PATCH pve-http-server 1/2] apiserver: add opt-in recording of api requests Hannes Laimer
  2026-06-17 16:47 ` [PATCH pve-manager 2/2] pvesh: add 'record' subcommand to trace user's API requests Hannes Laimer
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Laimer @ 2026-06-17 16:47 UTC (permalink / raw)
  To: pve-devel

Implements a new pvesh subcommand that records the API requests a user makes
and prints them as the equivalent `pvesh` commands, e.g. to find the CLI/API
equivalent of an action done in the web UI.

`pvesh record <user>` creates a `<pid>.req` file under /run/pve-api-record/
containing the user and an `all` flag. The http-server (pveproxy) reads it and
appends the matching API requests (including data) to a spool file
`<pid>.events`. The pvesh process reads those entries, translates them into
`pvesh ..` and prints them. By default only writing requests (POST/PUT/DELETE)
are recorded, `--all` also includes reads (GET).

With the pid of the pvesh process as the identifier, this works with multiple,
concurrently running recordings. The pvesh process holds a lock on `<pid>.req`,
so if it is killed without cleaning up, the http-server can reap the stale
files once it can take the lock.

This spans two repos: the recording hook in pve-http-server and the `record`
command in pve-manager that uses it.

Note: recorded parameters are verbatim, so any secret submitted in a request
(e.g. a password) appears in the printed commands.

Turned out to be really handy for testing things, but i could also see how this
could be helpful in getting more familiar with the api in general and having a
way to map ui intercations to scriptable api requests.

also put pre-build packages on sani(`pvesh-record-rfc/`)


pve-http-server:

Hannes Laimer (1):
  apiserver: add opt-in recording of api requests

 src/Makefile                         |   1 +
 src/PVE/APIServer/AnyEvent.pm        |  17 +++
 src/PVE/APIServer/RequestRecorder.pm | 188 +++++++++++++++++++++++++++
 3 files changed, 206 insertions(+)
 create mode 100644 src/PVE/APIServer/RequestRecorder.pm


pve-manager:

Hannes Laimer (1):
  pvesh: add 'record' subcommand to trace user's API requests

 PVE/CLI/pvesh.pm        | 140 ++++++++++++++++++++++++++++++++++++++++
 PVE/Service/pveproxy.pm |   1 +
 2 files changed, 141 insertions(+)


Summary over all repositories:
  5 files changed, 347 insertions(+), 0 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-17 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-17 16:47 [RFC http-server/manager 0/2] add pvesh record subcommand Hannes Laimer
2026-06-17 16:47 ` [PATCH pve-http-server 1/2] apiserver: add opt-in recording of api requests Hannes Laimer
2026-06-17 16:47 ` [PATCH pve-manager 2/2] pvesh: add 'record' subcommand to trace user's API requests Hannes Laimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal