From: Max Carrara <m.carrara@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH pve-manager 4/8] ceph: fix edge case of wrong files being deleted on purge
Date: Thu, 1 Feb 2024 14:59:53 +0100 [thread overview]
Message-ID: <04196276-5fef-4c1d-a5c4-b25ac2d3d49d@proxmox.com> (raw)
In-Reply-To: <1706701866.nr9ta17jw1.astroid@yuna.none>
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 <m.carrara@proxmox.com>
>> ---
>> 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
>
>
next prev parent reply other threads:[~2024-02-01 14:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-30 18:40 [pve-devel] [PATCH master ceph, quincy-stable-8 ceph, pve-storage, pve-manager 0/8] Fix #4759: Configure Permissions for ceph-crash.service Max Carrara
2024-01-30 18:40 ` [pve-devel] [PATCH master ceph 1/8] debian: add patch to fix ceph crash dir permissions in postinst hook Max Carrara
2024-01-31 13:18 ` Fabian Grünbichler
2024-02-01 13:28 ` Max Carrara
2024-01-30 18:40 ` [pve-devel] [PATCH quincy-stable-8 ceph 2/8] " Max Carrara
2024-01-30 18:40 ` [pve-devel] [PATCH pve-storage 3/8] cephconfig: support sections in the format of [client.$NAME] Max Carrara
2024-01-31 13:18 ` Fabian Grünbichler
2024-02-01 13:40 ` Max Carrara
2024-01-30 18:40 ` [pve-devel] [PATCH pve-manager 4/8] ceph: fix edge case of wrong files being deleted on purge Max Carrara
2024-01-31 13:18 ` Fabian Grünbichler
2024-02-01 13:59 ` Max Carrara [this message]
2024-01-30 18:40 ` [pve-devel] [PATCH pve-manager 5/8] fix #4759: ceph: configure keyring for ceph-crash.service Max Carrara
2024-01-31 13:17 ` Fabian Grünbichler
2024-02-05 11:57 ` Max Carrara
2024-02-12 13:41 ` Fabian Grünbichler
2024-01-30 18:40 ` [pve-devel] [PATCH pve-manager 6/8] ceph: create '/etc/pve/ceph' during `pveceph init` Max Carrara
2024-01-30 18:40 ` [pve-devel] [PATCH pve-manager 7/8] debian/postinst: fix shellcheck warning Max Carrara
2024-01-31 13:16 ` [pve-devel] applied-partially: " Fabian Grünbichler
2024-02-01 13:40 ` Max Carrara
2024-01-30 18:40 ` [pve-devel] [PATCH pve-manager 8/8] fix #4759: debian/postinst: configure ceph-crash.service and its key Max Carrara
2024-01-31 13:15 ` Fabian Grünbichler
2024-02-01 13:54 ` Max Carrara
2024-01-31 13:25 ` [pve-devel] [PATCH master ceph, quincy-stable-8 ceph, pve-storage, pve-manager 0/8] Fix #4759: Configure Permissions for ceph-crash.service Fabian Grünbichler
2024-01-31 14:22 ` Friedrich Weber
2024-02-01 13:35 ` Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=04196276-5fef-4c1d-a5c4-b25ac2d3d49d@proxmox.com \
--to=m.carrara@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox