Commit Graph

91 Commits

Author SHA1 Message Date
Alfredo Deza
a9334a1c8c use the absolute path for executables if found
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
2013-12-12 11:16:38 -05:00
Alfredo Deza
43561f7916 remove trailing semicolon
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
2013-12-12 10:26:05 -05:00
Alfredo Deza
e19e38012b replace sgdisk subprocess calls with a helper
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
2013-12-11 15:41:45 -05:00
Jonathan Davies
35011e0b01 Call --mbrtogpt on journal run of sgdisk should the drive require a GPT table.
Signed-off-by: Jonathan Davies <jonathan.davies@canonical.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Reviewed-by: Loic Dachary <loic@dachary.org>
2013-12-04 13:57:13 +00:00
Loic Dachary
6570197871 ceph-disk: blacklist /dev/fd0
blkid -s TYPE /dev/fd0 has been verified to hang forever on a
H8DMR-82 supermicro motherboard running

3.8.0-33-generic #48~precise1-Ubuntu SMP Thu Oct 24 16:28:06 UTC 2013
x86_64

It is unlikely that ceph will ever be used on floppy disks, they
can be blacklisted.

http://tracker.ceph.com/issues/6827 fixes: #6827

Signed-off-by: Loic Dachary <loic@dachary.org>
2013-12-03 09:31:05 +01:00
git-harry
22f8325dbf Make fsid comparison case-insensitive
get_fsid and find_cluster_by_uuid are modified so ceph-disk activate and
ceph-disk activate-all will work if the fsid uses uppercase characters.

Signed-off-by: Harry Harrington <git-harry@live.co.uk>
2013-10-03 10:32:50 +01:00
Alfredo Deza
8fb7a47601 Merge pull request #678 from ceph/wip-5981
ceph-disk: make initial journal files 0 bytes
2013-10-02 11:13:43 -07:00
Dan Mick
b9000b314b Invoke python with /usr/bin/env python instead of directly
Fixes: #6311
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-09-30 14:58:11 -07:00
Sage Weil
a786ad773c ceph-disk: make initial journal files 0 bytes
The ceph-osd will resize journal files up and properly fallocate() them
so that the blocks are preallocated and (hopefully) contiguous.  We
don't need to do it here too, and getting fallocate() to work from
python is a pain in the butt.

Fixes: #5981
Signed-off-by: Sage Weil <sage@inktank.com>
2013-09-09 22:27:23 -07:00
Sage Weil
8b1b74598b Merge remote-tracking branch 'gh/next' 2013-08-24 14:12:44 -07:00
Alfredo Deza
f040020fb2 ceph-disk: specify the filetype when mounting
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-08-23 08:15:06 -07:00
Sage Weil
2af59d5e81 ceph-disk: partprobe after creating journal partition
At least one user reports that a partprobe is needed after creating the
journal partition.  It is not clear why sgdisk is not doing it, but this
fixes ceph-disk for them, and should be harmless for other users.

Fixes: #5599
Tested-by: lurbs in #ceph
Signed-off-by: Sage Weil <sage@inktank.com>
2013-08-20 22:39:09 -07:00
Sage Weil
cb50b5a7f1 ceph-disk: fix mount options passed to move_mount
Commit 6cbe0f021f added a mount_options but
in certain cases it may be blank.  Fill in with the defaults, just as we
do in mount().

Backport: cuttlefish
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Signed-off-by: Sage Weil <sage@inktank.com>
2013-08-09 21:24:08 -07:00
Alfredo Deza
6cbe0f021f make sure we are using the mount options
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
(cherry picked from commit 34831d0989)
2013-08-08 18:38:08 -07:00
Alfredo Deza
ebb9aceb79 ceph-disk: use new dumpling-style osd caps if we can, or fall back to old-style ones
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-07-25 14:30:00 -07:00
Sage Weil
fd1fd664d6 ceph-disk: use new get_dev_path helper for list
Backport: cuttlefish
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
Tested-by: Olivier Bonvalet <ob.ceph@daevel.fr>
2013-07-24 14:46:24 -07:00
Sage Weil
2ea8fac441 ceph-disk: use /sys/block to determine partition device names
Not all devices are basename + number; some have intervening character(s),
like /dev/cciss/c0d1p2.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-16 15:51:44 -07:00
Sage Weil
5b031e100b ceph-disk: reimplement is_partition() using /sys/block
Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-16 15:51:44 -07:00
Sage Weil
3359aaedde ceph-disk: use get_dev_name() helper throughout
This is more robust than the broken split trick.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-16 15:51:44 -07:00
Sage Weil
35d3f2d848 ceph-disk: refactor list_[all_]partitions
Make these methods work in terms of device *names*, not paths, and fix up
the only direct list_partitions() caller to do the same.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-16 15:51:44 -07:00
Sage Weil
e0401591e3 ceph-disk: add get_dev_name, path helpers
Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-16 15:51:43 -07:00
Sage Weil
64379e701b ceph-disk: rely on /dev/disk/by-partuuid instead of special-casing journal symlinks
This was necessary when ceph-disk-udev didn't create the by-partuuid (and
other) symlinks for us, but now it is fragile and error-prone.  (It also
appears to be broken on a certain customer RHEL VM.)  See
d7f7d61351.

