Preparing My First Patch for OpenStack

Preparing My First Patch for OpenStacksource

I joined DreamHost about four weeks ago on Feb 6. and am on the team building a cloud hosting service based on the open source project OpenStack. I spent the first couple of weeks at the new job doing the usual sorts of new-hire activities: reading a lot of documentation and learning my way around the development environment and tool chain. I’ve done a little bit of work on some internal code already, and I recently had a good opportunity to start working on OpenStack itself. The OpenStack project team was running a coordinated “Global Hack-In” on March 1st to work on bugs for the upcoming Essex release. Several members of the OpenStack Atlanta meetup, sponsored by DreamHost, met to participate in the hack-in as a group. Since we don’t have official offices in Atlanta, yet, we gathered over at Duncan McGreggor’s house. Brent Scotten has already posted a quick recap of the day on the OpenStack blog, but I wanted to go into a little more detail about my experiences preparing my first patch for the project because for me this was a new code base on a new project using new version control and code review tools.
Becoming an OpenStack Contributor
The process for signing up to be a contributor to OpenStack isn’t terribly complicated, but there are a lot of steps and the instructions are spread out over a couple of different documents. I took care of subscribing to the required mailing lists and signing the contributor agreement a couple of weeks ago, but I am including those steps here along with the technical stuff I did yesterday, to provide an end-to-end view of the process.
Community
The first set of instructions, in the wiki under HowToContribute, explains how to join the OpenStack community. I registered an account on Launchpad, the code hosting service managed by Canonical and used by Ubuntu and other open source projects. Then I joined all of the OpenStack projects (Nova, Swift, Glance, and Keystone). Joining the individual teams under the OpenStack umbrella gave me access to the project mailing lists, so I can eventually participate in conversations about designs and implementation details.
Contributor Agreement
Updated: The old CLA process described here using Echosign is no longer valid. Please refer to this wiki page for the current process. As with many large open source projects, OpenStack requires all developers to sign a contributor agreement before any patches will be accepted. I signed the Individual Contributor License agreement on-line using echosign.com. Then, I added my name and the echosign signature hash to the Contributors page in the OpenStack wiki and requested membership in the openstack-cla group on Launchpad. Only members of openstack-cla can submit patches, though it isn’t clear if that requirement is enforced automatically by one of the tools or if it is a convention monitored by the project owners. In any case, my membership was approved without incident.
Development Environment
I am familiar with source control and virtualization, but not the specific flavors used for this project. My next step was to set up a development environment where I could work on the Nova project documentation, which meant setting up an virtual machine where I could build the project.
Virtualbox
My desktop system is running Mac OS X 10.7.3 (Lion), and OpenStack is intended to run on Linux (primarily Ubuntu). To set up an Ubuntu system for the build, I used virtualbox and vagrant. Duncan and Mark had already found a Vagrantfile that would set up an Oneiric image and then use DevStack to deploy all of the parts of OpenStack into the new VM using these chef cookbooks. I saved the Vagrantfile to an empty directory and started a VM using vagrant up. After a short wait while devstack downloaded and installed all of the dependencies, the VM was ready and running a copy of OpenStack based on the git repositories created by the devstack script. The local repositories are created in /opt/stack within the VM, but I wanted to work in a copy that was mounted via NFS from the host OS so I could edit under OS X and build in the VM. I was going to work on Nova, so I cloned its git repository from github and modified the Vagrantfile to have more RAM and so it would mount the directory where my source code was checked out using NFS to /home/vagrant/Devel.

-- mode: ruby --

Vagrant::Config.run do |config|
sshdir = "#{ENV['HOME']}/.ssh/"
cachedir = (ENV['CACHEDIR'] or "/Users/dhellmann/Documents/Devel/openstack-vm/cache")
checkout = (ENV['COOKBOOKS'] or "/Users/dhellmann/Documents/Devel/openstack-vm/openstack-cookbooks")

Make /vagrant an NFS mount instead of using the default setting

config.vm.share_folder("v-root", "/vagrant", ".", :nfs => true)

ip_prefix = (ENV['IP_PREFIX'] or "10.0.5.")
mac_prefix = (ENV['MAC_PREFIX'] or "080027027")
suffix = "100"
ip = "#{ip_prefix}#{suffix}"
config.vm.box = "oneiric"
config.vm.box_url = "http://images.ansolabs.com/vagrant/oneiric64.box"
config.vm.customize ['modifyvm', :id, '--memory', '2048']
config.vm.network :hostonly, ip, :mac => "#{mac_prefix}#{suffix}"

config.vm.share_folder("v-cache", "/home/vagrant/cache", cachedir, :nfs => true)
config.vm.share_folder("v-ssh", "/home/vagrant/.host-ssh", sshdir)
config.vm.share_folder("v-dev", "/home/vagrant/Devel", "/Users/dhellmann/Documents/Devel/nova-docs",
:nfs => true)

