Skip to content

Commit

Permalink
Merge pull request ceph#4532 from dachary/wip-init-system-detection
Browse files Browse the repository at this point in the history
ceph-detect-init helper and associated tests

Reviewed-by: Ken Dreyer <[email protected]>
Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Loic Dachary committed May 7, 2015
2 parents 25c23c3 + 69248bc commit 0c715f6
Show file tree
Hide file tree
Showing 43 changed files with 1,040 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ EXTRA_DIST += \
share/id_dsa_drop.ceph.com.pub

# why is it so hard to make autotools to this?
install-data-local:
install-data-local::
-mkdir -p $(DESTDIR)$(datadir)/ceph
-install -m 644 share/known_hosts_drop.ceph.com $(DESTDIR)$(datadir)/ceph/known_hosts_drop.ceph.com
-install -m 644 share/id_dsa_drop.ceph.com $(DESTDIR)$(datadir)/ceph/id_dsa_drop.ceph.com
-install -m 644 share/id_dsa_drop.ceph.com.pub $(DESTDIR)$(datadir)/ceph/id_dsa_drop.ceph.com.pub

all-local:
all-local::
if WITH_DEBUG
# We need gtest to build the rados-api tests. We only build those in
# a debug build, though.
@cd src/gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
@cd src/gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
endif

check-local: all
check-local:: all
# We build gtest this way, instead of using SUBDIRS, because with that,
# gtest's own tests would be run and that would slow us down.
@cd src/gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la
Expand Down
3 changes: 3 additions & 0 deletions ceph.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ fi
%{_bindir}/ceph-mds
%{_bindir}/ceph-objectstore-tool
%{_bindir}/ceph-osd
%{_bindir}/ceph-detect-init
%{_bindir}/librados-config
%{_bindir}/ceph-client-debug
%{_bindir}/cephfs-journal-tool
Expand Down Expand Up @@ -646,7 +647,9 @@ fi
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/ceph-mon
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/ceph-osd-mds
%endif
%{python_sitelib}/ceph_detect_init*
%{_mandir}/man8/ceph-deploy.8*
%{_mandir}/man8/ceph-detect-init.8*
%{_mandir}/man8/ceph-disk.8*
%{_mandir}/man8/ceph-mon.8*
%{_mandir}/man8/ceph-mds.8*
Expand Down
3 changes: 3 additions & 0 deletions debian/ceph.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ usr/sbin/ceph-create-keys
usr/sbin/ceph-disk
usr/sbin/ceph-disk-activate
usr/sbin/ceph-disk-prepare
usr/bin/ceph-detect-init
usr/bin/ceph-clsinfo
usr/bin/ceph-debugpack
usr/bin/ceph-mon
Expand All @@ -13,6 +14,7 @@ usr/bin/ceph-osd
usr/bin/ceph-run
usr/bin/ceph-rest-api
usr/lib/python*/dist-packages/ceph_rest_api.py
usr/lib/python*/dist-packages/ceph_detect_init*
usr/bin/crushtool
usr/bin/monmaptool
usr/bin/osdmaptool
Expand All @@ -25,6 +27,7 @@ usr/share/doc/ceph/sample.fetch_config
usr/share/man/man8/ceph-clsinfo.8
usr/share/man/man8/ceph-debugpack.8
usr/share/man/man8/ceph-deploy.8
usr/share/man/man8/ceph-detect-init.8
usr/share/man/man8/ceph-disk.8
usr/share/man/man8/ceph-mon.8
usr/share/man/man8/ceph-osd.8
Expand Down
54 changes: 54 additions & 0 deletions doc/man/8/ceph-detect-init.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
:orphan:

============================================================
ceph-detect-init -- display the init system Ceph should use
============================================================

.. program:: ceph-detect-init

Synopsis
========

| **ceph-detect-init** [--verbose] [--use-rhceph] [--default *init*]
Description
===========

:program:`ceph-detect-init` is a utility that prints the init system
Ceph uses. It can be one of ``sysvinit``, ``upstart`` or ``systemd``.
The init system Ceph uses may not be the default init system of the
host operating system. For instance on Debian Jessie, Ceph may use
``sysvinit`` although ``systemd`` is the default.

If the init system of the host operating system is unknown, return on
error, unless :option:`--default` is specified.

Options
=======

.. option:: --use-rhceph

When an operating system identifies itself as Red Hat, it is
treated as if it was CentOS. With :option:`--use-rhceph` it is
treated as RHEL instead.

.. option:: --default INIT

If the init system of the host operating system is unkown, return
the value of *INIT* instead of failing with an error.

.. option:: --verbose

Display additional information for debugging.

Availability
============

:program:`ceph-detect-init` is part of Ceph, a massively scalable, open-source, distributed storage system. Please refer to
the Ceph documentation at http://ceph.com/docs for more information.

See also
========

