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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A4B5A8AA27 for ; Fri, 19 Aug 2022 11:28:14 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9AFE7188DE for ; Fri, 19 Aug 2022 11:28:14 +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 ; Fri, 19 Aug 2022 11:28:14 +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 D415D43449 for ; Fri, 19 Aug 2022 11:28:13 +0200 (CEST) Message-ID: Date: Fri, 19 Aug 2022 11:28:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Content-Language: en-US To: =?UTF-8?Q?Fabian_Gr=c3=bcnbichler?= , Proxmox VE development discussion References: <20220715115808.1385388-1-a.lauterer@proxmox.com> <20220715115808.1385388-3-a.lauterer@proxmox.com> <1660736115.7grkvr18dc.astroid@nora.none> <1660896759.rnpqx2mr05.astroid@nora.none> From: Aaron Lauterer In-Reply-To: <1660896759.rnpqx2mr05.astroid@nora.none> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.014 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lvm.pm] Subject: Re: [pve-devel] [PATCH storage v2 2/3] disks: die if storage name is already in use 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: Fri, 19 Aug 2022 09:28:14 -0000 On 8/19/22 10:20, Fabian Grünbichler wrote: > On August 18, 2022 5:22 pm, Aaron Lauterer wrote: >> >>>> >>>> diff --git a/PVE/API2/Disks/LVM.pm b/PVE/API2/Disks/LVM.pm >>>> index 6e4331a..a27afe2 100644 >>>> --- a/PVE/API2/Disks/LVM.pm >>>> +++ b/PVE/API2/Disks/LVM.pm >>>> @@ -152,6 +152,9 @@ __PACKAGE__->register_method ({ >>>> PVE::Diskmanage::assert_disk_unused($dev); >>>> PVE::Storage::assert_sid_unused($name) if $param->{add_storage}; >>>> >>>> + die "volume group with name '${name}' already exists\n" >>>> + if PVE::Storage::LVMPlugin::lvm_vgs()->{$name}; >>> >>> probably better off inside the worker, since `vgs` might take a while >>> (although we also use it in the index API call in this module..) >> >> From a GUI perspective: putting it in a worker would result in the user to hit >> okay and then will see the failed task right? Keeping it as is will result in an >> error popping up when clicking ok/create and the user can edit the name instead >> of starting all over again. Though, if `vgs` really needs a bit, that error >> popping up could take a moment or two. > > yes, putting it in the worker means no early-failure. but not putting it > in the worker potentially means this API endpoint cannot be called on > systems with busy LVM at all (30s timeout for API requests!). so > early-failure checks should almost always only do "logical" things that > are cheap (like reading a conf file and checking invariants), and > nothing that can reasonably block for some time (like storage > operations, starting guests, ..). I know we are not 100% consistent > there (the worst offender is probably the storage content API endpoint > ;)), but we should try to not introduce more problems of that fashion > but rather work on removing the existing ones. good point. I'll put the check inside the worker.