github.com/cilium/cilium@v1.16.2/Documentation/contributing/release/backports.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 .. _backport_process: 8 9 Backporting process 10 =================== 11 12 .. _backport_criteria: 13 14 Backport Criteria 15 ----------------- 16 17 Committers may nominate PRs that have been merged into main as candidates for 18 backport into stable releases if they affect the stable production usage 19 of community users. 20 21 Backport Criteria for Current Minor Release 22 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23 24 Criteria for inclusion into the next stable release of the current latest 25 minor version of Cilium, for example in a ``v1.2.z`` release prior to the 26 release of version ``v1.3.0``: 27 28 - All bugfixes 29 - Debug tool improvements 30 31 Backport Criteria for X.Y-1.Z and X.Y-2.Z 32 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 33 34 Criteria for the inclusion into the next stable release of the prior two minor 35 versions of Cilium, for example in a ``v1.0.z`` or ``v1.1.z`` release prior to 36 the release of version ``v1.3.0``: 37 38 - Security relevant fixes 39 - Major bugfixes relevant to the correct operation of Cilium 40 - Debug tool improvements 41 42 .. _backport_criteria_docs: 43 44 Backport Criteria for documentation changes 45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 47 Changes to Cilium's documentation should generally be subject to backports for 48 all supported branches to which they apply (all supported branches containing 49 the parent features to which the modified sections relate). 50 51 The motivation is that users can then simply look at the branch of the 52 documentation related to the version they are deploying, and find the latest 53 correct instructions for their version. 54 55 Proposing PRs for backporting 56 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 58 PRs are proposed for backporting by adding a ``needs-backport/X.Y`` label to 59 them. Normally this is done by the author when the PR is created or one of the 60 maintainers when the PR is reviewed. When proposing PRs that have already been 61 merged, also add a comment to the PR to ensure that the backporters are 62 notified. 63 64 Marking PRs to be backported by the author 65 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 67 For PRs which need to be backported, but are likely to run into conflicts or 68 other difficulties, the author has the option of adding the ``backport/author`` 69 label. This will exclude the PR from backporting automation, and the author is 70 expected to perform the backport themselves. 71 72 Backporting Guide for the Backporter 73 ------------------------------------ 74 75 Cilium PRs that are marked with the label ``needs-backport/X.Y`` need to be 76 backported to the stable branch ``X.Y``. The following steps summarize the 77 process for backporting these PRs: 78 79 * One-time setup 80 * Preparing PRs for backport 81 * Cherry-picking commits into a backport branch 82 * Posting the PR and updating GitHub labels 83 84 .. _backport_setup: 85 86 One-time Setup 87 ~~~~~~~~~~~~~~ 88 89 #. Make sure you have a GitHub developer access token with the ``public_repos`` 90 ``workflow``, ``read:user`` scopes available. You can do this directly from 91 https://github.com/settings/tokens or by opening GitHub and then navigating 92 to: User Profile -> Settings -> Developer Settings -> Personal access token 93 -> Generate new token. 94 95 #. The scripts referred to below need to be run on Linux, they do not work on 96 macOS. It is recommended to create a container using (``contrib/backporting/Dockerfile``), 97 as it will have all the correct versions of dependencies / libraries. 98 99 .. code-block:: shell-session 100 101 $ export GITHUB_TOKEN=<YOUR_GITHUB_TOKEN> 102 103 $ docker build -t cilium-backport contrib/backporting/. 104 105 $ docker run -e GITHUB_TOKEN -v $(pwd):/cilium -v "$HOME/.ssh":/home/user/.ssh \ 106 -it cilium-backport /bin/bash 107 108 .. note:: 109 110 If you are running on a mac OS, and see ``/home/user/.ssh/config: line 3: 111 Bad configuration option: usekeychain`` error message while running any of 112 the backporting scripts, comment out the line ``UseKeychain yes``. 113 114 #. Once you have a setup ready, you need to configure git to have your name and 115 email address to be used in the commit messages: 116 117 .. code-block:: shell-session 118 119 $ git config --global user.name "John Doe" 120 $ git config --global user.email johndoe@example.com 121 122 #. Add remotes for the Cilium upstream repository and your Cilium repository fork. 123 124 .. code-block:: shell-session 125 126 $ git remote add johndoe git@github.com:johndoe/cilium.git 127 $ git remote add upstream https://github.com/cilium/cilium.git 128 129 #. Skip this step if you have created a setup using the pre-defined Dockerfile. 130 This guide makes use of several tools to automate the backporting process. 131 The basics require ``bash`` and ``git``, but to automate interactions with 132 github, further tools are required. 133 134 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 135 | Dependency | Required? | Download Command | 136 +==============================================================+===========+=========================================================+ 137 | bash | Yes | N/A (OS-specific) | 138 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 139 | git | Yes | N/A (OS-specific) | 140 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 141 | jq | Yes | N/A (OS-specific) | 142 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 143 | python3 | Yes | `Python Downloads <https://www.python.org/downloads/>`_ | 144 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 145 | `PyGithub <https://pypi.org/project/PyGithub/>`_ | Yes | ``pip3 install PyGithub`` | 146 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 147 | `Github hub CLI (>= 2.8.3) <https://github.com/github/hub>`_ | Yes | N/A (OS-specific) | 148 +--------------------------------------------------------------+-----------+---------------------------------------------------------+ 149 150 Verify your machine is correctly configured by running 151 152 .. code-block:: shell-session 153 154 $ go run ./tools/dev-doctor --backporting 155 156 Preparation 157 ~~~~~~~~~~~ 158 159 Pull requests that are candidates for backports to the X.Y stable release are 160 tracked through the following links: 161 162 * PRs with the needs-backport/X.Y label (\ |CURRENT_RELEASE|: :github-backport:`GitHub Link<needs-backport>`) 163 * PRs with the backport-pending/X.Y label (\ |CURRENT_RELEASE|: :github-backport:`GitHub Link<backport-pending>`) 164 * The X.Y GitHub project (\ |NEXT_RELEASE|: :github-project:`GitHub Link<>`) 165 166 Make sure that the Github labels are up-to-date, as this process will deal with 167 all commits from PRs that have the ``needs-backport/X.Y`` label set (for a 168 stable release version X.Y). 169 170 Creating the Backports Branch 171 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 172 173 #. Check whether there are any `outstanding backport PRs for the target branch 174 <https://github.com/cilium/cilium/pulls?q=is%3Aopen+is%3Apr+label%3Akind%2Fbackports>`__. 175 If there are already backports for that branch, create a thread in the 176 #launchpad channel in `Cilium Slack`_ and reach out to the author to 177 coordinate triage, review and merge of the existing PR into the target 178 branch. 179 180 #. Run ``contrib/backporting/start-backport`` for the release version that 181 you intend to backport PRs for. This will pull the latest repository commits 182 from the Cilium repository (assumed to be the git remote ``origin``), create 183 a new branch, and runs the ``contrib/backporting/check-stable`` script to 184 fetch the full set of PRs to backport. 185 186 .. code-block:: shell-session 187 188 $ GITHUB_TOKEN=xxx contrib/backporting/start-backport 1.0 189 190 .. note:: 191 192 This command will leave behind a file in the current directory with a 193 name based upon the release version and the current date in the form 194 ``vRELEASE-backport-YYYY-MM-DD.txt`` which contains a prepared backport 195 pull-request description so you don't need to write one yourself. 196 197 #. Cherry-pick the commits using the ``main`` branch git SHAs listed, starting 198 from the oldest (top), working your way down and fixing any merge 199 conflicts as they appear. Note that for PRs that have multiple 200 commits you will want to check that you are cherry-picking oldest 201 commits first. The ``cherry-pick`` script accepts multiple arguments, 202 in which case it will attempt to apply each commit in the order 203 specified on the command line until one cherry pick fails or every 204 commit is cherry-picked. 205 206 .. code-block:: shell-session 207 208 $ contrib/backporting/cherry-pick <oldest-commit-sha> 209 ... 210 $ contrib/backporting/cherry-pick <newest-commit-sha> 211 212 Conflicts may be resolved by applying changes or backporting other 213 PRs to completely avoid conflicts. Backporting entire PRs is preferred if the 214 changes in the dependent PRs are small. `This stackoverflow.com question 215 <https://stackoverflow.com/questions/17818167/find-a-pull-request-on-github-where-a-commit-was-originally-created>`_ 216 describes how to determine the original PR corresponding to a particular 217 commit SHA in the GitHub UI. 218 219 If a conflict is resolved by modifying a commit during backport, describe 220 the changes made in the commit message and collect these to add to the 221 backport PR description when creating the PR below. This helps to direct 222 backport reviewers towards which changes may deviate from the original 223 commits to ensure that the changes are correctly backported. This can be 224 fairly simple, for example inside the commit message of the modified commit:: 225 226 commit f0f09158ae7f84fc8d888605aa975ce3421e8d67 227 Author: Joe Stringer <joe@cilium.io> 228 Date: Tue Apr 20 16:48:18 2021 -0700 229 230 contrib: Automate digest PR creation 231 232 [ upstream commit 893d0e7ec5766c03da2f0e7b8c548f7c4d89fcd7 ] 233 234 [ Backporter's notes: Dropped conflicts in .github/ issue template ] 235 236 There's still some interactive bits here just for safety, but one less 237 step in the template. 238 239 Signed-off-by: Joe Stringer <joe@cilium.io> 240 241 **It is the backporter's responsibility to check that the backport commits 242 they are preparing are identical to the original commits**. This can be 243 achieved by preparing the commits, then running ``git show <commit>`` for 244 both the original upstream commit and the prepared backport, and read 245 through the commits side-by-side, line-by-line to check that the changes are 246 the same. If there is any uncertainty about the backport, reach out to the 247 original author directly to coordinate how to prepare the backport for the 248 target branch. 249 250 #. For backporting commits that update cilium-builder and cilium-runtime images, 251 the backporter builds new images as described in :ref:`update_cilium_builder_runtime_images`. 252 253 #. (Optional) If there are any commits or pull requests that are tricky or 254 time-consuming to backport, consider reaching out for help on `Cilium 255 Slack`_. If the commit does not cherry-pick cleanly, please mention the 256 necessary changes in the pull request description in the next section. 257 258 Creating the Backport Pull Request 259 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 260 261 The backport pull-request may be created via CLI tools, or alternatively 262 you can use the GitHub web interface to achieve these steps. 263 264 Via Command-Line Tools (Recommended) 265 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 266 267 These steps require all of the tools described in the :ref:`backport_setup` 268 section above. It pushes the git tree, creates the pull request and updates 269 the labels for the PRs that are backported, based on the 270 ``vRELEASE-backport-YYYY-MM-DD.txt`` file in the current directory. 271 272 .. code-block:: shell-session 273 274 $ GITHUB_TOKEN=xxx contrib/backporting/submit-backport 275 276 The script takes up to three positional arguments:: 277 278 usage: submit-backport [branch version] [pr-summary] [your remote] 279 280 - The first parameter is the version of the branch against which the PR should 281 be done, and defaults to the version passed to ``start-backport``. 282 - The second one is the name of the file containing the text summary to use for 283 the PR, and defaults to the file created by ``start-backport``. 284 - The third one is the name of the git remote of your (forked) repository to 285 which your changes will be pushed. It defaults to the git remote 286 which matches ``github.com/<your github username>/cilium``. 287 288 Via GitHub Web Interface 289 ^^^^^^^^^^^^^^^^^^^^^^^^ 290 291 #. Push your backports branch to your fork of the Cilium repo. 292 293 .. code-block:: shell-session 294 295 $ git push -u <remote_for_your_fork> HEAD 296 297 #. Create a new PR from your branch towards the feature branch you are 298 backporting to. Note that by default Github creates PRs against the 299 ``main`` branch, so you will need to change it. The title and 300 description for the pull request should be based upon the 301 ``vRELEASE-backport-YYYY-MM-DD.txt`` file that was generated by the scripts 302 above. 303 304 .. note:: 305 306 The ``vRELEASE-backport-YYYY-MM-DD.txt`` file will include: 307 308 .. code-block:: RST 309 310 Once this PR is merged, a GitHub action will update the labels of these PRs: 311 ```upstream-prs 312 AAA BBB 313 ``` 314 315 The ``upstream-prs`` tag `is required 316 <https://github.com/cilium/release/blob/3c5fc2bdc38f8d290349a612a03cc83655f57a51/pkg/github/labels.go#L26>`_, 317 so add it if you manually write the message. 318 319 320 #. Label the new backport PR with the backport label for the stable branch such 321 as ``backport/X.Y`` as well as ``kind/backports`` so that it is easy to find 322 backport PRs later. 323 324 #. Mark all PRs you backported with the backport pending label 325 ``backport-pending/X.Y`` and clear the ``needs-backport/X.Y`` label. This 326 can be done with the command printed out at the bottom of the output from 327 the ``start-backport`` script above (``GITHUB_TOKEN`` needs to be set for 328 this to work). 329 330 Running the CI Against the Pull Request 331 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 332 333 To validate a cross-section of various tests against the PRs, backport PRs 334 should be validated in the CI by running all CI targets. This can be triggered 335 by adding a comment to the PR with exactly the text ``/test-backport-x.x``, 336 where ``x.x`` is the target version as described in :ref:`trigger_phrases`. 337 The comment must not contain any other characters. 338 339 After the Backports are Merged 340 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 341 342 After the backport PR is merged, the GH workflow "Call Backport Label Updater" 343 should take care of marking all backported PRs with the ``backport-done/X.Y`` 344 label and clear the ``backport-pending/X.Y`` label(s). 345 Verify that the workflow succeeded by looking `here 346 <https://github.com/cilium/cilium/actions/workflows/call-backport-label-updater.yaml>`_. 347 348 Backporting Guide for Others 349 ---------------------------- 350 351 Original Committers and Reviewers 352 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 353 354 Committers should mark PRs needing backport as ``needs-backport/X.Y``, based on 355 the `backport criteria <backport_criteria_>`_. It is up to the reviewers to 356 confirm that the backport request is reasonable and, if not, raise concerns on 357 the PR as comments. In addition, if conflicts are foreseen or significant 358 changes to the PR are necessary for older branches, consider adding the 359 ``backport/author`` label to mark the PR to be backported by the author. 360 361 At some point, changes will be picked up on a backport PR and the committer will 362 be notified and asked to approve the backport commits. Confirm that: 363 364 #. All the commits from the original PR have been indeed backported. 365 #. In case of conflicts, the resulting changes look good.