:doc:`ceph-disk <ceph-disk>`\(8),
:doc:`ceph-deploy <ceph-deploy>`\(8)
22 changes: 20 additions & 2 deletions doc/man/8/ceph-disk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Synopsis
[--fs-type *xfs|ext4|btrfs*] [*data-path*] [*journal-path*]
| **ceph-disk** **activate** [*data-path*] [--activate-key *path*]
[--mark-init *sysvinit|upstart|systemd|auto|none*]
[--no-start-daemon]
| **ceph-disk** **activate-all**
Expand Down Expand Up @@ -76,8 +78,24 @@ Usage::

ceph-disk activate [PATH] [--activate-key PATH]

Another option :option:`--mark-init` can also be used with this subcommand.
``--mark-init`` provides init system to manage the OSD directory.
Another option :option:`--mark-init` can also be used with this
subcommand. ``--mark-init`` provides init system to manage the OSD
directory. It defaults to ``auto`` which detects the init system
suitable for ceph (either ``sysvinit``, ``systemd`` or
``upstart``). The argument can be used to override the init system. It
may be convenient when an operating system supports multiple init
systems, such as Debian GNU/Linux jessie with ``systemd`` and
``sysvinit``. If the argument is ``none``, the OSD is not marked with
any init system and ``ceph-disk activate`` needs to be called
explicitely after each reboot.


Usage::

ceph-disk activate [PATH] [--mark-init *sysvinit|upstart|systemd|auto|none*]

If the option :option:`--no-start-daemon` is given, the activation
steps are performed but the OSD daemon is not started.

activate-journal
----------------
Expand Down
25 changes: 24 additions & 1 deletion install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Ceph distributed storage system
#
# Copyright (C) 2014 Red Hat <[email protected]>
# Copyright (C) 2014, 2015 Red Hat <[email protected]>
#
# Author: Loic Dachary <[email protected]>
#
Expand Down Expand Up @@ -83,3 +83,26 @@ CentOS|Fedora|RedHatEnterpriseServer)
echo "$(lsb_release -si) is unknown, dependencies will have to be installed manually."
;;
esac

#
# preload python modules so that tox can run without network access
#
for interpreter in python2.7 python3 ; do
type $interpreter > /dev/null 2>&1 || continue
rm -fr install-deps
virtualenv --python $interpreter install-deps
. install-deps/bin/activate
pip install wheel
find . -name tox.ini | while read ini ; do
(
cd $(dirname $ini)
require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
if test "$require" ; then
# although pip comes with virtualenv, having a recent version
# of pip matters when it comes to using wheel packages
pip wheel $require 'distribute >= 0.7' 'pip >= 6.1'
fi
)
done
done
rm -fr install-deps
6 changes: 5 additions & 1 deletion make-debs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ fi
# b) do not sign the packages
# c) use half of the available processors
#
PATH=/usr/lib/ccache:$PATH dpkg-buildpackage -j$(($(nproc) / 2)) -uc -us
: ${NPROC:=$(($(nproc) / 2))}
if test $NPROC -gt 1 ; then
j=-j${NPROC}
fi
PATH=/usr/lib/ccache:$PATH dpkg-buildpackage $j -uc -us
cd ../..
mkdir -p $codename/conf
cat > $codename/conf/distributions <<EOF
Expand Down
1 change: 1 addition & 0 deletions man/Makefile-server.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ endif
if WITH_OSD
dist_man_MANS += \
ceph-clsinfo.8 \
ceph-detect-init.8 \
ceph-disk.8 \
ceph-osd.8 \
osdmaptool.8
Expand Down
9 changes: 5 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif
include arch/Makefile.am
include auth/Makefile.am
include brag/Makefile.am
include ceph-detect-init/Makefile.am
include crush/Makefile.am
include mon/Makefile.am
include mds/Makefile.am
Expand Down Expand Up @@ -151,7 +152,7 @@ TESTS = \
$(check_TESTPROGRAMS) \
$(check_SCRIPTS)

check-local:
check-local::
$(top_srcdir)/qa/workunits/erasure-code/encode-decode-non-regression.sh
$(srcdir)/test/encoding/readable.sh ../ceph-object-corpus

Expand Down Expand Up @@ -205,7 +206,7 @@ CLEANFILES += ceph_ver.h sample.fetch_config

# cleaning

clean-local:
clean-local::
rm -f *.so
find . -name '*.gcno' -o -name '*.gcda' -o -name '*.lcov' -o -name "*.o" -o -name "*.lo" | xargs rm -f
rm -f ceph java/java/com/ceph/crush/Bucket.class
Expand Down Expand Up @@ -255,12 +256,12 @@ if ENABLE_COVERAGE
-test/coverage.sh -d $(srcdir) -o check-coverage make check
endif

