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 52AD393690 for ; Mon, 5 Feb 2024 18:55:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9C5361B452 for ; Mon, 5 Feb 2024 18:54:33 +0100 (CET) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 5 Feb 2024 18:54:32 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id ECE9C44474 for ; Mon, 5 Feb 2024 18:54:31 +0100 (CET) From: Max Carrara To: pve-devel@lists.proxmox.com Date: Mon, 5 Feb 2024 18:54:16 +0100 Message-Id: <20240205175419.1271680-9-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205175419.1271680-1-m.carrara@proxmox.com> References: <20240205175419.1271680-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.029 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 pve-manager 08/11] ceph: fix edge case of wrong files being deleted on purge 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: Mon, 05 Feb 2024 17:55:02 -0000 Having a file named e.g. "60" in your current directory will cause it to be deleted when executing `pveceph purge`. This commit fixes that by making the config hash differ between which values represent file paths and which don't. Signed-off-by: Max Carrara --- Changes v1 --> v2:as * use two hashes instead of one large nested hash to differ between config values that correspond to files and adapt surrounding logic correspondingly PVE/Ceph/Tools.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm index a1458b40..273a3eb6 100644 --- a/PVE/Ceph/Tools.pm +++ b/PVE/Ceph/Tools.pm @@ -35,15 +35,18 @@ my $ceph_service = { ceph_volume => '/usr/sbin/ceph-volume', }; -my $config_hash = { +my $config_values = { ccname => $ccname, + ceph_mds_data_dir => $ceph_mds_data_dir, + long_rados_timeout => 60, +}; + +my $config_files = { pve_ceph_cfgpath => $pve_ceph_cfgpath, pve_mon_key_path => $pve_mon_key_path, pve_ckeyring_path => $pve_ckeyring_path, ceph_bootstrap_osd_keyring => $ceph_bootstrap_osd_keyring, ceph_bootstrap_mds_keyring => $ceph_bootstrap_mds_keyring, - ceph_mds_data_dir => $ceph_mds_data_dir, - long_rados_timeout => 60, ceph_cfgpath => $ceph_cfgpath, }; @@ -84,9 +87,12 @@ sub get_cluster_versions { sub get_config { my $key = shift; - my $value = $config_hash->{$key}; + my $value = $config_values->{$key}; + if (! defined($value)) { + $value = $config_files->{$key}; + } - die "no such ceph config '$key'" if !$value; + die "no such ceph config '$key'" if ! defined($value); return $value; } @@ -123,7 +129,7 @@ sub purge_all_ceph_files { warn "Foreign MON address in ceph.conf. Keeping config & keyrings\n" } else { print "Removing config & keyring files\n"; - foreach my $file (%$config_hash) { + for my $file (%$config_files) { unlink $file if (-e $file); } } -- 2.39.2