- 1 Before You Begin
- 2 Your first commit
- 3 How to Resolve Merge Conflicts
- 4 Reviews
Before You Begin
To familiarize yourself with Magnum, try it out using the information in our Dev Quickstart Guide and Manually Adding Magnum to DevStack Guide. When you are ready to start contributing, you will need to execute an OpenStack CLA. This is required before you can submit reviews to our Magnum Repo. For information about how prepare for contribution, please consult the How To Contribute wiki page.
Sign Up for the OpenStack Development Mailing List
Head on over to OpenStack Dev Mailing List, fill out the fields under "Subscribing to OpenStack-dev" and click Subscribe.
Learn About Gerrit
Be sure to read the Developer's Guide for information about how to submit your commit for review so it can be merged into the Magnum code base.
If you do not have a gerrit username setup or do not remember it, verify and configure it here: https://review.openstack.org/#/settings/
Keep that handy for the "git review -s" command later in the https://wiki.openstack.org/wiki/Magnum/Contributing#Setting_up_your_git_review_settings and https://wiki.openstack.org/wiki/Magnum/Contributing#Set_up_your_local_branch sections below...
You'll also need to upload an SSH public key, specifically for Gerrit: https://review.openstack.org/#/settings/ssh-keys
Setting up your git review settings
New to git? Try the 15-minute high-level interactive Git demo GitHub Demo
Need a git refresher? Download a git reference direct from the source: GitHub Git Cheat Sheet
git config --global user.name "Firstname Lastname" git config --global user.email "firstname.lastname@example.org"
In the event your launchpad and gerrit usernames are identical:
git config --global gitreview.username "your_launchpad_username"
In the event your launchpad and gerrit usernames are not identical:
git config --global gitreview.username "your_gerrit_username"
To check your git configuration:
git config --list
On Ubuntu, MacOSx, or most other Unix-like systems, it is as simple as:
pip install git-review
There are other installation options detailed in the Developer's Guide. You can now check out the Magnum code and begin working on it:
Your first commit
Set up your local branch
git clone git://git.openstack.org/openstack/magnum cd magnum git checkout -b [branch name] git review -s
If you receive the following error when running the "git review -s" command:
We don't know where your gerrit is. Please manually create a remote named "gerrit" and try again.
Perform the following (substituting <your gerrit username> with your specific gerrit username...):
git remote add gerrit ssh://<your gerrit username>@review.openstack.org:29418/openstack/magnum.git git review -s
If you receive the following error when running the "git review -s" command:
Agent admitted failure to sign using the key
See this support page: https://help.github.com/articles/error-agent-admitted-failure-to-sign/
Observe a bug? Report it here: https://launchpad.net/magnum
- Click the Report a Bug button.
- Enter a Summary in the field and click Next. Here's an example: Stale link to Gerrit Workflow
- Review the choices you've been given. If you spot your bug, click on the bug and review its status; proceed to the awesome code section below if there's more to do.. If you do not spot your bug, proceed to the next step.
- Click the No, I need to report a new bug button.
- Type in a detailed description of the bug in the "Further information" field and click Submit bug report. Here's an example description for our previous example: In doc/source/dev/dev-quickstart.rst the link to the Gerrit workflow is incorrect. It should be: http://docs.openstack.org/infra/manual/developers.html
Write some awesome code
At this point can write your code and push it to Gerrit for review.
git add <list of files you added/changed>
If you submitted a bug in the previous section, be sure to add the bug link in the commit message.
Each commit line should conform with the OpenStack style guidelines. Some highlights:
- The first line of the commit message should be <=50 characters.
- The subsequent lines can be <= 78 characters.
- Lines 2 onward are a blank line followed by a more verbose description of the first commit line (as needed).
- The last commit line needs to link to either a blueprint or bug/task ticket number.
- There should be no whitespace at the end of all lines.
For the example case:
Adjust Gerrit workflow Link <blank line> The Gerrit workflow link in the previous version is no longer valid. This patch updates documentation to the current link. <blank line> Closes-bug: <bug/task ticket number>
git commit -a git review -v --draft
Once you are happy with your code and want it to be reviewed you want to convert it from a Draft. "Sign In" at https://review.openstack.org/ and after verifying the review yourself hit the "Publish" button on the page.
If you know you are ready for others to review your code, you can skip the draft step and just do:
git review -v
By this point, your code will be reviewed by the Openstack automatic testing frameworks and, potentially, your peers on the project.
If you want to revise your patchset in the review system in response to feedback, make your changes, then use:
git commit -a --amend git review -v
Upon approval of the review your code will be automatically merged.
Need somewhere to start writing code?
You can also contribute to the quality of the code by looking at the coverage of current Magnum unit tests and improving the code coverage. The following code has under 30% code coverage.
Name Stmts Miss Branch BrMiss Cover Missing magnum/base 56 56 16 16 0% 13-113 magnum/cloud/nova_driver 20 20 0 0 0% 13-45 magnum/cmd/api 23 23 2 2 0% 15-54 magnum/cmd/conductor 28 28 3 3 0% 15-65 magnum/cmd/db_manage 42 42 2 2 0% 14-91 magnum/cmd/template_manage 49 49 15 15 0% 14-96 magnum/common/pythonk8sclient/client/ApivbetaApi 4570 4415 1656 1656 2% 30, 55-109, ... magnum/common/pythonk8sclient/client/models/V1beta3_Binding 18 15 0 0 17% 29-152 magnum/common/pythonk8sclient/client/models/V1beta3_Container 21 18 0 0 14% 29-179 magnum/common/pythonk8sclient/client/models/V1beta3_ContainerStateTerminated 12 9 0 0 25% 29-98 magnum/common/pythonk8sclient/client/models/V1beta3_ContainerStatus 13 10 0 0 23% 29-107 magnum/common/pythonk8sclient/client/models/V1beta3_Endpoints 18 15 0 0 17% 29-152 magnum/common/pythonk8sclient/client/models/V1beta3_Event 24 21 0 0 13% 29-206 magnum/common/pythonk8sclient/client/models/V1beta3_LimitRange 18 15 0 0 17% 29-152 magnum/common/pythonk8sclient/client/models/V1beta3_Namespace 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_Node 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_NodeCondition 11 8 0 0 27% 29-89 magnum/common/pythonk8sclient/client/models/V1beta3_NodeSystemInfo 13 10 0 0 23% 29-105 magnum/common/pythonk8sclient/client/models/V1beta3_ObjectReference 12 9 0 0 25% 29-98 magnum/common/pythonk8sclient/client/models/V1beta3_PersistentVolume 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_PersistentVolumeClaim 19 16 0 0 16% 29-160 magnum/common/pythonk8sclient/client/models/V1beta3_Pod 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_PodSpec 12 9 0 0 25% 29-98 magnum/common/pythonk8sclient/client/models/V1beta3_PodStatus 11 8 0 0 27% 29-89 magnum/common/pythonk8sclient/client/models/V1beta3_PodTemplateSpec 16 13 0 0 19% 29-134 magnum/common/pythonk8sclient/client/models/V1beta3_ReplicationController 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_ResourceQuota 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_Secret 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_Service 19 16 0 0 16% 29-161 magnum/common/pythonk8sclient/client/models/V1beta3_ServiceSpec 11 8 0 0 27% 29-88 magnum/common/pythonk8sclient/client/models/V1beta3_Volume 13 10 0 0 23% 29-107 magnum/common/pythonk8sclient/client/swagger 154 125 74 74 13% 33-40, 44, 48, ... magnum/common/service 5 5 0 0 0% 15-22 magnum/config 8 8 0 0 0% 15-78 magnum/db/migration 19 19 2 2 0% 17-52 magnum/opts 16 16 0 0 0% 16-34 TOTAL 10985 5975 2908 2063 42%
You can review the code coverage of your currently checked out code with:
$ tox -e cover
This will produce a cover directory that provides HTML output showing the code coverage as well as the specific lines of code that are not covered.
Low Hanging Fruit
Some bugs have been identified by the bug manager as appropriate for first time contributors. These bugs should require small patches, and don't require an extensive understanding of Magnum to work on. Find them tagged with the low-hanging-fruit tag in the bug system.
How to Resolve Merge Conflicts
If another patch changes the same line of code as your patch, and it gets merged before yours, your patch may get a
patch in merge conflict status in red. If that happens, here is how you can resolve it. You will need the patch number from the Gerrit URL https://review.openstack.org/NNNNN to make your rebase a revision of the previous review.
git clone https://github.com/openstack/magnum cd magnum git review -d NNNNN git rebase master
Now edit all files with merge conflicts to resolve them by making the code look the way it should both with the recently merged code, and your own. Then
git add each of the files you edited.
git add path/to/file/you/edited git rebase --continue git review -v
That will resubmit your patch with the original commit message, and the rebased code with your merge fix as a new patch set.
The OpenStack CI system uses the concept of core reviewers. These are individuals who have consistently reviewed code for the project, and helped over a considerable period of time to improve the quality and consistency of what we merge into the code base. Project contributors will feel that this reviewer is a positive influence on the team and that they maintain the values and traditions of the OpenStack development community.
Existing core reviewers may nominate new ones in an ML thread. Consent among the current reviewers shall result in the declaration of the new core reviewer by the PTL. Lack of unanimous consent shall be carefully considered, and a final decision informed by input from from active team members shall be made by the PTL. Core reviewers who are judged by their peers in the core review group to fall short of the expectations for contribution of a core reviewer may be nominated for return to regular reviewer status.
Patches require a core reviewer to mark a review as "Approved" before they are merged.
Code Approval for Merge
- For Approval, two core reviewers shall supply a
Continuing Someone Else's Contribution
- If a patch submitted by one contributor is picked up and completed by another contributor, special handling of the resolution should be used.
Advice for Reviewers
-1vote is an opportunity to make our code better before it is merged. Please do your best to make helpful, actionable -1 votes.
- Avoid the temptation to blindly
+1code without reviewing it in sufficient detail to form an opinion.
- When voting
-1on a patch, it means that you want the submitter to make a revision in accordance with your feedback before core reviewers should consider this code for merge.
- If you ask a question, you should vote
0unless you anticipate that the answer to that question is likely to cause you to vote against the patch without further revisions.
- If you use a
-1vote for a question, and the contributor answers the question, please respond acknowledging the question. Either change your vote or follow up with additional rationale for why this should remain a
-2vote is a veto by a single core reviewer. It is sticky. That means that even if you revise your patch, that vote will persist. To allow your patch to merge, that same reviewer must clear the
-2vote first. This vote is used when you have contributed something that is not in alignment with the current project vision, or is implemented in a way that can not be accepted. For example, security concerns that a core reviewer wants to individually re-evaluate before allowing the contribution to continue. It can also be used as a way to halt further gate testing of a patch, if something is included that may break the gate. It works even after a
2*+2,+Aapproval for merge, but before the patch reaches MERGED state.
- To avoid a
-2vote, discuss your plans with the development team prior to writing code, and post a WIP (workflow-1) patch while you are working on it, and ask for input before you submit it for merge review.