From: Aaron Lauterer <a.lauterer@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH librados2-perl 2/6] mon_command: optionally ignore errors and return hashmap
Date: Tue, 22 Feb 2022 13:42:31 +0100 [thread overview]
Message-ID: <5683f184-4159-b330-c278-c8557b551821@proxmox.com> (raw)
In-Reply-To: <b7fb21fd-f991-9945-ac95-94562454b6c8@proxmox.com>
On 2/21/22 16:44, Thomas Lamprecht wrote:
> On 18.02.22 12:38, Aaron Lauterer wrote:
>> This patch requires patch 3 of the series to not break OSD removal!
>> Therefore releasing a new version of librados2-perl and pve-manager
>> needs to be coordinated.
>
> I don't like that and think it can be avoided.
I'll look into it again.
>> [...]
>> sub mon_command {
>> - my ($self, $cmd) = @_;
>> + my ($self, $cmd, $noerr) = @_;
>> +
>> + $noerr = 0 if !$noerr;
>>
>> $cmd->{format} = 'json' if !$cmd->{format};
>>
>> my $json = encode_json($cmd);
>>
>> - my $raw = eval { $sendcmd->($self, 'M', $json) };
>> + my $ret = eval { $sendcmd->($self, 'M', $json, undef, $noerr) };
>
> I'd rather like to avoid chaining through that $noerr every where, rather pass all the
> info via the die (errors can be references to structured data too, like PVE::Exception is),
> or just avoid the die at the lower level completely and map the error inside the struct
> too, it can then be thrown here, depending on $noerr parameters or what not.
Okay, definitely sounds like the cleaner approach.
>> [...]
>> - if (ret < 0) {
>> + if (ret < 0 && noerr == false) {
>> char msg[4096];
>> if (outslen > sizeof(msg)) {
>> outslen = sizeof(msg);
>> @@ -142,9 +143,22 @@ CODE:
>> die(msg);
>> }
>>
>> - RETVAL = newSVpv(outbuf, outbuflen);
>> + char status[(int)outslen + 1];
>
> this is on the stack and could be to large to guarantee it always fits, but...
>
>> + if (outslen > sizeof(status)) {
>> + outslen = sizeof(status);
>> + }
>> + snprintf(status, sizeof(status), "%.*s\n", (int)outslen, outs);
>
> ...why not just chain outs through instead of re-allocating it and writing it out in a
> relatively expensive way?
>
Yeah, will do that.
next prev parent reply other threads:[~2022-02-22 12:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 11:38 [pve-devel] [PATCH librados2-perl manager 0/6] Add Ceph safety checks Aaron Lauterer
2022-02-18 11:38 ` [pve-devel] [PATCH librados2-perl 1/6] mon_command: free outs buffer Aaron Lauterer
2022-02-21 15:35 ` Thomas Lamprecht
2022-02-18 11:38 ` [pve-devel] [PATCH librados2-perl 2/6] mon_command: optionally ignore errors and return hashmap Aaron Lauterer
2022-02-21 15:44 ` Thomas Lamprecht
2022-02-22 12:42 ` Aaron Lauterer [this message]
2022-02-18 11:38 ` [pve-devel] [PATCH manager 3/6] api: osd: force mon_command to scalar context Aaron Lauterer
2022-02-18 11:38 ` [pve-devel] [PATCH manager 4/6] api: mon: mds: osd: add safety check endpoints Aaron Lauterer
2022-02-22 8:44 ` Thomas Lamprecht
2022-03-14 16:49 ` Aaron Lauterer
2022-03-14 17:02 ` Thomas Lamprecht
2022-02-18 11:38 ` [pve-devel] [PATCH manager 5/6] ui: osd: warn if removal could be problematic Aaron Lauterer
2022-02-24 12:46 ` Thomas Lamprecht
2022-02-18 11:38 ` [pve-devel] [PATCH manager 6/6] ui: osd: mon: mds: warn if stop/destroy actions are problematic Aaron Lauterer
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=5683f184-4159-b330-c278-c8557b551821@proxmox.com \
--to=a.lauterer@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
--cc=t.lamprecht@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox