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 5C91B90AD6 for ; Mon, 12 Feb 2024 14:34:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 39C9619E41 for ; Mon, 12 Feb 2024 14:34:02 +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, 12 Feb 2024 14:34:01 +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 60A8B478D9 for ; Mon, 12 Feb 2024 14:34:01 +0100 (CET) Date: Mon, 12 Feb 2024 14:33:55 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20240205175419.1271680-1-m.carrara@proxmox.com> <20240205175419.1271680-9-m.carrara@proxmox.com> In-Reply-To: <20240205175419.1271680-9-m.carrara@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1707743179.h1hwhq5mx5.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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] applied: [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, 12 Feb 2024 13:34:02 -0000 applied this one with a small style follow-up: diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm index 273a3eb63..ee6c515cb 100644 --- a/PVE/Ceph/Tools.pm +++ b/PVE/Ceph/Tools.pm @@ -87,10 +87,7 @@ sub get_cluster_versions { sub get_config { my $key =3D shift; =20 - my $value =3D $config_values->{$key}; - if (! defined($value)) { - $value =3D $config_files->{$key}; - } + my $value =3D $config_values->{$key} // $config_files->{$key}; =20 die "no such ceph config '$key'" if ! defined($value); =20 On February 5, 2024 6:54 pm, Max Carrara wrote: > 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. >=20 > 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 >=20 > PVE/Ceph/Tools.pm | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) >=20 > 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 =3D { > ceph_volume =3D> '/usr/sbin/ceph-volume', > }; > =20 > -my $config_hash =3D { > +my $config_values =3D { > ccname =3D> $ccname, > + ceph_mds_data_dir =3D> $ceph_mds_data_dir, > + long_rados_timeout =3D> 60, > +}; > + > +my $config_files =3D { > 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, > }; > =20 > @@ -84,9 +87,12 @@ sub get_cluster_versions { > sub get_config { > my $key =3D shift; > =20 > - my $value =3D $config_hash->{$key}; > + my $value =3D $config_values->{$key}; > + if (! defined($value)) { > + $value =3D $config_files->{$key}; > + } > =20 > - die "no such ceph config '$key'" if !$value; > + die "no such ceph config '$key'" if ! defined($value); > =20 > 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); > } > } > --=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