Wait! No-one's "hacking" anything. The aim of this document is to enable new developers/users get familiarised with the build tools and MicroCeph codebase so that they can build and contribute to the MicroCeph Codebase.
A snap is a bundle of an app and its dependencies that works without modification across Linux distributions.
Apart from being a self-contained artifact, being a snap enables MicroCeph to be isolated from host and provide a clean and consistent building, installing and cleanup experience.
The microceph snap packages all the required ceph-binaries, dqlite and a small management daemon (microcephd) which ties all of this together. Using the light-weight distributed dqlite layer, MicroCeph enables orchestration of a ceph cluster in a centralised and easy to use manner.
Snaps are built and published using another snap called snapcraft. It uses lxd to pull dependencies and build an artifact completely isolated from the host system. This makes it easier for developers to work on MicroCeph without polluting their host system with unwanted dependencies. You can install snapcraft and lxd using snap tool.
sudo snap install snapcraft --classic
sudo snap install lxd
NOTE: For a detailed how-to-use snapcraft tool guide, check-out Snap-Tutorials
The MicroCeph codebase resides inside the microceph sub-directory of the repo. This subdir is neatly organised into parts which make up the whole of MicroCeph. Below is a brief description of what can be found in each of those parts for reference.
-
Contains files related to the internal REST APIs which the microceph client uses to communicate to the microceph daemon. It also contains a types subdir which has necessary data structures for the APIs.
-
Contains files directly related to ceph orchestration. This includes code for ceph cluster configuration, service orchestration etc.
-
Contains REST client code which is used by microceph CLI for interacting with microceph daemon.
-
Contains microceph CLI commands written with Cobra Commands
-
Contains common code
-
Contains DQlite schema and migration definitions along with generated mappers for DB interfacing.
-
Contains mock definitions for unit testing
Building MicroCeph is as easy as a snap!
# v for verbose output of the build process.
snapcraft -v
...
Creating snap package
...
Created snap package microceph_0+git.ac1da26_amd64.snap
The newly created .snap artifact can then be installed as
# Dangerous flag for locally built snap
sudo snap install --dangerous microceph_*.snap
# Locally built snaps do no auto-connect the available plugs on install, they can be connected manually using;
sudo snap connect microceph:block-devices
sudo snap connect microceph:hardware-observe
sudo snap connect microceph:dm-crypt
sudo snap restart microceph.daemon
The MicroCeph makefile has targets for running unit tests and lint checks. They can be run as follows.
# Note: commands executed from microceph subdir which contains the Makefile.
# Run unit tests
make check-unit
# Run static checks
make check-static