From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8DFA27AC31 for ; Wed, 6 Jul 2022 08:37:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 81A3A6FC9 for ; Wed, 6 Jul 2022 08:37:50 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 6 Jul 2022 08:37:49 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1CA7240FC0 for ; Wed, 6 Jul 2022 08:37:49 +0200 (CEST) Message-ID: <2f5c421e-9fc2-64d1-8701-f861a75517ce@proxmox.com> Date: Wed, 6 Jul 2022 08:37:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Thunderbird/103.0 Content-Language: en-GB To: Proxmox VE development discussion , Aaron Lauterer References: <20220701141642.2743824-1-a.lauterer@proxmox.com> <20220701141642.2743824-4-a.lauterer@proxmox.com> <1bc425f0-5b8c-833b-6f8f-e1583357fc1d@proxmox.com> <7e833330-c2bc-d392-2690-fc828e600adb@proxmox.com> From: Thomas Lamprecht In-Reply-To: <7e833330-c2bc-d392-2690-fc828e600adb@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH manager 3/5] api ceph osd: add volume details endpoint X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2022 06:37:50 -0000 On 05/07/2022 16:19, Aaron Lauterer wrote: > Okay, so IIUC, drop the Datastore.Audit and only keep the Sys.Audit? yes. > > Being unsure 😉 Looking closer at run_command, it will die if there is some issue running the specified command, not found or returning an error. So this would only be needed if I would like to catch the error to handle it in some way, right? >>> + my $cmd = ['/usr/sbin/ceph-volume', 'lvm', 'list', '--format', 'json']; >>> + eval { run_command($cmd, errmsg => 'ceph volume error', outfunc => $parser) }; >>> + die $@ if $@; >> >> what's the point in eval'ing if you do a plain die then anyway on $@? > > Being unsure 😉 Looking closer at run_command, it will die if there is some issue running the specified command, not found or returning an error. So this would only be needed if I would like to catch the error to handle it in some way, right? Most of the time an eval with a single (!) function call, for example like `eval { foo() }; die $@ if $@;`, is identical with '`foo();`, I say most of the time because a function may avoid die directly but only set $@ manually, and in that case the eval can help to ensure it was an error from inside the function, as `eval {}` will reset $@ to undef. IIRC we only do such "set $@ manually without die" in the PVE::Tools lock_file_full (and thus the depending lock_file) method though, so just mentioning for completeness sake. Otherwise you're right, doing eval { .. } + die if $@ is basically done when we require to transform the error or have additional condition for when to actually die, e.g., a $noerr parameter.