[pve-devel] [PATCH manager v4 1/3] Move wipe_disks to PVE::Diskmanage
Dominic Jäger
d.jaeger at proxmox.com
Thu Apr 16 12:26:09 CEST 2020
Move wipe_disks from PVE::Ceph::Tools to PVE::Diskmanage.
Relies on the corresponding patch in pve-storage.
Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
v3->v4: unchanged
v2->v3: unchanged
v1->v2: Fix syntax
To test this we need an OSD that is not managed by ceph-volume:
- Create a PVE 5 VM
- Install Ceph Luminous
- Create an OSD
- Upgrade to PVE 6 but don't update Ceph to Nautilus
PVE/API2/Ceph/OSD.pm | 4 ++--
PVE/Ceph/Tools.pm | 22 ----------------------
2 files changed, 2 insertions(+), 24 deletions(-)
diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
index a514c502..fec53fbf 100644
--- a/PVE/API2/Ceph/OSD.pm
+++ b/PVE/API2/Ceph/OSD.pm
@@ -462,7 +462,7 @@ __PACKAGE__->register_method ({
push @$cmd, '--data', $devpath;
push @$cmd, '--dmcrypt' if $param->{encrypted};
- PVE::Ceph::Tools::wipe_disks($devpath);
+ PVE::Diskmanage::wipe_blockdevices([$devpath]);
run_command($cmd);
});
@@ -551,7 +551,7 @@ __PACKAGE__->register_method ({
my $partnum = PVE::Diskmanage::get_partnum($part);
my $devpath = PVE::Diskmanage::get_blockdev($part);
- PVE::Ceph::Tools::wipe_disks($part);
+ PVE::Diskmanage::wipe_blockdevices([$part]);
print "remove partition $part (disk '${devpath}', partnum $partnum)\n";
eval { run_command(['/sbin/sgdisk', '-d', $partnum, "${devpath}"]); };
warn $@ if $@;
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index e6225b78..7d2e8469 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -270,28 +270,6 @@ sub get_or_create_admin_keyring {
return $pve_ckeyring_path;
}
-# wipe the first 200 MB to clear off leftovers from previous use, otherwise a
-# create OSD fails.
-sub wipe_disks {
- my (@devs) = @_;
-
- my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M conv=fdatasync);
-
- foreach my $devpath (@devs) {
- my $devname = basename($devpath);
- my $dev_size = PVE::Tools::file_get_contents("/sys/class/block/$devname/size");
-
- ($dev_size) = $dev_size =~ m|(\d+)|; # untaint $dev_size
- die "Coulnd't get the size of the device $devname\n" if (!defined($dev_size));
-
- my $size = ($dev_size * 512 / 1024 / 1024);
- my $count = ($size < 200) ? $size : 200;
-
- print "wipe disk/partition: $devpath\n";
- eval { run_command([@wipe_cmd, "count=$count", "of=${devpath}"]) };
- warn $@ if $@;
- }
-};
# get ceph-volume managed osds
sub ceph_volume_list {
--
2.20.1
More information about the pve-devel
mailing list