From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Christoph Heiss <c.heiss@proxmox.com>
Subject: [pve-devel] applied: [PATCH manager v2] pvesh: decode streamed responses
Date: Sat, 21 Oct 2023 16:36:39 +0200 [thread overview]
Message-ID: <fd4b029a-31a3-443a-a835-f18b2caeeaf3@proxmox.com> (raw)
In-Reply-To: <20230607141511.560351-1-c.heiss@proxmox.com>
Am 07/06/2023 um 16:15 schrieb Christoph Heiss:
> This allows to use `pvesh` on endpoints like /nodes/{node}/journal,
> which return streamed (and possibly gzip'd) responses.
>
> Currently, e.g. `pvesh get /nodes/localhost/journal --lastentries 10`
> fails with:
>
> gzip: stdout: Broken pipe
> got hash object, but result schema specified array!
>
> Using e.g. `--output-format yaml` resulted in:
>
> ---
> download:
> content-encoding: gzip
> content-type: application/json
> fh: &1 !!perl/ref
> =: *1
> stream: 1
>
> gzip: stdout: Broken pipe
> Failed to write
>
> This is due the API call returning a "download" object (as seen above),
> which contains (among some other things) a file handle to read the
> response from.
>
> With this patch, the response from such endpoints is now correctly read
> and displayed. Only handles combinations of `Content-Encoding` == 'gzip'
> and either 'text/plain' or 'application/json' for `Content-Type`.
>
> This tries to mimic the behavior of the API server implementation when
> encountering `download` objects.
>
> Tested this with all four output formats 'text', 'json', 'json-pretty'
> and 'yaml', as well as "cross-node" in a local test cluster.
>
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
> Changes v1 -> v2:
> * Fix some style nits
> * Move content-{encoding,type} checks before actual decoding
>
> As far as I could see (aka. grep for it), the only two endpoints which
> implement this are /nodes/{node}/journal and
> /nodes/{node}/tasks/{upid}/log, latter one only with `--download 1`
> set.
>
> PVE/CLI/pvesh.pm | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
>
applied, thanks!
prev parent reply other threads:[~2023-10-21 14:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 14:15 [pve-devel] " Christoph Heiss
2023-10-19 7:28 ` Christoph Heiss
2023-10-21 14:36 ` Thomas Lamprecht [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd4b029a-31a3-443a-a835-f18b2caeeaf3@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal