[pve-devel] [PATCH manager 12/20] ceph: osd: rework osd destroy to work with ceph-volume

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jun 5 11:02:02 CEST 2019


On 6/4/19 2:47 PM, Dominik Csapak wrote:
> with this, osd destruction is left to ceph-volume if the osd was created
> with ceph-volume, else our old code remains mostly the same since
> we want to be able to destroy upgraded osds
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/API2/Ceph/OSD.pm | 76 ++++++++++++++++++++++++++++++++++------------------
>  1 file changed, 50 insertions(+), 26 deletions(-)

applied, with a follow up, see below (I tried do modify the diff so that one sees
the real outcome without whitespace changes)

> 
> diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
> index ae938016..7aec0642 100644
> --- a/PVE/API2/Ceph/OSD.pm
> +++ b/PVE/API2/Ceph/OSD.pm
> @@ -490,37 +490,61 @@ __PACKAGE__->register_method ({
>  		warn $@ if $@;
>  	    };

> +	    my $osd_list = PVE::Ceph::Tools::ceph_volume_list();
> +
> +	    if ($osd_list->{$osdid}) {
> +		# ceph-volume managed
> +
> +		# try to make a list of devs we want to pvremove
> +		my $devices_pvremove = {};
> +		for my $osd_part (@{$osd_list->{$osdid}}) {
> +		    for my $dev (@{$osd_part->{devices}}) {
> +			$devices_pvremove->{$dev} = 1;
>  		    }
>  		}

I moved above into the if (cleanup) branch below and just do the pveremove directly,
no recording into a hash required.

> 
> +		eval {
> +		    PVE::Ceph::Tools::ceph_volume_zap($osdid, $param->{cleanup});
> +		};
> +		warn $@ if $@;
> +		if ($param->{cleanup}) {
> +		    # try to remove pvs, but do not fail if it does not work
> +		    for my $dev (keys %$devices_pvremove) {
> +			eval { run_command(['/sbin/pvremove', $dev], errfunc => {}) };
> +		    }
> +		}




More information about the pve-devel mailing list