Instead, just use the by-partuuid symlinks that we spent all that ugly
effort generating.

Backport: cuttlefish
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-07-16 13:15:07 -07:00
Sandon Van Ness
836e35f8ed Get device-by-path by looking for it instead of assuming 3rd entry.
On some systems (virtual machines so far) the device-by-path entry
from udevadm is not always in the same spot so instead actually
look for the right output instead of blindy assuming that its a
specific field in the output.

Signed-off-by: Sandon Van Ness <sandon@inktank.com>
Reviewed-by: Gary Lowell  <gary.lowell@inktank.com>
2013-07-10 14:55:52 -07:00
Sage Weil
cb97338b11 ceph-disk: handle /dev/foo/bar devices throughout
Assume the last component is the unique device name, even if it appears
under a subdir of /dev.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-02 14:00:15 -07:00
Sage Weil
e082f1247f ceph-disk: make is_held() smarter about full disks
Handle the case where the device is a full disk.  Make the partition
check a bit more robust (don't make assumptions about naming aside from
the device being a prefix of the partition).

Signed-off-by: Sage Weil <sage@inktank.com>
2013-07-02 14:00:15 -07:00
Greg Farnum
9e604ee694 ceph-disk: s/else if/elif/
Signed-off-by: Greg Farnum <greg@inktank.com>
Reviewed-by: Joao Luis <joao.luis@inktank.com>
(cherry picked from commit bd8255a750de08c1b8ee5e9c9a0a1b9b16171462)
2013-06-27 15:21:44 -07:00
Sage Weil
8a17f33b14 ceph-disk: do not mount over an osd directly in /var/lib/ceph/osd/$cluster-$id
If we see a 'ready' file in the target OSD dir, do not mount our device
on top of it.

Among other things, this prevents ceph-disk activate on stray disks from
stepping on teuthology osds.

Fixes: #5445
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-26 18:28:01 -07:00
Sage Weil
2a4953b697 ceph-disk: use unix lock instead of lockfile class
The lockfile class relies on file system trickery to get safe mutual
exclusion.  However, the unix syscalls do this for us.  More
importantly, the unix locks go away when the owning process dies, which
is behavior that we want here.

Fixes: #5387
Backport: cuttlefish
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-06-19 17:58:31 -07:00
Alexandre Maragone
8c0daafe00 ceph-disk: make list_partition behave with unusual device names
When you get device names like sdaa you do not want to mistakenly conclude that
sdaa is a partition of sda.  Use /sys/block/$device/$partition existence
instead.

Fixes: #5211
Backport: cuttlefish
Signed-off-by: Alexandre Maragone <alexandre.maragone@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
2013-06-19 16:11:45 -07:00
Sage Weil
8c6b24e903 ceph-disk: add some notes on wth we are up to
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-17 15:43:40 -07:00
Sage Weil
e538829f16 ceph-disk: clear TERM to avoid libreadline hijinx
The weird output from libreadline users is related to the TERM variable.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-17 11:16:42 -07:00
Sage Weil
c9074375bf ceph-disk: do not stop activate-all on first failure
Keep going even if we hit one activation error.  This avoids failing to
start some disks when only one of them won't start (e.g., because it
doesn't belong to the current cluster).

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-17 11:16:41 -07:00
Sage Weil
5c7a23687a ceph-disk: add 'activate-all'
Scan /dev/disk/by-parttypeuuid for ceph OSDs and activate them all.  This
is useful when the event didn't trigger on the initial udev event for
some reason.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-17 09:49:53 -07:00
Sage Weil
e5ffe0d248 ceph-disk: do not use mount --move (or --bind)
The kernel does not let you mount --move when the parent mount is
shared (see, e.g., https://bugzilla.redhat.com/show_bug.cgi?id=917008
for another person this also confused).  We can't use --bind either
since that (on RHEL at least) screws up /etc/mtab so that the final
result looks like

 /var/lib/ceph/tmp/mnt.HNHoXU /var/lib/ceph/osd/ceph-0 none rw,bind 0 0

Instead, mount the original dev in the final location and then umount
from the old location.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-14 14:04:54 -07:00
Sage Weil
82ff72f827 ceph-disk: work around buggy rhel/centos parted
parted on RHEL/Centos prefixes the *machine readable output* with

 1b 5b 3f 31 30 33 34 68

Note that the same thing happens when you 'import readline' in python.

