![]() |
Kea
1.5.0
|
So you found a bug in Kea or plan to develop an extension and want to send us a patch? Great! This page will explain how to contribute your changes smoothly.
Before you start working on a patch or a new feature, it is a good idea to discuss it first with Kea developers. You can post your questions to the kea-dev mailing list (https://lists.isc.org/mailman/listinfo/kea-dev) or kea-users (https://lists.isc.org/mailman/listinfo/kea-users). The kea-users list is intended for users who are not interested in the internal workings or development details of Kea: it is OK to ask for feedback regarding new design or the best proposed solution to a certain problem, but all the internal details should be discussed on kea-dev and not posted to kea-users.
The first step in writing the patch or new feature should be to get the source code from our Git repository. The procedure is very easy and is explained here: https://gitlab.isc.org/isc-projects/kea/wikis/gitlab-howto.
While it is possible to provide a patch against the latest stable release, it makes the review process much easier if it is for latest code from the Git master branch.
OK, so you have written a patch? Great! Before you submit it, make sure that your code compiles. This may seem obvious, but there's more to it. You have surely checked that it compiles on your system, but Kea is portable software. Besides Linux, it is compiled and used on relatively uncommon systems like OpenBSD. Will your code compile and work there? What about endianness? It is likely that you used a regular x86 architecture machine to write your patch, but the software is expected to run on many other architectures. You may take a look at system specific build notes (https://kb.isc.org/docs/installing-kea). For a complete list of systems we build on, you may take a look at the following build farm report: https://jenkins.isc.org/view/Kea_BuildFarm/ .
Does your patch conform to Kea coding guidelines (https://gitlab.isc.org/isc-projects/kea/wikis/coding-guidelines)? You can submit a patch that does not adhere to them, but that will reduce its chances of being accepted. If the deviations are minor, one of the Kea engineers who does the review will likely fix the issues. However, if there are lots of issues, the reviewer may simply reject the patch and ask you to fix it before re-submitting.
One of the ground rules in Kea development is that every piece of code has to be tested. We now have an extensive set of unit-tests for almost every line of code. Even if you are fixing something small, like a single line fix, you are encouraged to write unit-tests for that change. That is even more true for new code: if you write a new function, method or a class, you definitely should write unit-tests for it.
To ensure that everything is tested, ISC uses a development method called Test Driven Development (TDD). In TDD, a feature is developed alongside the tests, with the tests being written first. In detail, a test is written for a small piece of functionality and run against the existing code. (In the case where the test is a unit test for a function, it would be run against an empty (unimplemented) function.) The test should fail. A minimal amount of code is then written, just enough to get the test to pass. Then the process is repeated for the next small piece of functionality. This continues until all the functionality has been implemented.
This approach has two advantages:
Initially, some people unfamiliar with that approach react with "but my change is simple and I tested that it works". That approach is both insufficient and short-sighted. It is insufficient, because manual testing is by definition laborious and can't really be done on the multitude of systems we run Kea on. It is short-sighted, because even with your best intentions you will not be able to dedicate any significant amount of time for repeated testing of your improved code. The old ISC DHCP has two decades of history behind it and we hope to make Kea last similar time span. Over such long periods, code tends to be refactored several times. The change you made may be affected by some other change or by the code that hasn't been written yet.
See Building Kea with Unit Tests for instructions on how to run unit-tests. If you happen to touch any database related code, make sure you compile your code with –with-mysql, –with-pgsql and/or –with-cql as needed. For example, if you change something substantial, make sure the other compilation options still work.
If you happen to add new files or have modified any Makefile.am files, it is also a good idea to check if you haven't broken the distribution process:
There are other useful switches which can be passed to configure. It is always a good idea to use –enable-logger-checks, which does sanity checks on logger parameters. Use –enable-debug to enable various additional consistency checks that reduce performance but help during development. If you happen to modify anything in the documentation, use –enable-generate-docs. If you are modifying DHCP code, you are likely to be interested in enabling a non-default database backends for DHCP. Note that if the backend is not enabled, the database-specific unit-tests are skipped. To enable the MySQL backend, use the switch –with-mysql; for PostgreSQL, use –with-pgsql. A complete list of all switches can be obtained with the command:
There are several ways how you can send your changes. They are listed here from most to least preferred.
Once you let us submitted a patch using one of the ways above, the action is on one of the ISC engineers. First, we will need either a trac ticket or PR on github. We prefer the original submitter fill them as he or she has the best understanding of the purpose of the change and may have any extra information, e.g. "this patch fixes compilation issue on FreeBSD 10.1". If there there is no PR and no trac ticket, we will create one. Depending on the subjective importance and urgency as perceived by the ISC engineer, the ticket or PR will be assigned to one of the milestones.
Sooner or later, one of ISC engineers will do the review. Here's the tricky part. One of Kea developers will review your patch, but it may not happen immediately. Unfortunately, developers are usually working under a tight schedule, so any extra unplanned review work may take a while sometimes. Having said that, we value external contributions very much and will do whatever we can to review patches in a timely manner. Don't get discouraged if your patch is not accepted after first review. To keep the code quality high, we use the same review processes for external patches as we do for internal code. It may take some cycles of review/updated patch submissions before the code is finally accepted. The nature of the review process is that it emphasizes areas that need improvement. If you are not used to the review process, you may get the impression that the feedback is negative. It is not: even the Kea developers seldom see reviews that say "All OK please merge".
Once the process is almost complete, the developer will likely ask you how you would like to be credited. The typical answers are by first and last name, by nickname, by company name or anonymously. Typically we will add a note to the ChangeLog and also set you as the author of the commit applying the patch and update the contributors section in the AUTHORS file. If the contributed feature is big or critical for whatever reason, it may also be mentioned in release notes.
Sadly, we sometimes see patches that are submitted and then the submitter never responds to our comments or requests for an updated patch. Depending on the nature of the patch, we may either fix the outstanding issues on our own and get another ISC engineer to review them or the ticket may end up in our "Outstanding Tasks" milestone. When a new release is started, we go through the tickets in Outstanding Tasks, select a small number of them and move them to whatever the current milestone is. Keep that in mind if you plan to submit a patch and forget about it. We may accept it eventually, but it's much, much faster process if you participate in it.
If you are interested in knowing the results of more in-depth testing, you are welcome to visit the ISC Jenkins page: https://jenkins.isc.org This is a live result page with all tests being run on various systems. Besides basic unit-tests, we also have reports from valgrind (memory debugger), cppcheck and clang-analyzer (static code analyzers), Lettuce system tests and more. Although it is not possible for non ISC employees to run tests on that farm, it is possible that your contributed patch will end up there sooner or later. We also have ISC Forge tests running, but currently the test results are not publicly available.