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 71E5391E43 for ; Wed, 31 Jan 2024 14:18:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5256C3ACB5 for ; Wed, 31 Jan 2024 14:18:16 +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 ; Wed, 31 Jan 2024 14:18:15 +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 7BBAA4936B for ; Wed, 31 Jan 2024 14:18:15 +0100 (CET) Date: Wed, 31 Jan 2024 14:18:08 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20240130184041.1125674-1-m.carrara@proxmox.com> <20240130184041.1125674-5-m.carrara@proxmox.com> In-Reply-To: <20240130184041.1125674-5-m.carrara@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1706701866.nr9ta17jw1.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.065 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: Re: [pve-devel] [PATCH pve-manager 4/8] 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: Wed, 31 Jan 2024 13:18:46 -0000 On January 30, 2024 7:40 pm, Max Carrara wrote: > Having a file named e.g. "60" in your current directory will cause it > to be deleted when executind `pveceph purge`. This commit fixes that > by making the config hash differ between which values represent file > paths and which don't. >=20 > Signed-off-by: Max Carrara > --- > PVE/Ceph/Tools.pm | 54 ++++++++++++++++++++++++++++++++++++----------- > 1 file changed, 42 insertions(+), 12 deletions(-) >=20 > diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm > index a1458b40..3acef11b 100644 > --- a/PVE/Ceph/Tools.pm > +++ b/PVE/Ceph/Tools.pm > @@ -36,15 +36,42 @@ my $ceph_service =3D { > }; > =20 > my $config_hash =3D { > - ccname =3D> $ccname, > - pve_ceph_cfgpath =3D> $pve_ceph_cfgpath, > - pve_mon_key_path =3D> $pve_mon_key_path, > - pve_ckeyring_path =3D> $pve_ckeyring_path, > - ceph_bootstrap_osd_keyring =3D> $ceph_bootstrap_osd_keyring, > - ceph_bootstrap_mds_keyring =3D> $ceph_bootstrap_mds_keyring, > - ceph_mds_data_dir =3D> $ceph_mds_data_dir, > - long_rados_timeout =3D> 60, > - ceph_cfgpath =3D> $ceph_cfgpath, > + ccname =3D> { > + value =3D> $ccname, > + is_file =3D> 0, > + }, > + pve_ceph_cfgpath =3D> { > + value =3D> $pve_ceph_cfgpath, > + is_file =3D> 1, > + }, > + pve_mon_key_path =3D> { > + value =3D> $pve_mon_key_path, > + is_file =3D> 1, > + }, > + pve_ckeyring_path =3D> { > + value =3D> $pve_ckeyring_path, > + is_file =3D> 1, > + }, > + ceph_bootstrap_osd_keyring =3D> { > + value =3D> $ceph_bootstrap_osd_keyring, > + is_file =3D> 1, > + }, > + ceph_bootstrap_mds_keyring =3D> { > + value =3D> $ceph_bootstrap_mds_keyring, > + is_file =3D> 1, > + }, > + ceph_mds_data_dir =3D> { > + value =3D> $ceph_mds_data_dir, > + is_file =3D> 0, > + }, > + long_rados_timeout =3D> { > + value =3D> 60, > + is_file =3D> 0, > + }, > + ceph_cfgpath =3D> { > + value =3D> $ceph_cfgpath, > + is_file =3D> 1, > + }, > }; this would be less verbose if the hash is just split into two, with get_config using both, and the removal using the one just containing files. > =20 > sub get_local_version { > @@ -84,7 +111,7 @@ sub get_cluster_versions { > sub get_config { > my $key =3D shift; > =20 > - my $value =3D $config_hash->{$key}; > + my $value =3D $config_hash->{$key}->{value}; > =20 > die "no such ceph config '$key'" if !$value; > =20 > @@ -123,8 +150,11 @@ 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) { > - unlink $file if (-e $file); > + for my $conf_value (values %$config_hash) { > + if ($conf_value->{is_file}) { > + my $file =3D $conf_value->{value}; > + unlink $file if (-e $file); > + } > } > } > } > --=20 > 2.39.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20