Project

General

Profile

HOWTO backport commits » History » Version 16

Loïc Dachary, 05/06/2015 02:10 PM

1 1 Loïc Dachary
h3. Backport issues
2
3 9 Loïc Dachary
* Pick one entry with the highest *Severity* field in the list of issues linked from [[HOWTO|the top level page]] (for instance "firefly issues":http://tracker.ceph.com/projects/ceph/issues?query_id=75) and look for more information about it in the inventory page (for instance the "firefly inventory page":http://workbench.dachary.org/ceph/ceph-backports/wikis/firefly#issues-that-need-backporting not only shows issues but also discovers pull requests, commits and backports to other stable branches). Note that *Severity* is different from *Priority*. *Severity* is not used while working on the bug, it's used to prioritize backports only. An issue marked with a high *Priority* may not need to be backported with the same priority.
4 7 Loïc Dachary
* git clone a fork of http://github.com/ceph/ceph
5 10 Loïc Dachary
* *git checkout -b wip-$issue-$release origin/$release* to create a branch with a name that reflects the issue being fixed and the target release: this naming is convenient to select all branches containing backports for firefly or select all branches containing backports for a specific issue
6 1 Loïc Dachary
* git cherry-pick -x the commits from the pull request that was targeting master (not from the pull requests targeting stable branches)
7 10 Loïc Dachary
* *git push origin wip-$issue-$release* to publish the branch on github and be able to create a pull request from it
8 16 Loïc Dachary
* generate a *$github_token* by "following the GitHub instructions":https://help.github.com/articles/creating-an-access-token-for-command-line-use/
9 14 Loïc Dachary
* retrieve the *$redmine_key*: it is a token that will allow you to script issue updates
10
** login http://tracker.ceph.com/
11
** visit http://tracker.ceph.com/my/account
12
** look for *API access key* in the page (Control-f)
13
** click on the *Show* link just under *API access key*
14
** copy the hexadecimal number it shows
15
** redmine_key=b586ce6a7a936e71f351c93ac0b65a588d4333
16 10 Loïc Dachary
* create a pull request from the *wip-$issue-$release* branch with the same title as the issue
17 7 Loïc Dachary
<pre>
18 10 Loïc Dachary
account=myaccount
19 7 Loïc Dachary
eval title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject) ; echo $title
20 10 Loïc Dachary
number=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$account':wip-'$issue-$release'","base":"'$release'","body":"http://tracker.ceph.com/issues/'$issue'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token | jq .number)
21
</pre>
22 13 Loïc Dachary
* assigned the pull request to yourself (because it needs to got through integration tests before it can be approved by the original author), add the relevant labels (rgw, core, bug fix, feature...) and set the milestone to $release (requires write permission to the ceph repository)
23 10 Loïc Dachary
<pre>
24
component=core ; curl --silent --data-binary '{"milestone":"'$release_number'","assignee":"'$account'","labels":["bug fix","'$component'"]}' 'https://api.github.com/repos/ceph/ceph/issues/'$number'?access_token='$github_token
25
</pre>
26
* wait for the make check bot to run the *run-make-check.sh* script on the branch that was pushed and verify it works
27 15 Loïc Dachary
* Add a link to the pull request in the issue formatted as follows : 
28
<pre>
29
* $release backport http://github.com/ceph/ceph/pull/XXX*
30
</pre>
31
the following snippet does that:
32 10 Loïc Dachary
<pre>
33 7 Loïc Dachary
curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"notes":"* '$release' backport https://github.com/ceph/ceph/pull/'$number'"}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key
34 2 Loïc Dachary
</pre>
35
* if there is a conflict explain how it was resolved in the commit message, below the Conflicts line. For instance:
36
<pre>
37
commit c60da2f3c34e7325c748d2d6e55140a0a30013fd
38
Author: Samuel Just <sjust@redhat.com>
39
Date:   Thu Nov 20 15:15:08 2014 -0800
40 1 Loïc Dachary
41
    PGLog: include rollback_info_trimmed_to in (read|write)_log
42
    
43
    Fixes: #10157
44
    Backport: firefly, giant
45
    Signed-off-by: Samuel Just <sjust@redhat.com>
46
    (cherry picked from commit 1fe8b846641486cc294fe7e1d2450132c38d2dba)
47
    
48
    Conflicts:
49
    	src/osd/PGLog.cc
50
            in the context coll_t::META_COLL was replaced with META_COLL
51
</pre>
52 11 Loïc Dachary
* The difference between the original commit and the one including a conflict resolution can be displayed with
53
<pre>
54
commit=c7d0d51cb574594de6f09457c960347b11fc2474 ; picked_from=$(git show --no-patch --pretty=%b $commit  |  perl -ne 'print if(s/.*cherry picked from commit (\w+).*/$1/)') ; diff -u --ignore-matching-lines '^[^+-]' <(git show $picked_from) <(git show $commit)
55
</pre>
56 1 Loïc Dachary
* if the conflict is difficult to resolve, seek help from the author of the original commit (see "librbd: deadlock in image refresh":https://github.com/ceph/ceph/pull/4176 for instance)
57
* assign the pull request to the [[HOWTO#Leads|lead]] after it passed [[HOWTO run integration and upgrade tests|integration and upgrade tests]]
58
59
All commits being backported must be cherry-picked from master. There are exceptions to this rule (see https://github.com/ceph/ceph/pull/4175 for instance: it fixes a regression introduced by an incorrect resolution of a backport) but they are rare. When a backport is done to fix a bug that shows in the integration tests or upgrade tests run by cron, testing the backport in an integration branch is redundant because the existing tests will keep failing.
60 10 Loïc Dachary
61
62
Here are the snippets above groupped together for easier copy/paste:
63
<pre>
64
redmine_key=b586c588d4333
65
github_token=bc275830c635
66 12 Loïc Dachary
github_user=dachary
67 10 Loïc Dachary
issue=$1
68
# can't seem to extract the release number with the api
69
release=giant ; release_number=2
70 1 Loïc Dachary
release=firefly ; release_number=3
71 12 Loïc Dachary
release=hammer ; release_number=5
72
git checkout -f -b wip-$issue-$release ceph/$release
73 10 Loïc Dachary
git cherry-pick -x .....
74 12 Loïc Dachary
git push loic wip-$issue-$release ; sleep 2 # let github catch up
75 10 Loïc Dachary
eval title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject) ; echo $title
76 12 Loïc Dachary
number=$(curl --silent --data-binary '{"title":"'"$title"'","head":"'$github_user':wip-'$issue-$release'","base":"'$release'","body":"http://tracker.ceph.com/issues/'$issue'"}' 'https://api.github.com/repos/ceph/ceph/pulls?access_token='$github_token | jq .number)
77
component=core ; curl --silent --data-binary '{"milestone":"'$release_number'","assignee":"'$github_user'","labels":["bug fix","'$component'"]}' 'https://api.github.com/repos/ceph/ceph/issues/'$number'?access_token='$github_token
78 10 Loïc Dachary
firefox https://github.com/ceph/ceph/pull/$number
79
curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"notes":"* '$release' backport https://github.com/ceph/ceph/pull/'$number'"}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key
80
firefox http://tracker.ceph.com/issues/$issue
81
</pre>