Project

General

Profile

HOWTO backport commits » History » Revision 27

Revision 26 (Nathan Cutler, 07/29/2015 01:51 PM) → Revision 27/52 (Nathan Cutler, 07/29/2015 01:53 PM)

h3. Backport commits 

 * Pick one entry with the highest *Priority* field in the list of backports linked from [[HOWTO|the top level page]] (for instance "hammer backports":http://tracker.ceph.com/projects/ceph/issues?query_id=78)  
 * <code>git clone</code> a fork of http://github.com/ceph/ceph 
 * <code>git checkout -b wip-$issue-$release origin/$release</code> 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 
 * <code>git cherry-pick -x</code> the commits from the pull request that was targeting <code>master</code> (not from the pull requests targeting stable branches -- with the exception of <code>next</code>, which can be used because all commits to <code>next</code> are merged into <code>master</code> on a regular basis) 
 ** the original issue is linked in the *Related issues* section of the issue, as a *Copied from* link 
 ** the pull request or commit targeting master can be found by following the *Copied from* link and searching the original issue 
 * <code>git push origin wip-$issue-$release</code> to publish the branch on github and be able to create a pull request from it 
 * generate a *$github_token* by "following the GitHub instructions":https://help.github.com/articles/creating-an-access-token-for-command-line-use/ 
 * retrieve the *$redmine_key*: it is a token that will allow you to script issue updates 
 ** login http://tracker.ceph.com/ 
 ** visit http://tracker.ceph.com/my/account 
 ** look for *API access key* in the page (Control-f) 
 ** click on the *Show* link just under *API access key* 
 ** copy the hexadecimal number it shows 
 ** redmine_key=b586ce6a7a936e71f351c93ac0b65a588d4333 
 * create a pull request from the <code>wip-$issue-$release</code> branch with the same title as the issue 
 <pre> 
 account=myaccount 
 eval title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject) ; echo $title 
 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) 
 </pre> 
 * 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) 
 <pre> 
 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 
 </pre> 
 * wait for the make check bot to run the *run-make-check.sh* script on the branch that was pushed and verify it works 
 * Set the issue description to only contain the URL to the pull request 
 <pre> 
 curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"description":"https://github.com/ceph/ceph/pull/'$number'"}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key 
 </pre> 
 * if there is a conflict explain how it was resolved in the commit message, below the Conflicts line. For instance: 
 <pre> 
 commit c60da2f3c34e7325c748d2d6e55140a0a30013fd 
 Author: Samuel Just <sjust@redhat.com> 
 Date:     Thu Nov 20 15:15:08 2014 -0800 

     PGLog: include rollback_info_trimmed_to in (read|write)_log 
    
     Fixes: #10157 
     Backport: firefly, giant 
     Signed-off-by: Samuel Just <sjust@redhat.com> 
     (cherry picked from commit 1fe8b846641486cc294fe7e1d2450132c38d2dba) 
    
     Conflicts: 
    	 src/osd/PGLog.cc 
             in the context coll_t::META_COLL was replaced with META_COLL 
 </pre> 
 * The difference between the original commit and the one including a conflict resolution can be displayed with 
 <pre> 
 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) 
 </pre> 
 * 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) and assign the issue to her/him, or to a [[HOWTO#Leads|lead]] 

 Do not merge the pull request yet. Merging only takes place after the backports pass [[HOWTO run integration and upgrade tests|integration and upgrade tests]] and with proper approval as described in [[HOWTO merge commits from the integration branch]]. 

 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. 

 Here are the snippets above grouped together for easier copy/paste: 
 <pre> 
 redmine_key=b586c588d4333 
 github_token=bc275830c635 
 github_user=dachary 
 issue=$1 
 # can't seem to extract the release number with the api 
 release=giant ; release_number=2 
 release=firefly ; release_number=3 
 release=hammer ; release_number=5 
 [ $(curl --silent http://tracker.ceph.com/issues/$issue.json | jq -r .issue.tracker.name) == "Backport" ] || echo "not a backport issue" && exit 1 
 git checkout -f -b wip-$issue-$release ceph/$release 
 git cherry-pick -x ..... 
 git push loic wip-$issue-$release ; sleep 2 # let github catch up 
 title=$(curl --silent 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key | jq .issue.subject | tr -d '\\"') 
 echo "Issue title: $title" 
 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) 
 echo "Opened pull request $number" 
 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 
 firefox https://github.com/ceph/ceph/pull/$number 
 curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"description":"https://github.com/ceph/ceph/pull/'$number'"}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key 
 firefox http://tracker.ceph.com/issues/$issue 
 </pre> 

 If you would like to automate update of tracker issue status and target version, try something like this instead of the last <code>curl</code> command: 
 <pre> 
 curl --verbose -X PUT --header 'Content-type: application/json' --data-binary '{"issue":{"description":"https://github.com/ceph/ceph/pull/'$number'","status_id":'$redmine_status',"fixed_version_id":'$redmine_fixed_version'}}' 'http://tracker.ceph.com/issues/'$issue.json?key=$redmine_key 
 </pre> 
 The values of <code>$redmine_status</code> and <code>$redmine_fixed_version</code> can be determined by setting the desired values in an issue and then peeking at the JSON using a command like this: 
 <pre> 
 curl --silent 'http://tracker.ceph.com/issues/12395.json' 
 </pre>