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 728328A900 for ; Thu, 18 Aug 2022 17:23:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 61CC42DE7 for ; Thu, 18 Aug 2022 17:23:02 +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 ; Thu, 18 Aug 2022 17:23:00 +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 66E6944CAA for ; Thu, 18 Aug 2022 17:23:00 +0200 (CEST) Message-ID: Date: Thu, 18 Aug 2022 17:22:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 To: Proxmox VE development discussion , =?UTF-8?Q?Fabian_Gr=c3=bcnbichler?= References: <20220715115808.1385388-1-a.lauterer@proxmox.com> <20220715115808.1385388-3-a.lauterer@proxmox.com> <1660736115.7grkvr18dc.astroid@nora.none> Content-Language: en-US From: Aaron Lauterer In-Reply-To: <1660736115.7grkvr18dc.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.416 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_ASCII_DIVIDERS 0.8 Spam that uses ascii formatting tricks 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 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: Thu, 18 Aug 2022 15:23:32 -0000 On 8/17/22 13:42, Fabian Grünbichler wrote: > On July 15, 2022 1:58 pm, Aaron Lauterer wrote: [...] >> - my $worker = sub { >> - my $path = "/mnt/pve/$name"; >> - my $mountunitname = PVE::Systemd::escape_unit($path, 1) . ".mount"; >> - my $mountunitpath = "/etc/systemd/system/$mountunitname"; >> + my $mounted = PVE::Diskmanage::mounted_paths(); >> + die "a mountpoint for '${name}' already exists: ${path} ($1)\n" if $mounted->{$path}; > > nit: the mountpoint existing is not the issue (something already being > mounted there is!). also, where does the $1 come from? good point and thanks for catching the $1 > >> + die "a systemd mount unit already exists: ${mountunitpath}\n" if -e $mountunitpath; > > could check if it's identical to the one we'd generate (in the spirit of > patch #3 ;)) I looked into it, depending on how hard we want to match the mount unit, this could be a bit hard. It contains the /dev/disk/by-uuid/... path which will not be the same as it changes with each FS creation (IIUC). > >> >> + my $worker = sub { >> PVE::Diskmanage::locked_disk_action(sub { >> PVE::Diskmanage::assert_disk_unused($dev); >> >> 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. [...] >> sub preparetree { >> @@ -336,6 +340,7 @@ __PACKAGE__->register_method ({ >> my $user = $rpcenv->get_user(); >> >> my $name = $param->{name}; >> + my $node = $param->{node}; > > nit: please also change the usage further below in this API handler if > you do this what exactly do you mean? defining local variables for $param->{..} ones? > >> my $devs = [PVE::Tools::split_list($param->{devices})]; >> my $raidlevel = $param->{raidlevel}; >> my $compression = $param->{compression} // 'on'; >> @@ -346,6 +351,10 @@ __PACKAGE__->register_method ({ >> } >> PVE::Storage::assert_sid_unused($name) if $param->{add_storage}; >> >> + my $pools = get_pool_data(); > > and also here > >> + die "pool '${name}' already exists on node '$node'\n" >> + if grep { $_->{name} eq $name } @{$pools}; >> + >> my $numdisks = scalar(@$devs); >> my $mindisks = { >> single => 1, >> -- >> 2.30.2 >> >> >> >> _______________________________________________ >> pve-devel mailing list >> pve-devel@lists.proxmox.com >> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >> >> >> > > > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > >