Loic Dachary [Thu, 27 Aug 2015 20:22:43 +0000 (22:22 +0200)]
ceph-disk: integration tests for multipath
Add integration tests for multipath to the ceph-disk workunit, with the
following caveats:
A workaround is added (explicit call to ceph-disk activate) until the
CentOS activation bug http://tracker.ceph.com/issues/12786 is fixed.
The tests do not run on Ubuntu because of the multipath / device mapper
bug
https://bugs.launchpad.net/ubuntu/+source/multipath-tools/+bug/1488688
and it has not been tested on Debian.
Loic Dachary [Thu, 27 Aug 2015 20:17:21 +0000 (22:17 +0200)]
ceph-disk: implement workunit
This new ceph-disk workunit re-implements the tests that previously were
in the src/test/ceph-disk.sh src/test/ceph-disk-root.sh scripts and is
meant to run in a virtual machine instead of docker.
Loic Dachary [Thu, 27 Aug 2015 11:14:13 +0000 (13:14 +0200)]
ceph-disk: implement list --format json
The ceph-disk list command is reworked in two parts:
1) the list_devices function that build an internal structure with all
the information regarding disks and partitions.
2) a function to display the internal structure in plain text or json
The ceph-disk list show the plain text version and is backward
compatible.
The ceph-disk list --format json output has more information about each
device than the plain text version and is intended for scripts.
The unit tests cover all modified lines (2610 to 2849).
Loic Dachary [Thu, 27 Aug 2015 10:21:48 +0000 (12:21 +0200)]
tests: obsolete ceph-disk root tests
They were designed to run in a docker container using loop devices
instead of disks. Although this was fit for ceph-disk activate tests for
regular and dmcrypt devices, a docker instance does not have its own
udev instance it is not possible to run tests involving udev events
without interfering with the host.
Loic Dachary [Sun, 16 Aug 2015 00:37:01 +0000 (02:37 +0200)]
ceph-disk: add multipath support
A multipath device is detected because there is a
/sys/dev/block/M:m/dm/uuid file with the mpath- prefix (or part\w+-mpath
prefix).
When ceph-disk prepares data or journal devices on a multipath device,
it sets the partition typecode to MPATH_JOURNAL_UUID, MPATH_OSD_UUID and
MPATH_TOBE_UUID to
a) help the udev rules distinguish them from other devices in
devicemapper
b) allow ceph-disk to fail if an attempt is made to activate a device
with this type without accessing it via a multipath device
The 95-ceph-osd.rules call ceph-disk activate on partitions of type
MPATH_JOURNAL_UUID, MPATH_OSD_UUID. It relies on ceph-disk to do nothing
if the device is not accessed via multipath.
Loic Dachary [Mon, 17 Aug 2015 22:18:51 +0000 (00:18 +0200)]
ceph-disk: is_held must ignore multipath devices
Always return an empty list when is_held is called on a multipath
device.
The dmcrypt logic base decisions depending on the holders/slaves
relationship. Such relationships can also exists for multipath devices
but do not have the same semantic.
Loic Dachary [Mon, 17 Aug 2015 22:04:32 +0000 (00:04 +0200)]
ceph-disk: rework get_partition_{type,uuid}
Mimic the get_partition_type implementation after get_partition_uuid
and factorize them to reduce the code footprint.
The get_partition_type implementation is based on blkid: it is complex
and fragile. Since sgdisk is consistently used to create partitions, use
it instead. It is already used for get_partition_uuid and there does not
seem to be any reason for concern.
Loic Dachary [Mon, 17 Aug 2015 21:51:24 +0000 (23:51 +0200)]
ceph-disk: multipath support for split_dev_base_partnum
split_dev_base_partnum returns the path of the whole disk in
/dev/mapper. The base variable name to designate the device for the
whole disk is a misnomer since it cannot be used as a basename to
rebuild the parition device name in the case of multipath.
The logic of split_dev_base_partnum for devices is reworked to use
/sys/dev/block/M:m/partition instead of device name parsing.
Loic Dachary [Mon, 17 Aug 2015 21:25:45 +0000 (23:25 +0200)]
ceph-disk: multipath support for is_partition and list_partitions
The is_partition predicate and the list_partitions function support
devices managed by multipath.
A set of helpers dedicated to multipath devices is implemented because
the content of the corresponding /sys directory does not use the same
conventions as regular devices regarding partitions.
Instead of relying on subdirectories such as /sys/block/name/name1, the
devicemapper uuid file is used and expected to start with part\d+. The
holders/slaves directories provide pointers between the whole device and
the partition devices.
Although these structural differences reduce the opportunity for
code factorization, it is easier for backward compatibility since the
multipath specific logic is limited to if is_mpath(dev) branches.
Loic Dachary [Mon, 17 Aug 2015 21:02:40 +0000 (23:02 +0200)]
ceph-disk: --verbose shows a stack trace on error
When running with --verbose, do not hide the stack trace from the user
when an exception is raised. It is most helpful to figure out when the
exception actually happened.
Loic Dachary [Mon, 17 Aug 2015 20:52:25 +0000 (22:52 +0200)]
ceph-disk: is_mpath predicate for multipath devices
The is_mpath predicate returns True if a device is managed by
multipath. It is based on the devicemapper uuid content which is
expected to always contain the mpath- string to identify the multipath
subsystem.
The block_path helper is added to convert the path to a device to the
/sys directory that describes it. It uses the major and minor number
instead of the device name because it is more reliable. The rationale
including an actual example is added as a comment for future
maintainers.
Loic Dachary [Mon, 17 Aug 2015 20:22:12 +0000 (22:22 +0200)]
tests: ceph-disk tests may use system ceph-{mon,osd}
Allow ceph-disk.sh to run to test ceph as installed from packages.
When run from sources, ceph-disk.sh is expected to use the binaries from
the source tree. It is enough to prepend . to the PATH. There is no need
to prefix each binary with ./
The virtualenv is also only necessary when running from sources and
setting it up for ceph-detect-init is only done if in the source tree.
Loic Dachary [Sun, 16 Aug 2015 10:05:51 +0000 (12:05 +0200)]
udev: add devicemapper to partuuid-workaround
The dm-* devices are not excluded and will have by-partuuid symlinks
etc. This will include devices managed by multipath as well as
others. Since this only is used on partitions:
# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="persistent_storage_end_two"
It may create symlinks for dm-* devices that are unrelated to Ceph and
we assume this is going to be ok.
Sage Weil [Thu, 6 Aug 2015 15:57:48 +0000 (11:57 -0400)]
global: implement setuser_match_path
Allow the --setuser and --setgroup to be conditional on the
specified user/group matching the ownership of a given path.
This allows the ceph daemons to switch to user ceph for newly
deployed instances or stay as root depending on the ownership of
the data directory.
Signed-off-by: Sage Weil <sage@redhat.com> Reviewed-by: Boris Ranto <branto@redhat.com>
Boris Ranto [Thu, 18 Jun 2015 11:42:04 +0000 (13:42 +0200)]
ceph.spec.in: User and group must be created in ceph-common pre-install script
The package ceph-common uses ceph user and group but they are both created in
ceph package %pre phase. We need to move the script to ceph-common %pre phase.
Boris Ranto [Wed, 17 Jun 2015 15:55:59 +0000 (17:55 +0200)]
ceph.spec.in: Fixup uid/gid setting
We need to set the variables in the %pre phase, otherwise they are not properly
evaluated. Also use /sbin/nolongin instead of /bin/false and set the default
uid/gid pair for fedora and rhel (these were already allocated). We can also
use them for older fedora releases as they are guaranteed to be free.
Sage Weil [Fri, 24 Apr 2015 21:57:46 +0000 (14:57 -0700)]
global: add --setuser and --setgroup options
These are done after reading config files/environment and before log files
are opened. Allow a name or id to be specified. In the case of --setuser,
also switch to that user's gid, unless --setgroup is also specified.
Yehuda Sadeh [Wed, 26 Aug 2015 21:34:30 +0000 (14:34 -0700)]
rgw: init some manifest fields when handling explicit objs
Fixes: #11455
When dealing with old manifest that has explicit objs, we also
need to set the head size and head object correctly so that
code that relies on this info doesn't break.