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 B70C5923B4 for ; Thu, 1 Feb 2024 15:00:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8E73A10E61 for ; Thu, 1 Feb 2024 14:59:56 +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 ; Thu, 1 Feb 2024 14:59:55 +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 C29F440BE8 for ; Thu, 1 Feb 2024 14:59:54 +0100 (CET) Message-ID: <04196276-5fef-4c1d-a5c4-b25ac2d3d49d@proxmox.com> Date: Thu, 1 Feb 2024 14:59:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: pve-devel@lists.proxmox.com References: <20240130184041.1125674-1-m.carrara@proxmox.com> <20240130184041.1125674-5-m.carrara@proxmox.com> <1706701866.nr9ta17jw1.astroid@yuna.none> From: Max Carrara In-Reply-To: <1706701866.nr9ta17jw1.astroid@yuna.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.434 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_ASCII_DIVIDERS 0.8 Email that uses ascii formatting dividers and possible spam tricks 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, tools.pm] 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: Thu, 01 Feb 2024 14:00:26 -0000 On 1/31/24 14:18, Fabian Grünbichler wrote: > 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. >> >> Signed-off-by: Max Carrara >> --- >> PVE/Ceph/Tools.pm | 54 ++++++++++++++++++++++++++++++++++++----------- >> 1 file changed, 42 insertions(+), 12 deletions(-) >> >> 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 = { >> }; >> >> my $config_hash = { >> - ccname => $ccname, >> - 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, >> + ccname => { >> + value => $ccname, >> + is_file => 0, >> + }, >> + pve_ceph_cfgpath => { >> + value => $pve_ceph_cfgpath, >> + is_file => 1, >> + }, >> + pve_mon_key_path => { >> + value => $pve_mon_key_path, >> + is_file => 1, >> + }, >> + pve_ckeyring_path => { >> + value => $pve_ckeyring_path, >> + is_file => 1, >> + }, >> + ceph_bootstrap_osd_keyring => { >> + value => $ceph_bootstrap_osd_keyring, >> + is_file => 1, >> + }, >> + ceph_bootstrap_mds_keyring => { >> + value => $ceph_bootstrap_mds_keyring, >> + is_file => 1, >> + }, >> + ceph_mds_data_dir => { >> + value => $ceph_mds_data_dir, >> + is_file => 0, >> + }, >> + long_rados_timeout => { >> + value => 60, >> + is_file => 0, >> + }, >> + ceph_cfgpath => { >> + value => $ceph_cfgpath, >> + is_file => 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. Hmm, you really think so? I would personally prefer to keep it all in one place, as it makes the surrounding logic a bit easier (at least in my head). I wouldn't mind splitting it up, but I'm not really sure if that makes it actually less verbose. I shan't speculate though and just see what it would look like - will inform you when I have. Thanks for your input! > >> >> sub get_local_version { >> @@ -84,7 +111,7 @@ sub get_cluster_versions { >> sub get_config { >> my $key = shift; >> >> - my $value = $config_hash->{$key}; >> + my $value = $config_hash->{$key}->{value}; >> >> die "no such ceph config '$key'" if !$value; >> >> @@ -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 = $conf_value->{value}; >> + unlink $file if (-e $file); >> + } >> } >> } >> } >> -- >> 2.39.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 > >