Pacemaker Development¶
Working with the Pacemaker Code Base
Abstract¶
This document has guidelines and tips for developers interested in editing Pacemaker source code and submitting changes for inclusion in the project. Start with the FAQ; the rest is optional detail.
Table of Contents¶
1. Frequently Asked Questions¶
- Q
Who is this document intended for?
- A
Anyone who wishes to read and/or edit the Pacemaker source code. Casual contributors should feel free to read just this FAQ, and consult other chapters as needed.
- Q
Where is the source code for Pacemaker?
- A
The source code for Pacemaker is kept on GitHub, as are all software projects under the ClusterLabs umbrella. Pacemaker uses Git for source code management. If you are a Git newbie, the gittutorial(7) man page is an excellent starting point. If you’re familiar with using Git from the command line, you can create a local copy of the Pacemaker source code with: git clone https://github.com/ClusterLabs/pacemaker.git
- Q
What are the different Git branches and repositories used for?
- A
The master branch is the primary branch used for development.
The 2.1 branch is the current release branch. Normally, it does not receive any changes, but during the release cycle for a new release, it will contain release candidates. During the release cycle, certain bug fixes will go to the 2.1 branch first (and be pulled into master later).
The 2.0 branch, 1.1 branch, and separate 1.0 repository are frozen snapshots of earlier release series, no longer being developed.
Messages will be posted to the developers@ClusterLabs.org mailing list during the release cycle, with instructions about which branches to use when submitting requests.
- Q
How do I build from the source code?
- A
See INSTALL.md in the main checkout directory.
- Q
What coding style should I follow?
- A
You’ll be mostly fine if you simply follow the example of existing code. When unsure, see the relevant chapter of this document for language-specific recommendations. Pacemaker has grown and evolved organically over many years, so you will see much code that doesn’t conform to the current guidelines. We discourage making changes solely to bring code into conformance, as any change requires developer time for review and opens the possibility of adding bugs. However, new code should follow the guidelines, and it is fine to bring lines of older code into conformance when modifying that code for other reasons.
- Q
How should I format my Git commit messages?
- A
An example is “Feature: scheduler: wobble the frizzle better”.
The first part is the type of change, used to automatically generate the change log for the next release. Commit messages with the following will be included in the change log:
Feature for new features
Fix for bug fixes (Bug or High also work)
API for changes to the public API
Everything else will not automatically be in the change log, and so don’t really matter, but types commonly used include:
Log for changes to log messages or handling
Doc for changes to documentation or comments
Test for changes in CTS and regression tests
Low, Med, or Mid for bug fixes not significant enough for a change log entry
Refactor for refactoring-only code changes
Build for build process changes
The next part is the name of the component(s) being changed, for example, controller or libcrmcommon (it’s more free-form, so don’t sweat getting it exact).
The rest briefly describes the change. The git project recommends the entire summary line stay under 50 characters, but more is fine if needed for clarity.
Except for the most simple and obvious of changes, the summary should be followed by a blank line and a longer explanation of why the change was made.
- Q
How can I test my changes?
- A
Most importantly, Pacemaker has regression tests for most major components; these will automatically be run for any pull requests submitted through GitHub. Additionally, Pacemaker’s Cluster Test Suite (CTS) can be used to set up a test cluster and run a wide variety of complex tests. This document will have more detail on testing in the future.
- Q
What is Pacemaker’s license?
- A
Except where noted otherwise in the file itself, the source code for all Pacemaker programs is licensed under version 2 or later of the GNU General Public License (GPLv2+), its headers and libraries under version 2.1 or later of the less restrictive GNU Lesser General Public License (LGPLv2.1+), its documentation under version 4.0 or later of the Creative Commons Attribution-ShareAlike International Public License (CC-BY-SA-4.0), and its init scripts under the Revised BSD license. If you find any deviations from this policy, or wish to inquire about alternate licensing arrangements, please e-mail the developers@ClusterLabs.org mailing list. Licensing issues are also discussed on the ClusterLabs wiki.
- Q
How can I contribute my changes to the project?
- A
Contributions of bug fixes or new features are very much appreciated! Patches can be submitted as pull requests via GitHub (the preferred method, due to its excellent features), or e-mailed to the developers@ClusterLabs.org mailing list as an attachment in a format Git can import. Authors may only submit changes that they have the right to submit under the open source license indicated in the affected files.
- Q
What if I still have questions?
- A
Ask on the developers@ClusterLabs.org mailing list for development-related questions, or on the users@ClusterLabs.org mailing list for general questions about using Pacemaker. Developers often also hang out on freenode’s #clusterlabs IRC channel.
2. General Guidelines for All Languages¶
2.1. Copyright¶
When copyright notices are added to a file, they should look like this:
Note
Copyright Notice Format
The first YYYY is the year the file was originally published. The original date is important for two reasons: when two entities claim copyright ownership of the same work, the earlier claim generally prevails; and copyright expiration is generally calculated from the original publication date. 1
If the file is modified in later years, add -YYYY with the most recent year of modification. Even though Pacemaker is an ongoing project, copyright notices are about the years of publication of specific content.
Copyright notices are intended to indicate, but do not affect, copyright ownership, which is determined by applicable laws and regulations. Authors may put more specific copyright notices in their commit messages if desired.
Footnotes
- 1
See the U.S. Copyright Office’s “Compendium of U.S. Copyright Office Practices”, particularly “Chapter 2200: Notice of Copyright”, sections 2205.1(A) and 2205.1(F), or “Updating Copyright Notices” for a more readable summary.
3. Python Coding Guidelines¶
3.1. Python Boilerplate¶
If a Python file is meant to be executed (as opposed to imported), it should
have a .in extension, and its first line should be:
#!@PYTHON@
which will be replaced with the appropriate python executable when Pacemaker is
built. To make that happen, add an entry to CONFIG_FILES_EXEC() in
configure.ac, and add the file name without .in to .gitignore (see
existing examples).
After the above line if any, every Python file should start like this:
""" <BRIEF-DESCRIPTION>
"""
__copyright__ = "Copyright <YYYY[-YYYY]> the Pacemaker project contributors"
__license__ = "<LICENSE> WITHOUT ANY WARRANTY"
<BRIEF-DESCRIPTION> is obviously a brief description of the file’s purpose. The string may contain any other information typically used in a Python file docstring.
<LICENSE> should follow the policy set forth in the
COPYING file,
generally one of “GNU General Public License version 2 or later (GPLv2+)”
or “GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)”.
3.2. Python Version Compatibility¶
Pacemaker targets compatibility with Python 3.4 and later.
Do not use features not available in all targeted Python versions. An
example is the subprocess.run() function.
3.3. Formatting Python Code¶
Indentation must be 4 spaces, no tabs.
Do not leave trailing whitespace.
Lines should be no longer than 80 characters unless limiting line length significantly impacts readability. For Python, this limitation is flexible since breaking a line often impacts readability, but definitely keep it under 120 characters.
Where not conflicting with this style guide, it is recommended (but not required) to follow PEP 8.
It is recommended (but not required) to format Python code such that
pylint --disable=line-too-long,too-many-lines,too-many-instance-attributes,too-many-arguments,too-many-statementsproduces minimal complaints (even better if you don’t need to disable all those checks).
4. C Coding Guidelines¶
Pacemaker is a large project accepting contributions from developers with a wide range of skill levels and organizational affiliations, and maintained by multiple people over long periods of time. Following consistent guidelines makes reading, writing, and reviewing code easier, and helps avoid common mistakes.
Some existing Pacemaker code does not follow these guidelines, for historical reasons and API backward compatibility, but new code should.
4.1. Code Organization¶
Pacemaker’s C code is organized as follows:
Directory |
Contents |
|---|---|
daemons |
the Pacemaker daemons (pacemakerd, pacemaker-based, etc.) |
include |
header files for library APIs |
lib |
libraries |
tools |
command-line tools |
Source file names should be unique across the entire project, to allow for
individual tracing via PCMK_trace_files.
4.2. Pacemaker Libraries¶
Library |
Symbol prefix |
Source location |
API Headers |
Description |
|---|---|---|---|---|
libcib |
cib |
lib/cib |
include/crm/cib.h
include/crm/cib/*
|
API for pacemaker-based IPC and the CIB |
libcrmcluster |
pcmk |
lib/cluster |
include/crm/cluster.h
include/crm/cluster/*
|
Abstract interface to underlying cluster layer |
libcrmcommon |
pcmk |
lib/common |
include/crm/common/*
some of include/crm/*
|
Everything else |
libcrmservice |
svc |
lib/services |
include/crm/services.h
|
Abstract interface to supported resource types (OCF, LSB, etc.) |
liblrmd |
lrmd |
lib/lrmd |
include/crm/lrmd*.h
|
API for pacemaker-execd IPC |
libpacemaker |
pcmk |
lib/pacemaker |
include/pacemaker*.h
include/pcmki/*
|
High-level APIs equivalent to command-line tool capabilities (and high-level internal APIs) |
libpe_rules |
pe |
lib/pengine |
include/crm/pengine/*
|
Scheduler functionality related to evaluating rules |
libpe_status |
pe |
lib/pengine |
include/crm/pengine/*
|
Low-level scheduler functionality |
libstonithd |
stonith |
lib/fencing |
include/crm/stonith-ng.h
include/crm/fencing/*
|
API for pacemaker-fenced IPC |
4.2.1. Public versus Internal APIs¶
Pacemaker libraries have both internal and public APIs. Internal APIs are those used only within Pacemaker; public APIs are those offered (via header files and documentation) for external code to use.
Generic functionality needed by Pacemaker itself, such as string processing or XML processing, should remain internal, while functions providing useful high-level access to Pacemaker capabilities should be public. When in doubt, keep APIs internal, because it’s easier to expose a previously internal API than hide a previously public API.
Internal APIs can be changed as needed.
The public API/ABI should maintain a degree of stability so that external applications using it do not need to be rewritten or rebuilt frequently. Many OSes/distributions avoid breaking API/ABI compatibility within a major release, so if Pacemaker breaks compatibility, that significantly delays when OSes can package the new version. Therefore, changes to public APIs should be backward-compatible (as detailed throughout this chapter), unless we are doing a (rare) release where we specifically intend to break compatibility.
External applications known to use Pacemaker’s public C API include sbd and dlm_controld.
4.2.2. API Documentation¶
Pacemaker uses Doxygen
to automatically generate its
online API documentation,
so all public API (header files, functions, structs, enums, etc.) should be
documented with Doxygen comment blocks. Other code may be documented in the
same way if desired, with an \internal tag in the Doxygen comment.
Simple example of an internal function with a Doxygen comment block:
/*!
* \internal
* \brief Return string length plus 1
*
* Return the number of characters in a given string, plus one.
*
* \param[in] s A string (must not be NULL)
*
* \return The length of \p s plus 1.
*/
static int
f(const char *s)
{
return strlen(s) + 1;
}
4.2.3. API Header File Naming¶
Internal API headers should be named ending in
_internal.h, in the same location as public headers, with the exception of libpacemaker, which for historical reasons keeps internal headers ininclude/pcmki/pcmki_*.h).If a library needs to share symbols just within the library, header files for these should be named ending in
_private.hand located in the library source directory (notinclude). Such functions should be declared asG_GNUC_INTERNAL, to aid compiler efficiency (glib defines this symbol appropriately for the compiler).
Header files that are not library API are located in the same locations as other source code.
4.2.4. API Symbol Naming¶
Exposed API symbols (non-static function names, struct and typedef
names in header files, etc.) must begin with the prefix appropriate to the
library (shown in the table at the beginning of this section). This reduces the
chance of naming collisions when external software links against the library.
The prefix is usually lowercase but may be all-caps for some defined constants and macros.
Public API symbols should follow the library prefix with a single underbar
(for example, pcmk_something), and internal API symbols with a double
underbar (for example, pcmk__other_thing).
File-local symbols (such as static functions) and non-library code do not require a prefix, though a unique prefix indicating an executable (controld, crm_mon, etc.) can be helpful to indicate symbols shared between multiple source files for the executable.
4.3. C Boilerplate¶
Every C file should start with a short copyright and license notice:
/*
* Copyright <YYYY[-YYYY]> the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under <LICENSE> WITHOUT ANY WARRANTY.
*/
<LICENSE> should follow the policy set forth in the COPYING file, generally one of “GNU General Public License version 2 or later (GPLv2+)” or “GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)”.
Header files should additionally protect against multiple inclusion by defining
a unique symbol of the form PCMK__<capitalized_header_name>__H. For
example:
#ifndef PCMK__MY_HEADER__H
# define PCMK__MY_HEADER__H
// header code here
#endif // PCMK__MY_HEADER__H
Public API header files should additionally declare “C” compatibility for inclusion by C++, and give a Doxygen file description. For example:
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \file
* \brief My brief description here
* \ingroup core
*/
// header code here
#ifdef __cplusplus
}
#endif
4.4. Line Formatting¶
Indentation must be 4 spaces, no tabs.
Do not leave trailing whitespace.
Lines should be no longer than 80 characters unless limiting line length hurts readability.
4.5. Comments¶
/* Single-line comments may look like this */
// ... or this
/* Multi-line comments should start immediately after the comment opening.
* Subsequent lines should start with an aligned asterisk. The comment
* closing should be aligned and on a line by itself.
*/
4.6. Variables¶
Pointers:
/* (1) The asterisk goes by the variable name, not the type;
* (2) Avoid leaving pointers uninitialized, to lessen the impact of
* use-before-assignment bugs
*/
char *my_string = NULL;
// Use space before asterisk and after closing parenthesis in a cast
char *foo = (char *) bar;
Global variables should be avoided in libraries when possible. State information should instead be passed as function arguments (often as a structure). This is not for thread safety – Pacemaker’s use of forking ensures it will never be threaded – but it does minimize overhead, improve readability, and avoid obscure side effects.
Time intervals are sometimes represented in Pacemaker code as user-defined text specifications (for example, “10s”), other times as an integer number of seconds or milliseconds, and still other times as a string representation of an integer number. Variables for these should be named with an indication of which is being used (for example, use
interval_spec,interval_ms, orinterval_ms_sinstead ofinterval).
4.7. Operators¶
// Operators have spaces on both sides
x = a;
/* (1) Do not rely on operator precedence; use parentheses when mixing
* operators with different priority, for readability.
* (2) No space is used after an opening parenthesis or before a closing
* parenthesis.
*/
x = a + b - (c * d);
4.8. Control Statements (if, else, while, for, switch)¶
/*
* (1) The control keyword is followed by a space, a left parenthesis
* without a space, the condition, a right parenthesis, a space, and the
* opening bracket on the same line.
* (2) Always use braces around control statement blocks, even if they only
* contain one line. This makes code review diffs smaller if a line gets
* added in the future, and avoids the chance of bad indenting making a
* line incorrectly appear to be part of the block.
* (3) The closing bracket is on a line by itself.
*/
if (v < 0) {
return 0;
}
/* "else" and "else if" are on the same line with the previous ending brace
* and next opening brace, separated by a space. Blank lines may be used
* between blocks to help readability.
*/
if (v > 0) {
return 0;
} else if (a == 0) {
return 1;
} else {
return 2;
}
/* Do not use assignments in conditions. This ensures that the developer's
* intent is always clear, makes code reviews easier, and reduces the chance
* of using assignment where comparison is intended.
*/
// Do this ...
a = f();
if (a) {
return 0;
}
// ... NOT this
if (a = f()) {
return 0;
}
/* It helps readability to use the "!" operator only in boolean
* comparisons, and explicitly compare numeric values against 0,
* pointers against NULL, etc. This helps remind the reader of the
* type being compared.
*/
int i = 0;
char *s = NULL;
bool cond = false;
if (!cond) {
return 0;
}
if (i == 0) {
return 0;
}
if (s == NULL) {
return 0;
}
/* In a "switch" statement, indent "case" one level, and indent the body of
* each "case" another level.
*/
switch (expression) {
case 0:
command1;
break;
case 1:
command2;
break;
default:
command3;
break;
}
4.9. Structures¶
Changes to structures defined in public API headers (adding or removing members, or changing member types) are generally not possible without breaking API compatibility. However, there are exceptions:
Public API structures can be designed such that they can be allocated only via API functions, not declared directly or allocated with standard memory functions using
sizeof.This can be enforced simply by documentating the limitation, in which case new
structmembers can be added to the end of the structure without breaking compatibility.Alternatively, the structure definition can be kept in an internal header, with only a pointer type definition kept in a public header, in which case the structure definition can be changed however needed.
4.10. Enumerations¶
New values should usually be added to the end of public API enumerations, because the compiler will define the values to 0, 1, etc., in the order given, and inserting a value in the middle would change the numerical values of all later values, breaking code compiled with the old values. However, if enum numerical values are explicitly specified rather than left to the compiler, new values can be added anywhere.
When defining constant integer values, enum should be preferred over
#defineorconstwhen possible. This allows type checking without consuming memory.
4.10.1. Flag groups¶
Pacemaker often uses flag groups (also called bit fields or bitmasks) for a collection of boolean options (flags/bits).
This is more efficient for storage and manipulation than individual booleans, but its main advantage is when used in public APIs, because using another bit in a bitmask is backward compatible, whereas adding a new function argument (or sometimes even a structure member) is not.
#include <stdint.h>
/* (1) Define an enumeration to name the individual flags, for readability.
* An enumeration is preferred to a series of "#define" constants
* because it is typed, and logically groups the related names.
* (2) Define the values using left-shifting, which is more readable and
* less error-prone than hexadecimal literals (0x0001, 0x0002, 0x0004,
* etc.).
* (3) Using a comma after the last entry makes diffs smaller for reviewing
* if a new value needs to be added or removed later.
*/
enum pcmk__some_bitmask_type {
pcmk__some_value = (1 << 0),
pcmk__other_value = (1 << 1),
pcmk__another_value = (1 << 2),
};
/* The flag group itself should be an unsigned type from stdint.h (not
* the enum type, since it will be a mask of the enum values and not just
* one of them). uint32_t is the most common, since we rarely need more than
* 32 flags, but a smaller or larger type could be appropriate in some
* cases.
*/
uint32_t flags = pcmk__some_value|pcmk__other_value;
/* If the values will be used only with uint64_t, define them accordingly,
* to make compilers happier.
*/
enum pcmk__something_else {
pcmk__whatever = (UINT64_C(1) << 0),
};
We have convenience functions for checking flags (see pcmk_any_flags_set(),
pcmk_all_flags_set(), and pcmk_is_set()) as well as setting and
clearing them (see pcmk__set_flags_as() and pcmk__clear_flags_as(),
usually used via wrapper macros defined for specific flag groups). These
convenience functions should be preferred to direct bitwise arithmetic, for
readability and logging consistency.
4.11. Functions¶
Function names should be unique across the entire project, to allow for
individual tracing via PCMK_trace_functions, and make it easier to search
code and follow detail logs.
4.11.1. Function Definitions¶
/*
* (1) The return type goes on its own line
* (2) The opening brace goes by itself on a line
* (3) Use "const" with pointer arguments whenever appropriate, to allow the
* function to be used by more callers.
*/
int
my_func1(const char *s)
{
return 0;
}
/* Functions with no arguments must explicitly list them as void,
* for compatibility with strict compilers
*/
int
my_func2(void)
{
return 0;
}
/*
* (1) For functions with enough arguments that they must break to the next
* line, align arguments with the first argument.
* (2) When a function argument is a function itself, use the pointer form.
* (3) Declare functions and file-global variables as ``static`` whenever
* appropriate. This gains a slight efficiency in shared libraries, and
* helps the reader know that it is not used outside the one file.
*/
static int
my_func3(int bar, const char *a, const char *b, const char *c,
void (*callback)())
{
return 0;
}
4.11.2. Return Values¶
Functions that need to indicate success or failure should follow one of the
following guidelines. More details, including functions for using them in user
messages and converting from one to another, can be found in
include/crm/common/results.h.
A standard Pacemaker return code is one of the
pcmk_rc_*enum values or a system errno code, as anint.crm_exit_t(theCRM_EX_*enum values) is a system-independent code suitable for the exit status of a process, or for interchange between nodes.Other special-purpose status codes exist, such as
enum ocf_exitcodefor the possible exit statuses of OCF resource agents (along with some Pacemaker-specific extensions). It is usually obvious when the context calls for such.Some older Pacemaker APIs use the now-deprecated “legacy” return values of
pcmk_okor the positive or negative value of one of thepcmk_err_*constants or system errno codes.Functions registered with external libraries (as callbacks for example) should use the appropriate signature defined by those libraries, rather than follow Pacemaker guidelines.
Of course, functions may have return values that aren’t success/failure indicators, such as a pointer, integer count, or bool.
4.11.3. Public API Functions¶
Unless we are doing a (rare) release where we break public API compatibility, new public API functions can be added, but existing function signatures (return type, name, and argument types) should not be changed. To work around this, an existing function can become a wrapper for a new function.
4.12. Memory Management¶
Always use
calloc()rather thanmalloc(). It has no additional cost on modern operating systems, and reduces the severity and security risks of uninitialized memory usage bugs.Ensure that all dynamically allocated memory is freed when no longer needed, and not used after it is freed. This can be challenging in the more event-driven, callback-oriented sections of code.
Free dynamically allocated memory using the free function corresponding to how it was allocated. For example, use
free()withcalloc(), andg_free()with most glib functions that allocate objects.
4.13. Logging¶
When format strings are used for derived data types whose implementation may vary across platforms (
pid_t,time_t, etc.), the safest approach is to use%lldin the format string, and cast the value tolong long.Do not pass
NULLas an argument to satisfy the%sformat specifier in logging (and more generally,printf-style) functions. When the string “<null>” is a sufficient output representation in such case, you can use thecrm_str()convenience macro; otherwise, the ternary operator is an obvious choice.Do not rely on
%shandlingNULLvalues properly. While the standard library functions might, not all Pacemaker API using them does, and it’s safest to get in the habit of always ensuring format values are non-NULL.
4.14. Regular Expressions¶
Use
REG_NOSUBwithregcomp()whenever possible, for efficiency.Be sure to use
regfree()appropriately.
4.15. Makefiles¶
Pacemaker uses automake for building, so the Makefile.am in each directory should be edited rather than Makefile.in or Makefile, which are automatically generated.
Public API headers are installed (by adding them to a
HEADERSvariable inMakefile.am), but internal API headers are not (by adding them tonoinst_HEADERS).
4.16. vim Settings¶
Developers who use vim to edit source code can add the following settings
to their ~/.vimrc file to follow Pacemaker C coding guidelines:
" follow Pacemaker coding guidelines when editing C source code files
filetype plugin indent on
au FileType c setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4 textwidth=80
autocmd BufNewFile,BufRead *.h set filetype=c
let c_space_errors = 1
5. Evolution of the project¶
5.1. Foreword¶
This chapter is currently not meant as a definite summary of how Pacemaker got into where it stands now, but rather to provide few valuable pointers an entusiasts (presumably software archeologist type of person) may find useful. Moreover, well-intentioned contributors to Pacemaker project may want to review them occasionally since, as the famous quote has it, “those who do not learn history are doomed to repeat it”.
For anything more talkative with less emphasis on actual code, other places will serve better for the time being (and if not, should not be too hard to volunteer extensions to those writeups):
5.2. Ancestor: Heartbeat project¶
Pacemaker can be considered as a spin-off from Heartbeat, the original comprehensive high availability suite started by Alan Robertson. Some portions of code are shared, at least on the conceptual level if not verbatim, till today, even if the effective percentage continually declines. Note that till Pacemaker 2.0, it also used to stand for one (and initially the only) of supported messaging back-ends (removal of this support made for one such notable drop of reused code), see also pre-2.0 commit 55ab749bf.
An archive of a 2016 checkout of the Heartbeat code base is shared as a dedicated read-only repository , and anchored there, the most notable commits are:
Regarding Pacemaker’s split from heartbeat, it evolved stepwise (as opposed to one-off cut), and the last step of full dependency is depicted in The Corosync Cluster Engine paper, fig. 10. This article also provides a good reference regarding wider historical context of the tangentially (and deeper in some cases) meeting components around that time.
5.3. Notable Restructuring Steps in the Codebase¶
File renames may not appear as notable … unless one runs into complicated
git blame and git log scenarios, so some more massive ones may be
stated as well.
watchdog/’sbd’ functionality spin-off:
daemons’ rename for 2.0 (in chronological order)
6. Advanced Hacking on the Project¶
6.1. Foreword¶
This chapter aims to be a gentle introduction (or perhaps, rather a summarization of advanced techniques we developed for backreferences) to how deal with the Pacemaker internals effectively. For instance, how to:
debug with an ease
verify various interesting interaction-based properties
or simply put, all that is in the interest of the core contributors on the project to know, master, and (preferably) also evolve – way beyond what is in the presumed repertoire of a generic contributor role, which is detailed in other chapters of this guide.
Therefore, if you think you will not benefit from any such details in the scope of this chapter, feel free to skip it.
6.2. Debugging¶
In the GNU userland tradition, preferred way of debugging is based on gdb
(directly or via specific frontends atop) that is widely available on platforms
(semi-)supported with Pacemaker itself.
To make some advanced debugging easier, we maintain a script defining some
useful helpers in devel/gdbhelpers file, which you can make available
in the debugging session easily when invoking it as
gdb -x <path-to-gdbhelpers> ....
From within the debugger, you can then invoke the new pcmk command that
will guide you regarding other helper functions available, so we won’t
replicate that here.
6.3. Working with mocked daemons¶
Since the Pacemaker run-time consists of multiple co-operating daemons as detailed elsewhere, tracking down the interaction details amongst them can be rather cumbersome. Since rebuilding existing daemons in a more modular way as opposed to clusters of mutually dependent functions, we elected to grow separate bare-bones counterparts built evolutionary as skeletons just to get the basic (long-term stabilized) communication with typical daemon clients going, and to add new modules in their outer circles (plus minimalistic hook support at those cores) on a demand-driven basis.
The code for these is located at maint/mocked; for instance,
based-notifyfenced.c module of based.c skeleton mocking
pacemaker-based daemon was exactly to fulfill investigation helper
role (the case at hand was also an impulse to kick off this very
sort of maintenance support material, to begin with).
Non-trivial knowledge of Pacemaker internals and other skills are needed to use such devised helpers, but given the other way around, some sorts of investigation may be even heftier, it may be the least effort choice. And when that’s the case, advanced contributors are expected to contribute their own extensions they used to validate the reproducibility/actual correctness of the fix along the actual code modifications. This way, the rest of the development teams is not required to deal with elaborate preconditions, be at guess, or even forced to use a blind faith regarding the causes, consequences and validity regarding the raised issues/fixes, for the greater benefit of all.