Work around it!

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-14 12:10:49 -07:00
Sage Weil
a2a78e8d16 ceph-disk: implement 'activate-journal'
Activate an osd via its journal device.  udev populates its symlinks and
triggers events in an order that is not related to whether the device is
an osd data partition or a journal.  That means that triggering
'ceph-disk activate' can happen before the journal (or journal symlink)
is present and then fail.

Similarly, it may be that they are on different disks that are hotplugged
with the journal second.

This can be wired up to the journal partition type to ensure that osds are
started when the journal appears second.

Include the udev rules to trigger this.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-13 18:01:43 -07:00
Sage Weil
8b3b59e014 ceph-disk: call partprobe outside of the prepare lock; drop udevadm settle
After we change the final partition type, sgdisk may or may not trigger a
udev event, depending on how well udev is behaving (it varies between
distros, it seems).  The old code would often settle and wait for udev to
activate the device, and then partprobe would uselessly fail because it
was already mounted.

Call partprobe only at the very end, after prepare is done.  This ensures
that if partprobe calls udevadm settle (which is sometimes does) we do not
get stuck.

Drop the udevadm settle.  I'm not sure what this accomplishes; take it out,
at least until we determine we need it.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-13 18:01:43 -07:00
Sage Weil
10ba60cd08 ceph-disk: add 'zap' command
Signed-off-by: Sage Weil <sage@inktank.com>
2013-06-13 18:01:43 -07:00
Dan Mick
f86b4e7a48 ceph-disk: extra dash in error message
Signed-off-by: Dan Mick <dan.mick@inktank.com>
2013-06-12 22:22:42 -07:00
Danny Al-Gaaf
9785478a2a ceph-disk: remove unnecessary semicolons
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-05-24 12:46:15 +02:00
Danny Al-Gaaf
16ecae153d ceph-disk: cast output of _check_output()
Cast output of _check_output() to str() to be able to use
str.split().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-05-24 12:41:11 +02:00
Danny Al-Gaaf
9429ff90a0 ceph-disk: fix undefined variable
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-05-24 12:33:16 +02:00
Danny Al-Gaaf
c127745cc0 ceph-disk: add missing spaces around operator
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-05-24 12:29:07 +02:00
Sage Weil
bcc8bfdb67 ceph-disk: fix stat errors with new suppress code
Broken by 225fefe5e7.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-05-21 12:52:20 -07:00
Sage Weil
225fefe5e7 ceph-disk: add '[un]suppress-activate <dev>' command
It is often useful to prepare but not activate a device, for example when
preparing a bunch of spare disks.  This marks a device as 'do not
activate' so that it can be prepared without activating.

Fixes: #3255
Signed-off-by: Sage Weil <sage@inktank.com>
2013-05-13 12:35:32 -07:00
Sage Weil
60603d01e5 ceph-disk: use separate lock files for prepare, activate
Use a separate lock file for prepare and activate to avoid deadlock.  This
didn't seem to trigger on all machines, but in many cases, the prepare
process would take the file lock and later trigger a udev event and the
activate would then block on the same lock, either when we explicitly call
'udevadm settle --timeout=10' or when partprobe does it on our behalf
(without a timeout!).   Avoid this by using separate locks for prepare
and activate.  We only care if multiple activates race; it is
okay for a prepare to be in progress and for an activate to be kicked
off.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-05-06 12:12:04 -07:00
Sage Weil
cd1d6fb3f9 ceph-disk: tolerate /sbin/service or /usr/sbin/service
CentOS/RH has it in /sbin, others in /usr/sbin.

Backport: bobtail
Signed-off-by: Sage Weil <sage@inktank.com>
2013-04-30 14:16:04 -07:00
Gary Lowell
7ad63d23d7 ceph-disk: OSD hotplug fixes for Centos
Two fixes for Centos 6.3 and other systems with udev versions
prior to 172.  The disk peristant name using the GPT UUID does
not exist, so use the by_path persistent name instead for the
journal symlink.

The gpt label fields are not available for use in udev rules. Add
ceph-disk-udev wrapper script that extracts the partition
type guid from the label and calls ceph-disk-activate if it is
a ceph guid type. (Bug #4632)

Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
2013-04-22 22:30:39 -07:00
Alexandre Marangone
56619ab917 Fix journal partition creation
With OSD sharing data and journal, the previous code created the
journal partiton from the end of the device. A uint32_t is
used in sgdisk to get the last sector, with large HD, uint32_t
is too small.
The journal partition will be created backwards from the
a sector in the midlle of the disk leaving space before
and after it. The data partition will use whichever of
these spaces is greater. The remaining will not be used.

This patch creates the journal partition from the start as a workaround.

Signed-off-by: Alexandre Marangone <alexandre.marangone@inktank.com>
2013-04-19 15:11:09 -07:00
Gary Lowell
a793853850 ceph-disk: CalledProcessError has no output keyword on 2.6
Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
2013-04-02 23:01:12 -07:00