install-data-local: install-coverage
install-data-local:: install-coverage
-mkdir -p $(DESTDIR)$(sysconfdir)/ceph
-mkdir -p $(DESTDIR)$(localstatedir)/log/ceph
-mkdir -p $(DESTDIR)$(localstatedir)/lib/ceph/tmp

uninstall-local: uninstall-coverage
uninstall-local:: uninstall-coverage
-rmdir -p $(DESTDIR)$(sysconfdir)/ceph/
-rmdir -p $(DESTDIR)$(localstatedir)/log/ceph
-rmdir -p $(DESTDIR)$(localstatedir)/lib/ceph/tmp
Expand Down
13 changes: 13 additions & 0 deletions src/ceph-detect-init/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*~
*.pyc
*.pyo
.coverage
.tox
*.egg-info
*.egg
dist
build
wheelhouse
*.log
*.trs

2 changes: 2 additions & 0 deletions src/ceph-detect-init/AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Owen Synge <[email protected]>
- Loic Dachary <[email protected]>
1 change: 1 addition & 0 deletions src/ceph-detect-init/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include AUTHORS.rst
69 changes: 69 additions & 0 deletions src/ceph-detect-init/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# Copyright (C) 2015 SUSE LINUX GmbH
# Copyright (C) 2015 <[email protected]>
#
# Author: Owen Synge <[email protected]>
# Author: Loic Dachary <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see `<http://www.gnu.org/licenses/>`.
#
check_SCRIPTS += ceph-detect-init/run-tox.sh

EXTRA_DIST += \
ceph-detect-init/AUTHORS.rst \
ceph-detect-init/ceph_detect_init/centos/__init__.py \
ceph-detect-init/ceph_detect_init/exc.py \
ceph-detect-init/ceph_detect_init/main.py \
ceph-detect-init/ceph_detect_init/__init__.py \
ceph-detect-init/ceph_detect_init/rhel/__init__.py \
ceph-detect-init/ceph_detect_init/fedora/__init__.py \
ceph-detect-init/ceph_detect_init/debian/__init__.py \
ceph-detect-init/ceph_detect_init/suse/__init__.py \
ceph-detect-init/integration/centos-6.dockerfile \
ceph-detect-init/integration/debian-wheezy.dockerfile \
ceph-detect-init/integration/debian-sid.dockerfile \
ceph-detect-init/integration/debian-jessie.dockerfile \
ceph-detect-init/integration/opensuse-13.1.dockerfile \
ceph-detect-init/integration/fedora-21.dockerfile \
ceph-detect-init/integration/ubuntu-14.04.dockerfile \
ceph-detect-init/integration/test_main.py \
ceph-detect-init/integration/opensuse-13.2.dockerfile \
ceph-detect-init/integration/ubuntu-12.04.dockerfile \
ceph-detect-init/integration/centos-7.dockerfile \
ceph-detect-init/integration/ubuntu-15.04.dockerfile \
ceph-detect-init/integration/debian-squeeze.dockerfile \
ceph-detect-init/Makefile.am \
ceph-detect-init/MANIFEST.in \
ceph-detect-init/README.rst \
ceph-detect-init/requirements.txt \
ceph-detect-init/run-tox.sh \
ceph-detect-init/setup.py \
ceph-detect-init/test-requirements.txt \
ceph-detect-init/tests/test_all.py \
ceph-detect-init/tox.ini

all-local::
cd ceph-detect-init ; python setup.py build

clean-local::
cd ceph-detect-init ; python setup.py clean ; rm -fr wheelhouse .tox build .coverage *.egg-info

install-data-local::
cd ceph-detect-init ; \
if lsb_release -si | grep --quiet 'Ubuntu\|Debian\|Devuan' ; then \
options=--install-layout=deb ; \
else \
options=--prefix=/usr ; \
fi ; \
python setup.py install --root=$(DESTDIR) $$options
28 changes: 28 additions & 0 deletions src/ceph-detect-init/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ceph-detect-init
================

ceph-detect-init is a command line tool that displays a normalized
string describing the init system of the host on which it is running:

Home page : https://pypi.python.org/pypi/ceph-detect-init

Hacking
=======

* Get the code : git clone https://git.ceph.com/ceph.git
* Run the unit tests : tox
* Run the integration tests (requires docker) : tox -e integration
* Check the documentation : rst2html < README.rst > /tmp/a.html
* Prepare a new version

- version=1.0.0 ; perl -pi -e "s/^version.*/version='$version',/" setup.py ; do python setup.py sdist ; amend=$(git log -1 --oneline | grep --quiet "version $version" && echo --amend) ; git commit $amend -m "version $version" setup.py ; git tag -a -f -m "version $version" $version ; done

* Publish a new version

- python setup.py sdist upload --sign
- git push ; git push --tags

* pypi maintenance

- python setup.py register # if the project does not yet exist
- trim old versions at https://pypi.python.org/pypi/ceph-detect-init
Loading

0 comments on commit 0c715f6

Please sign in to comment.