From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 260DE1FF2D3 for ; Fri, 12 Jul 2024 11:36:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A57283FDE5; Fri, 12 Jul 2024 11:37:00 +0200 (CEST) Message-ID: <0d63d9ef-d6cd-4d4a-a68a-ae8ac5f2f9cb@proxmox.com> Date: Fri, 12 Jul 2024 11:36:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion , Christoph Heiss References: <20240711115804.706227-1-c.heiss@proxmox.com> <20240711115804.706227-5-c.heiss@proxmox.com> Content-Language: en-US From: Aaron Lauterer In-Reply-To: <20240711115804.706227-5-c.heiss@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL -0.039 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [zfs.pm, install.pm] Subject: Re: [pve-devel] [PATCH installer v3 4/4] low-level: install: check for already-existing `rpool` on install 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: , Reply-To: Proxmox VE development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" only one small nit inline On 2024-07-11 13:57, Christoph Heiss wrote: > .. much in the same manner as the detection for LVM works. > > zpools can only be renamed by importing them with a new name, so > unfortunately the import-export dance is needed. > > Signed-off-by: Christoph Heiss > --- > Changes v2 -> v3: > * skip rename prompt in auto-install mode > > Changes v1 -> v2: > * use unique pool id for renaming instead of generating random id > ourselves > * moved renaming functionality to own subroutine in new > Proxmox::Sys::ZFS module > > Proxmox/Install.pm | 33 +++++++++++++++++++++++++++++++++ > Proxmox/Sys/ZFS.pm | 20 ++++++++++++++++++-- > 2 files changed, 51 insertions(+), 2 deletions(-) > > diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm > index 7342e4b..ba699fa 100644 > --- a/Proxmox/Install.pm > +++ b/Proxmox/Install.pm > @@ -16,6 +16,7 @@ use Proxmox::Install::StorageConfig; > use Proxmox::Sys::Block qw(get_cached_disks wipe_disk partition_bootable_disk); > use Proxmox::Sys::Command qw(run_command syscmd); > use Proxmox::Sys::File qw(file_read_firstline file_write_all); > +use Proxmox::Sys::ZFS; > use Proxmox::UI; > > # TODO: move somewhere better? > @@ -169,9 +170,41 @@ sub btrfs_create { > syscmd($cmd); > } > > +sub zfs_ask_existing_zpool_rename { > + my ($pool_name) = @_; > + > + # At this point, no pools should be imported/active > + my $exported_pools = Proxmox::Sys::ZFS::get_exported_pools(); > + > + foreach (@$exported_pools) { > + next if $_->{name} ne $pool_name || $_->{state} ne 'ONLINE'; > + my $renamed_pool = "$_->{name}-OLD-$_->{id}"; > + > + my $response_ok = Proxmox::Install::Config::get_existing_storage_auto_rename(); maybe we want to name this differently to avoid confusion? response_ok -> do_rename or something in that regard? but that could be done in a follow up patch as well if we want to > + if (!$response_ok) { > + $response_ok = Proxmox::UI::prompt( > + "A ZFS pool named '$_->{name}' (id $_->{id}) already exists on the system.\n\n" . > + "Do you want to rename the pool to '$renamed_pool' before continuing " . > + "or cancel the installation?" > + ); > + } > + > + # Import the pool using its id, as that is unique and works even if there are > + # multiple zpools with the same name. > + if ($response_ok) { > + Proxmox::Sys::ZFS::rename_pool($_->{id}, $renamed_pool); > + } else { > + warn "Canceled installation as requested by user, due to already existing ZFS pool '$pool_name'\n"; > + die "\n"; # causes abort without re-showing an error dialogue > + } > + } > +} > + [...] _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel