Commit Graph

66 Commits

Author SHA1 Message Date
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
Danny Al-Gaaf
c4eb7e6ddd ceph-disk: fix some (local) variable names
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-04-02 17:54:53 +02:00
Danny Al-Gaaf
3dd8b46121 ceph-disk: fix naming of local variable in is_mounted()
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-04-02 17:36:37 +02:00
Danny Al-Gaaf
eaf31bf9f9 ceph-disk: merge twice defined function is_mounted(dev)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-04-02 17:33:08 +02:00
Danny Al-Gaaf
4c6d6442a8 ceph-disk: define exception type
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-04-02 17:26:12 +02:00
Danny Al-Gaaf
058eb923c5 ceph-disk: fix Redefining name 'uuid' from outer scope
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-04-02 17:17:38 +02:00
Danny Al-Gaaf
0080d1df7c ceph-disk: add missing space after comma
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-04-02 17:14:23 +02:00
Sage Weil
e9b3f2e6e9 ceph-disk list: say 'unknown cluster $UUID' when cluster is unknown
This makes it clearer that an old osd is in fact old.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-29 17:30:28 -07:00
Sage Weil
562e1716bd ceph-disk: handle missing journal_uuid field gracefully
Only lower if we know it's not None.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-29 13:59:04 -07:00
Sage Weil
43e451f6ee Merge pull request #166 from ceph/wip-disk-list
Wip disk list

Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-03-29 12:24:47 -07:00
Sage Weil
6a65b9131c ceph-disk: implement 'list'
This is based on Sandon's initial patch, but much-modified.

Mounts ceph data volumes temporarily to see what is inside.  Attempts to
associated journals with osds.

Resolves: #3120
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Dan Mick <dan.mick@inktank.com>
2013-03-28 20:49:24 -07:00
Sage Weil
d3e49047ff ceph-disk: reimplement list_all_partitions
Use /dev/disk/by-id to list disks and their partitions.  This is more
accurate and correct than the previous (as-yet unused) implementation.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-27 18:44:38 -07:00
Sage Weil
20d594a889 ceph-disk: reimplement is_partition
Previously we were assuming any device that ended in a digit was a
partition, but this is not at all correct (e.g., /dev/sr0, /dev/rbd1).
Instead, look in /dev/disk/by-id and see if there is a symlink that ends in
-partNN that links to our device.

There is probably still a better way...

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-27 18:44:38 -07:00
Sage Weil
4362934a94 ceph-disk: conditionally remove mount path
umount removes it on success; only remove it here if it is still there.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-27 16:30:48 -07:00
Sage Weil
2ae297ccb8 ceph-disk: ignore udevadm settle return code
If we time out, just continue and let the next step fail.

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-27 16:30:48 -07:00
Sage Weil
b8160018bd Merge pull request #144 from dalgaaf/wip-da-ceph-disk
Fix some issues in ceph-dsk

Reviewed-by: Sage Weil <sage@inktank.com>
2013-03-26 12:06:41 -07:00
Gary Lowell
9eda8e5d5a ceph-disk: udevadm settle before partprobe
After changing the partition table, allow the udev event to be
processed before calling partprobe.  This helps prevent partprobe
from getting a resource busy error on some platforms.

Signed-off-by: Gary Lowell  <gary.lowell@inktank.com>
2013-03-26 11:31:16 -07:00
Danny Al-Gaaf
b7d7e6894c ceph-disk: rename some local variabels in list_*partitions
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-25 17:45:32 +01:00
Danny Al-Gaaf
0b5fcfffe6 ceph-disk: fix naming of a local variable in find_cluster_by_uuid
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-25 16:24:00 +01:00
Danny Al-Gaaf
8a999ded08 ceph-disk: rename some constants to upper case variable names
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-25 16:18:17 +01:00
Danny Al-Gaaf
86e55f5448 ceph-disk: add some more docstrings
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-25 16:15:29 +01:00
Danny Al-Gaaf
543327b1f2 ceph-disk: print subprocess.CalledProcessError on error
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-25 14:36:41 +01:00
Danny Al-Gaaf
2d26bcc071 ceph-disk: fix indention
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-25 13:55:56 +01:00
Sage Weil
6d63752c8f ceph-disk: re-add python 2.7 dependency comment
FIXME!

Signed-off-by: Sage Weil <sage@inktank.com>
2013-03-22 10:09:55 -07:00
Danny Al-Gaaf
87691dc46e ceph-disk: cast output of subprocess.Popen() to str()
Cast output of subprocess.Popen() to str() to be able to use
str.split() and str.splitlines() without warnings from pylint.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-20 14:36:58 +01:00
Danny Al-Gaaf
3575feb7d2 ceph-disk: fix adjust_symlink() replace 'journal' with 'target'
Replace 'journal' variable with 'target' since journal doesn't
exist in this function.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2013-03-20 14:02:28 +01:00