config.vm.forward_port 80, 8080
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "#{checkout}/cookbooks"
chef.roles_path = "#{checkout}/roles"
chef.log_level = :debug
chef.run_list = [
"recipe[anso::cache]",
"recipe[nova::hostname]",
"recipe[nova::source]",
#"recipe[anso::settings]", # vim / screen / git settings for testing
]
chef.json.merge!({
:nova => {
:source => {
:mysql_password => "secrete",
:rabbit_password => "secrete",
:admin_password => "secrete",
:service_token => "secrete",
:flat_interface => "eth1",
:public_interface => "eth1",
:floating_range => (ENV['FLOATING'] or "#{ip_prefix}128/28"),
:host_ip => ip,
}
},
})
end
endAfter restarting the VM (vagrant halt && vagrant up) I was able to login and switch Nova to use the git repository I had just checked out:
$ vagrant ssh
$ cd Devel/nova
$ sudo python setup.py developI encountered some I/O issues using vagrant ssh to connect to the VM, so in the end I switched to using ssh directly via the port that was forwarded using the instructions in the Vagrantfile above and the key vagrant used when setting up the VM.
$ ssh -i ~/.vagrant.d/insecure_private_key -p 2222 vagrant@127.0.0.1Building the Documentation
The documentation (and test) build for Nova use a local virtualenv created within the source tree. The instructions for creating the virtualenv are part of the Nova Developer Guide. We all had issues with timeouts and installation failures of one sort or another setting up the virtualenv within a virtualbox VM, and I eventually resorted to installing the dependencies into the virtualenv by hand using:
$ cd Devel/nova
$ source .venv/bin/activate
(.venv)$ pip install -r tools/pip-requires
(.venv)$ pip install -r tools/test-requiresSphinx and the other related tools needed to build the documentation are installed into the virtualenv so that, with the environment active, it is easy to build the HTML documentation using make:
$ cd doc
$ makeChoosing Something to Fix
It takes Sphinx a while to process all of the documentation, and it produced a lot of warnings and errors along the way. Duncan and Mark worked on some bugs in the OpenStack code, but I decided that since I was new to the tools as well as the code-base I would focus on shepherding a small documentation change all the way through the process this time around, to make sure I had everything set up correctly and that I understood the process. Fixing some of the errors in the reStructuredText formatting within the documentation met my criteria nicely.
Tracking Changes
OpenStack uses Launchpad for bug reports and task management. Launchpad’s operating model uses “blueprints” to group related related bugs and feature tickets. After studying the errors produced by Sphinx, I decided that there were basically three causes:
1.Problems in the automatically generated markup used to produce the API guide.
2.Problems in the manually written markup of the manual.
3.Problems in the manually written reStructuredText within the Nova source code, used when the API guide is generated.
I created one blueprint called sphinx-doc-cleanup to track all of the changes, and then opened three separate bug tickets to address the different types of problems. After opening the bugs, I went back to the blueprint page to associate the new tickets with the blueprint. I decided to tackle the changes in the order they are listed above, because the fix for the first one was just a few lines and it would eliminate several error messages.
Crafting the Fix
When Sphinx runs to build the Nova documentation, the first thing it does is generate skeleton files for some of the API documentation using a script called nova/doc/generate_autodoc_index.sh. For each module that needs to be documented and for which no documentation exists, a reStructuredText file is emitted containing a header such as:
The :mod:nova.wsgi Module
===========================
.. automodule:: nova.wsgi
:members:
:undoc-members:
:show-inheritance:The result is that even if there is no special local documentation for the module, the doc-strings from the code will be processed and included in the final output. The bug I found was with the way generate_autodoc_index.sh calculated the length of the underline to create the reStructuredText heading. The original version of the script used a single long line of =, but some of the module names were longer than the line. Rather than just extend it, I changed the script to calculate the proper length. Because this was my first patch, I also added myself to the Authors file at the top of the Nova source tree so I would be listed among the project contributors. I committed the change to my local repository, including the blueprint and bug id in the git commit message. At that point I was ready to submit the patch for review.
Review Tools and Process
OpenStack uses github to host its code, but the project does not accept pull requests in the usual way. Instead, it uses a copy of Gerrit tied to Launchpad and Jenkins so that changes can be reviewed by other developers and then run through the test suite before being merged into the main repository automatically. The instructions for setting up git to be able to submit change requests to Gerrit are in the GerritWorkflow page of the OpenStack wiki. After installing the git-review plug-in described there, I ran into some trouble authenticating with Gerrit. I finally figured out that I needed to upload the public half of my my ssh key to the Gerrit server. I don’t know if it was missing because I did not have it installed on Launchpad when I authenticated the first time, or if I would have had to take the extra step anyway. Installing the key allowed me to complete the setup, though, and then submit my change for review with git review. While I was looking for instructions about how to make sure someone saw that the change was ready for review, Vish Ishaya reviewed the change (email notification of reviews are sent to a review mailing list populated, I assume, from people who have signed up for the OpenStack Gerrit instance). I ended up needing to modify the git metadata for my change to use my DreamHost email address instead of my personal account, but after a bit of back-and-forth on IRC to ask for another review, Vish approved the change. A little while later the Jenkins build completed and the change was merged into the main repository. My first commit was merged!
Final Thoughts
So far I have found the OpenStack community helpful and welcoming. I especially want to thank Anne Gentle, who assisted me with finding some of the development setup documentation I needed. I should also thank Vish Ishaya and Brian Waldon for jumping right on the code review as soon as I submitted the patch, which made it possible to achieve my personal goal for the day. As I mentioned above, the OpenStack developers are using several tools I hadn’t used extensively before. The tools integrate well, especially those like gerrit that can use Launchpad for authentication. I am confident that I have everything I need set up now, which means I can start making more significant contributions.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,132评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,802评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,566评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,858评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,867评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,695评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,064评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,705评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,915评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,677评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,796评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,432评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,041评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,992评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,223评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,185评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,535评论 2 343

推荐阅读更多精彩内容