github.com/cilium/cilium@v1.16.2/Documentation/contributing/development/contributing_guide.rst (about) 1 .. only:: not (epub or latex or html) 2 3 WARNING: You are looking at unreleased Cilium documentation. 4 Please use the official rendered version released here: 5 https://docs.cilium.io 6 7 8 .. _howto_contribute: 9 10 How To Contribute 11 ================= 12 13 This document shows how to contribute as a community contributor. 14 :ref:`Guidance for reviewers and committers <reviewer_committer>` is also 15 available. 16 17 Cilium Feature Proposals 18 ~~~~~~~~~~~~~~~~~~~~~~~~ 19 20 Before you start working on a significant code change, it's a good idea to make sure 21 that your approach is likely to be accepted. The best way to do this is to 22 create a `Cilium issue of type "Feature Request" in 23 GitHub <https://github.com/cilium/cilium/issues/new?assignees=&labels=kind%2Ffeature&template=feature_template.md&title=CFP%3A+>`_ 24 where you describe your plans. 25 26 For longer proposals, you might like to include a link to an external doc (e.g. 27 a Google doc) where it's easier for reviewers to make comments and suggestions 28 in-line. The GitHub feature request template includes a link to the `Cilium 29 Feature Proposal template <https://docs.google.com/document/d/1vtE82JExQHw8_-pX2Uhq5acN1BMPxNlS6cMQUezRTWg/edit>`_ which you are welcome to use to help structure your 30 proposal. Please make a copy of that template, fill it in with your ideas, and 31 ensure it's publicly visible, before adding the link into the GitHub issue. 32 33 .. _provision_environment: 34 35 Clone and Provision Environment 36 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 37 38 #. Make sure you have a `GitHub account <https://github.com/join>`_ 39 #. Fork the Cilium repository to your GitHub user or organization. 40 #. Turn off GitHub actions for your fork as described in the `GitHub Docs <https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#managing-github-actions-permissions-for-your-repository>`_. 41 This is recommended to avoid unnecessary CI notification failures on the fork. 42 #. Clone your ``${YOUR_GITHUB_USERNAME_OR_ORG}/cilium`` fork and setup the base repository as ``upstream`` remote: 43 44 .. code-block:: shell-session 45 46 git clone https://github.com/${YOUR_GITHUB_USERNAME_OR_ORG}/cilium.git 47 cd cilium 48 git remote add upstream https://github.com/cilium/cilium.git 49 50 #. Set up your :ref:`dev_env`. 51 #. Check the GitHub issues for `good tasks to get started 52 <https://github.com/cilium/cilium/issues?q=is%3Aopen+is%3Aissue+label%3Agood-first-issue>`_. 53 #. Follow the steps in :ref:`making_changes` to start contributing :) 54 55 .. _submit_pr: 56 57 Submitting a pull request 58 ~~~~~~~~~~~~~~~~~~~~~~~~~ 59 60 Contributions must be submitted in the form of pull requests against the 61 upstream GitHub repository at https://github.com/cilium/cilium. 62 63 #. Fork the Cilium repository. 64 #. Push your changes to the topic branch in your fork of the repository. 65 #. Submit a pull request on https://github.com/cilium/cilium. 66 67 Before hitting the submit button, please make sure that the following 68 requirements have been met: 69 70 #. Take some time to describe your change in the PR description! A well-written 71 description about the motivation of the change and choices you made during 72 the implementation can go a long way to help the reviewers understand why 73 you've made the change and why it's a good way to solve your problem. If 74 it helps you to explain something, use pictures or 75 `Mermaid diagrams <https://mermaid-js.github.io/>`_. 76 #. Each commit must compile and be functional on its own to allow for 77 bisecting of commits in the event of a bug affecting the tree. 78 #. All code is covered by unit and/or runtime tests where feasible. 79 #. All changes have been tested and checked for regressions by running the 80 existing testsuite against your changes. See the :ref:`testsuite-legacy` section 81 for additional details. 82 #. All commits contain a well written commit description including a title, 83 description and a ``Fixes: #XXX`` line if the commit addresses a particular 84 GitHub issue. Note that the GitHub issue will be automatically closed when 85 the commit is merged. 86 87 :: 88 89 apipanic: Log stack at debug level 90 91 Previously, it was difficult to debug issues when the API panicked 92 because only a single line like the following was printed: 93 94 level=warning msg="Cilium API handler panicked" client=@ method=GET 95 panic_message="write unix /var/run/cilium/cilium.sock->@: write: broken 96 pipe" 97 98 This patch logs the stack at this point at debug level so that it can at 99 least be determined in developer environments. 100 101 Fixes: #4191 102 103 Signed-off-by: Joe Stringer <joe@cilium.io> 104 105 .. note:: 106 107 Make sure to include a blank line in between commit title and commit 108 description. 109 110 #. If any of the commits fixes a particular commit already in the tree, that 111 commit is referenced in the commit message of the bugfix. This ensures that 112 whoever performs a backport will pull in all required fixes: 113 114 :: 115 116 daemon: use endpoint RLock in HandleEndpoint 117 118 Fixes: a804c7c7dd9a ("daemon: wait for endpoint to be in ready state if specified via EndpointChangeRequest") 119 120 Signed-off-by: André Martins <andre@cilium.io> 121 122 .. note:: 123 124 The proper format for the ``Fixes:`` tag referring to commits is to use 125 the first 12 characters of the git SHA followed by the full commit title 126 as seen above without breaking the line. 127 128 #. If you change CLI arguments of any binaries in this repo, the CI will reject your PR if you don't 129 also update the command reference docs. To do so, make sure to run the ``postcheck`` make target. 130 131 .. code-block:: shell-session 132 133 $ make postcheck 134 $ git add Documentation/cmdref 135 $ git commit 136 137 #. All commits are signed off. See the section :ref:`dev_coo`. 138 139 .. note:: 140 141 Passing the ``-s`` option to ``git commit`` will add the 142 ``Signed-off-by:`` line to your commit message automatically. 143 144 #. Document any user-facing or breaking changes in ``Documentation/operations/upgrade.rst``. 145 146 #. (optional) Pick the appropriate milestone for which this PR is being 147 targeted, e.g. ``1.6``, ``1.7``. This is in particular important in the time 148 frame between the feature freeze and final release date. 149 150 #. If you have permissions to do so, pick the right release-note label. These 151 labels will be used to generate the release notes which will primarily be 152 read by users. 153 154 +-----------------------------------+--------------------------------------------------------------------------------------------------------+ 155 | Labels | When to set | 156 +===================================+========================================================================================================+ 157 | ``release-note/bug`` | This is a non-trivial bugfix and is a user-facing bug | 158 +-----------------------------------+--------------------------------------------------------------------------------------------------------+ 159 | ``release-note/major`` | This is a major feature addition, e.g. Add MongoDB support | 160 +-----------------------------------+--------------------------------------------------------------------------------------------------------+ 161 | ``release-note/minor`` | This is a minor feature addition, e.g. Add support for a Kubernetes version | 162 +-----------------------------------+--------------------------------------------------------------------------------------------------------+ 163 | ``release-note/misc`` | This is a not user-facing change , e.g. Refactor endpoint package, a bug fix of a non-released feature | 164 +-----------------------------------+--------------------------------------------------------------------------------------------------------+ 165 | ``release-note/ci`` | This is a CI feature or bug fix. | 166 +-----------------------------------+--------------------------------------------------------------------------------------------------------+ 167 168 #. Verify the release note text. If not explicitly changed, the title of the PR 169 will be used for the release notes. If you want to change this, you can add 170 a special section to the description of the PR. 171 These release notes are primarily going to be read by users so it is 172 important that release notes for bugs, major and minor features do not 173 contain internal details of Cilium functionality which sometimes are 174 irrelevant for users. 175 176 Example of a bad release note 177 :: 178 179 ```release-note 180 Fix concurrent access in k8s watchers structures 181 ``` 182 183 Example of a good release note 184 :: 185 186 ```release-note 187 Fix panic when Cilium received an invalid Cilium Network Policy from Kubernetes 188 ``` 189 190 .. note:: 191 192 If multiple lines are provided, then the first line serves as the high 193 level bullet point item and any additional line will be added as a sub 194 item to the first line. 195 196 #. If you have permissions, pick the right labels for your PR: 197 198 +------------------------------+---------------------------------------------------------------------------+ 199 | Labels | When to set | 200 +==============================+===========================================================================+ 201 | ``kind/bug`` | This is a bugfix worth mentioning in the release notes | 202 +------------------------------+---------------------------------------------------------------------------+ 203 | ``kind/enhancement`` | This enhances existing functionality in Cilium | 204 +------------------------------+---------------------------------------------------------------------------+ 205 | ``kind/feature`` | This is a feature | 206 +------------------------------+---------------------------------------------------------------------------+ 207 | ``release-blocker/X.Y`` | This PR should block the next X.Y release | 208 +------------------------------+---------------------------------------------------------------------------+ 209 | ``needs-backport/X.Y`` | PR needs to be backported to these stable releases | 210 +------------------------------+---------------------------------------------------------------------------+ 211 | ``backport/X.Y`` | This is backport PR, may only be set as part of :ref:`backport_process` | 212 +------------------------------+---------------------------------------------------------------------------+ 213 | ``upgrade-impact`` | The code changes have a potential upgrade impact | 214 +------------------------------+---------------------------------------------------------------------------+ 215 | ``area/*`` (Optional) | Code area this PR covers | 216 +------------------------------+---------------------------------------------------------------------------+ 217 218 .. note:: 219 220 If you do not have permissions to set labels on your pull request. Leave 221 a comment and a core team member will add the labels for you. Most 222 reviewers will do this automatically without prior request. 223 224 #. Open a draft pull request. GitHub provides the ability to create a Pull 225 Request in "draft" mode. On the "New Pull Request" page, below the pull 226 request description box there is a button for creating the pull request. 227 Click the arrow and choose "Create draft pull request". If your PR is still a 228 work in progress, please select this mode. You will still be able to run the 229 CI against it. 230 231 .. image:: https://i1.wp.com/user-images.githubusercontent.com/3477155/52671177-5d0e0100-2ee8-11e9-8645-bdd923b7d93b.gif 232 :align: center 233 234 #. To notify reviewers that the PR is ready for review, click **Ready for 235 review** at the bottom of the page. 236 237 #. Engage in any discussions raised by reviewers and address any changes 238 requested. Set the PR to draft PR mode while you address changes, then click 239 **Ready for review** to re-request review. 240 241 .. image:: /images/cilium_request_review.png 242 243 Getting a pull request merged 244 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 245 246 #. As you submit the pull request as described in the section :ref:`submit_pr`. 247 One of the reviewers will start a CI run by replying with a comment 248 ``/test`` as described in :ref:`trigger_phrases`. If you are an 249 `organization member`_, you can trigger the CI run yourself. CI consists of: 250 251 #. Static code analysis by Github Actions and Travis CI. Golang linter 252 suggestions are added in-line on PRs. For other failed jobs, please refer 253 to build log for required action (e.g. Please run ``go mod tidy && go mod 254 vendor`` and submit your changes, etc). 255 256 #. :ref:`ci_gha`: Will run a series of tests: 257 258 #. Unit tests 259 #. Single node runtime tests 260 #. Multi node Kubernetes tests 261 262 If a CI test fails which seems unrelated to your PR, it may be a flaky 263 test. Follow the process described in :ref:`ci_failure_triage`. 264 265 #. As part of the submission, GitHub will have requested a review from the 266 respective code owners according to the ``CODEOWNERS`` file in the 267 repository. 268 269 #. Address any feedback received from the reviewers 270 #. You can push individual commits to address feedback and then rebase your 271 branch at the end before merging. 272 #. Once you have addressed the feedback, re-request a review from the 273 reviewers that provided feedback by clicking on the button next to their 274 name in the list of reviewers. This ensures that the reviewers are 275 notified again that your PR is ready for subsequent review. 276 277 #. Owners of the repository will automatically adjust the labels on the pull 278 request to track its state and progress towards merging. 279 280 #. Once the PR has been reviewed and the CI tests have passed, the PR will be 281 merged by one of the repository owners. In case this does not happen, ping 282 us on `Cilium Slack`_ in the ``#development`` channel. 283 284 .. _organization member: https://github.com/cilium/community/blob/main/CONTRIBUTOR-LADDER.md#organization-member 285 286 Handling large pull requests 287 ---------------------------- 288 289 If the PR is considerably large (e.g. with more than 200 lines changed and/or 290 more than 6 commits), consider whether there is a good way to split the PR into 291 smaller PRs that can be merged more incrementally. Reviewers are often more 292 hesitant to review large PRs due to the level of complexity involved in 293 understanding the changes and the amount of time required to provide 294 constructive review comments. By making smaller logical PRs, this makes it 295 easier for the reviewer to provide comments and to engage in dialogue on the 296 PR, and also means there should be fewer overall pieces of feedback that you 297 need to address as a contributor. Tighter feedback cycles like this then make 298 it easier to get your contributions into the tree, which also helps with 299 reducing conflicts with other contributions. Good candidates for smaller PRs 300 may be individual bugfixes, or self-contained refactoring that adjusts the code 301 in order to make it easier to build subsequent functionality on top. 302 303 While handling review on larger PRs, consider creating a new commit to address 304 feedback from each review that you receive on your PR. This will make the 305 review process smoother as GitHub has limitations that prevents reviewers from 306 only seeing the new changes added since the last time they have reviewed a PR. 307 Once all reviews are addressed those commits should be squashed against the 308 commit that introduced those changes. This can be accomplished by the usage of 309 ``git rebase -i upstream/main`` and in that windows, move these new commits 310 below the commit that introduced the changes and replace the work ``pick`` with 311 ``fixup``. In the following example, commit ``d2cb02265`` will be combined into 312 ``9c62e62d8`` and commit ``146829b59`` will be combined into ``9400fed20``. 313 314 :: 315 316 pick 9c62e62d8 docs: updating contribution guide process 317 fixup d2cb02265 joe + paul + chris changes 318 pick 9400fed20 docs: fixing typo 319 fixup 146829b59 Quentin and Maciej reviews 320 321 Once this is done you can perform push force into your branch and request for 322 your PR to be merged. 323 324 Reviewers should apply the documented :ref:`review_process` when providing 325 feedback to a PR. 326 327 .. _dev_coo: 328 329 Developer's Certificate of Origin 330 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 331 332 To improve tracking of who did what, we've introduced a "sign-off" 333 procedure. 334 335 The sign-off is a simple line at the end of the explanation for the 336 commit, which certifies that you wrote it or otherwise have the right to 337 pass it on as open-source work. The rules are pretty simple: if you can 338 certify the below: 339 340 :: 341 342 Developer Certificate of Origin 343 Version 1.1 344 345 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 346 1 Letterman Drive 347 Suite D4700 348 San Francisco, CA, 94129 349 350 Everyone is permitted to copy and distribute verbatim copies of this 351 license document, but changing it is not allowed. 352 353 354 Developer's Certificate of Origin 1.1 355 356 By making a contribution to this project, I certify that: 357 358 (a) The contribution was created in whole or in part by me and I 359 have the right to submit it under the open source license 360 indicated in the file; or 361 362 (b) The contribution is based upon previous work that, to the best 363 of my knowledge, is covered under an appropriate open source 364 license and I have the right under that license to submit that 365 work with modifications, whether created in whole or in part 366 by me, under the same open source license (unless I am 367 permitted to submit under a different license), as indicated 368 in the file; or 369 370 (c) The contribution was provided directly to me by some other 371 person who certified (a), (b) or (c) and I have not modified 372 it. 373 374 (d) I understand and agree that this project and the contribution 375 are public and that a record of the contribution (including all 376 personal information I submit with it, including my sign-off) is 377 maintained indefinitely and may be redistributed consistent with 378 this project or the open source license(s) involved. 379 380 then you just add a line saying: 381 382 :: 383 384 Signed-off-by: Random J Developer <random@developer.example.org> 385 386 If you need to add your sign off to a commit you have already made, please see `this article <https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/managing-commits/amending-a-commit>`_. 387 388 Cilium follows the real names policy described in the CNCF `DCO Guidelines v1.0 389 <https://github.com/cncf/foundation/blob/main/dco-guidelines.md>`_: 390 391 :: 392 393 The DCO requires the use of a real name that can be used to identify 394 someone in case there is an issue about a contribution they made. 395 396 A real name does not require a legal name, nor a birth name, nor any name 397 that appears on an official ID (e.g. a passport). Your real name is the 398 name you convey to people in the community for them to use to identify you 399 as you. The key concern is that your identification is sufficient enough to 400 contact you if an issue were to arise in the future about your 401 contribution. 402 403 Your real name should not be an anonymous id or false name that 404 misrepresents who you are. 405 406 .. _contributor_ladder: 407 408 Contributor Ladder 409 ~~~~~~~~~~~~~~~~~~ 410 411 To help contributors grow in both privileges and responsibilities for the 412 project, Cilium also has a `contributor ladder 413 <https://github.com/cilium/community/blob/main/CONTRIBUTOR-LADDER.md>`_. 414 The ladder lays out how contributors can go from community contributor 415 to a committer and what is expected for each level. Community members 416 generally start at the first levels of the "ladder" and advance up it as 417 their involvement in the project grows. Our contributors are happy to 418 help you advance along the contributor ladder.