[pve-devel] applied: [PATCH v2 pve-manager 08/11] ceph: fix edge case of wrong files being deleted on purge
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Feb 12 14:33:55 CET 2024
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 = shift;
- my $value = $config_values->{$key};
- if (! defined($value)) {
- $value = $config_files->{$key};
- }
+ my $value = $config_values->{$key} // $config_files->{$key};
die "no such ceph config '$key'" if ! defined($value);
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.
>
> Signed-off-by: Max Carrara <m.carrara at proxmox.com>
> ---
> 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
>
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
>
More information about the pve-devel
mailing list