Dev Week -- Fixing obvious bugs in Launchpad -- deryck -- Tue, Jul 12th, 2011

   1 [19:02] <deryck> Ok, so I guess that's me.  Hi, all.  :)
   2 [19:02] <deryck> My name is Deryck Hodge. I'm a team lead for one of the dev teams working on Launchpad.
   3 [19:02] <deryck> This session will be about fixing obvious bugs in Launchpad.
   4 [19:02] <deryck> Feel free to ask questions as we go.
   5 [19:02] <deryck> Launchpad is a large code base with a complex deployment story, so one way into hacking on Launchpad is to start by fixing obvious or easy bugs.
   6 [19:02] <deryck> From there you can decide if you want to go deeper or spend more time working on Launchpad.
   7 [19:03] <deryck> Working on lp is great by itself, but also a great way to support Ubuntu development.
   8 [19:03] <deryck> The goals for this session then are to:
   9 [19:03] <deryck>  * show you how to setup a Launchpad dev environment
  10 [19:03] <deryck>  * give you a tour of the Launchpad codebase
  11 [19:03] <deryck>  * teach you how to find easy bugs
  12 [19:03] <deryck>  * demonstrate how to approach fixing a bug
  13 [19:04] <deryck> You can try to follow along if you like, but I'm not assuming that, since certain steps like branching can take time....
  14 [19:04] <deryck> I'll just outline and demo here.
  15 [19:04] <deryck> So, let's start with getting a Launchpad dev environment setup.
  16 [19:05] <deryck> Launchpad uses a set of scripts we refer to as "rocketfuel" to manage our dev environment. These live in the Launchpad devel  tree and all begin with "rocketfuel-" names.
  17 [19:05] <deryck> So rocketfuel-setup would be the script you would run to build a dev environment.
  18 [19:05] <deryck> A word of warning....
  19 [19:06] <deryck> This script appends to your /etc/hosts file, adds ppa sources for launchpad development, and adds local apache configs.
  20 [19:06] <deryck> If that scares you, don't run the script.  If it doesn't, then you can get a working environment by downloading the script and running it, like:
  21 [19:06] <deryck>  * bzr --no-plugins cat > rocketfuel-setup
  22 [19:06] <deryck>  * ./rocketfuel-setup
  23 [19:07] <deryck> (I'm pasting from notes, so the "*" has no meaning, it's just my bullet points I copied by accident.)
  24 [19:08] <deryck> The above will install into $HOME/launchpad by default. But it does look for some env variables if you want to install in non-standard places.
  25 [19:08] <deryck> I change things myself, so my $HOME/ looks like:
  26 [19:08] <deryck>
  27 [19:09] <deryck> If you create this file before running rocketfuel-setup, you'll get things in the places you want them.  Or just go with the defaults. :)
  28 [19:10] <deryck> If you want to do each step of rocketfuel-setup by hand rather than run the script, see the full instructions at:
  29 [19:10] <deryck>
  30 [19:10] <deryck> Under the "Do it yourself" section
  31 [19:11] <deryck> If you want to run rocketfuel-setup for convenience but want it isolated a bit, you can run launchpad in a vm, or use an LXC container or a chroot.
  32 [19:11] <deryck> For more on that, see:
  33 [19:11] <deryck> or
  34 [19:12] <deryck> The point of all of the above is to get you familiar with getting setup and point you to sources of more info.
  35 [19:12] <deryck> You don't have to do this now to continue following along... but feel free, of course.
  36 [19:12] <deryck> Okay, so after you do all that you should be able to browse the local tree.  If you're using the default location you can see it at $HOME/launchpad/lp-branches/devel.
  37 [19:13] <deryck> Now, you need a working database setup.
  38 [19:13] <deryck> This is as simple as changing into the lp tree and running:
  39 [19:14] <deryck> ./utilities/launchpad-database-setup $USER && make schema
  40 [19:14] <deryck> where $USER is whatever local user you want to access the db with.
  41 [19:14] <deryck> A warning again.....
  42 [19:14] <deryck> If you already have a working Postgres setup, this will destroy any existing DBs. So run isolated per suggestions above if you need to.
  43 [19:15] <deryck> Also "make schema" is your friend if you get your DB in a weird state. It always resets the DB for development.
  44 [19:15] <deryck> Now we can run the local Launchpad with:   make run
  45 [19:16] <deryck> This takes a minute to start up but you should be able to go to in your browser and connect.
  46 [19:16] <deryck> You can also run tests here.  By killing the running lp and trying something like:
  47 [19:16] <deryck> ./bin/test -cvvt test_bugheat
  48 [19:16] <deryck> Testing becomes important as we do changes later.  We'll come back to that.
  49 [19:17] <deryck> Any questions so far on getting setup and running lp locally?
  50 [19:18] <deryck> Now that we're setup (or at least know how to get setup), let's look at the code itself!
  51 [19:18] <deryck> You can ls the top of the tree to see what's there:  ls -l ~/launchpad/lp-branches/devel
  52 [19:18] <deryck> But the interesting bits are in lib, especially lib/lp and lib/canonical.
  53 [19:19] <deryck> lib/canonical is a part of the tree that we can't seem to get rid of.  Eventually everything should end up moved to lib/lp...
  54 [19:19] <deryck> ...but if you can't find something in lib/lp, then look in lib/canonical.
  55 [19:19] <deryck> Everything under the lib directory are the Python packages we'll deal with.  So lib/lp/bugs/model/ can be referenced in Python by lp.bugs.model.bug.
  56 [19:20] <deryck> Here's a paste to make this clear:
  57 [19:20] <deryck>
  58 [19:20] <deryck> Notice in the paste that there is a bin/py in the tree that allows you to use Python with the correct path set for lp development.
  59 [19:21] <deryck> You can use `make harness` at the top of the lp tree to get a Python shell with several objects available already.
  60 [19:21] <deryck> This is nice for interpretative debugging or figuring things out.
  61 [19:22] <deryck> So to understand the tree structure, let's focus on lib/lp since that's where most everything lives these days.
  62 [19:22] <deryck> Each component of has it's own directory in the lp tree.  "bugs" and "code" and "translations" and so on.
  63 [19:22] <deryck> Each of these has roughly the same structure....  an interfaces, model, browser, and templates directory.... among other directories that are common.
  64 [19:23] <deryck> so lp.bugs.model and lp.code.model and so on.
  65 [19:23] <deryck> This is roughly our MVC division in launchpad, for those who know MVC-style development from other web app frameworks like Django.
  66 [19:24] <deryck> Interfaces are declared in the "interfaces" dir, "model" then contains the classes that implement those interfaces.
  67 [19:24] <deryck> "browser" holds the view stuff and templates are the html portion.  Well, TAL versions of the html.
  68 [19:24] <deryck> Generally, if you want to figure out what's happening with the Python objects or the database layer, look at stuff in the interfaces and model directories....
  69 [19:25] <deryck> (Read up on Zope Component Architecture to make better sense of those files.)
  70 [19:25] <deryck> ...but we said we want to focus on easy or obvious bugs, which are likely something to do with the web page itself.
  71 [19:25] <deryck> So let's focus on the stuff in templates or browser code.
  72 [19:26] <deryck> Again, this is the stuff that has to do with display on (Or if you working locally.)
  73 [19:26] <deryck> That concludes the tour of the code.  Any questions on that part?
  74 [19:27] <deryck> Now let's try to understand how we organize bugs on the launchpad project to find something to fix.
  75 [19:28] <deryck> Tagging can help us here.  We use "trivial" or "easy" to mark bugs that are pretty shallow.
  76 [19:28] <deryck> Here is a list of 162 Triaged launchpad bugs tagged "trivial" --
  77 [19:28] <deryck>
  78 [19:29] <deryck> But if you look at those bugs, you can see we often use "trivial" to mean trivial to an *experienced* Launchpad dev.
  79 [19:29] <deryck> So that might be useful, but I like to narrow further, when looking for truly easy stuff.
  80 [19:30] <deryck> Let's search for Triaged bugs with the tag "trivial" and "ui" since I know "ui" is used to many anything in the web page itself.
  81 [19:30] <deryck>
  82 [19:30] <deryck> Now we're down to 69 bugs. :-)
  83 [19:31] <deryck> FWIW, "ui" and "css" and "javascript" are all tags we use for front end work that combined with "easy" or "trivial" tags can help you find easier bugs to fix.
  84 [19:32] <deryck> trivial means (for lp devs) something that can be fixed in an hour.  "easy" is a bit longer but still short work.  maybe 2-3 hour fix all told.
  85 [19:32] <deryck> You can look through these bugs above if you like, but I've spent some time with them already this morning....
  86 [19:32] <deryck> I've found a bug that will be a nice one to demo how to approach fixing bugs.
  87 [19:33] <deryck> Let's look at bug 470430 and start working on how to fix Launchpad  bugs now.
  88 [19:33] <deryck>
  89 [19:34] <deryck> This is an older bug that outlines that the icon for the link "Copy packages" is bad.
  90 [19:34] <deryck> See the bug report for a link to a page that has the bad link on it.
  91 [19:35] <deryck> We currently use the edit icon that is used too much on Launchpad, and mpt recommends a new icon or an expander icon.
  92 [19:35] <deryck> But we can also just remove the icon to fix the issue.
  93 [19:36] <deryck> The first thing I would do is simply search the soyuz templates to find the one that has the link for "Copy packages."
  94 [19:36] <deryck> (I know to look in soyuz because I know that's the part of lp that deals with packaging on Launchpad.)
  95 [19:37] <deryck> (If you want to work on an easy bug like this but don't even know where to start, ask in #launchpad-dev here on Freenode.)
  96 [19:37] <deryck> feel free to ping me if no one responds :)
  97 [19:37] <deryck> So back to the bug in question....
  98 [19:37] <deryck> To find this link, I would change to the devel tree and run:
  99 [19:37] <deryck> grep -rI "Copy packages" lib/lp/soyuz/templates/
 100 [19:38] <deryck> If you do that, you'll find that it returns nothing.  This is a clue that the link is created in Python code rather than a template.
 101 [19:38] <deryck> So I need to look in the browser code I told you about earlier:
 102 [19:39] <deryck> grep -rI "Copy packages" lib/lp/soyuz/browser/
 103 [19:39] <deryck> This gives me:
 104 [19:40] <deryck> The "text" and "label" bits there look promising.
 105 [19:40] <deryck> So I now want to open lib/lp/soyuz/browser/ in an editor and see what's happening there.
 106 [19:40] <deryck> We need to search the file for the phrase "Copy packages".
 107 [19:41] <deryck> We can find a function that is called "copy" which creates a link from a class called "Link".  This looks like it!
 108 [19:41] <deryck> See the code pasted here:
 109 [19:42] <deryck> That line also sets the icon to "edit."  And this is the cause of our bug.
 110 [19:42] <deryck> So the easy fix is to just remove the icon line and make it like:
 111 [19:42] <deryck> The fix is at line 5 in the paste.
 112 [19:43] <deryck> And now we've fixed a trivial bug! :-)
 113 [19:44] <deryck> The next steps would be to branch from devel, create your own branch with this fix in it, and push it up to Launchpad.
 114 [19:44] <deryck> Then propose it for merging into lp:launchpad.
 115 [19:44] <deryck> A Launchpad dev should then step in and help you get your changes landed.
 116 [19:44] <deryck> Any questions about all that?
 117 [19:46] <deryck> It really is just that easy to fix easy bugs. :)
 118 [19:47] <deryck> Today we've been through getting setup with lp dev, finding our way around the code base, finding bugs, and learning how to approach fixing easy bugs.
 119 [19:47] <deryck> Please ask around on #launchpad-dev if you'd like to get more involved with launchpad development and try your hand at fixing these kinds of bugs.
 120 [19:48] <deryck> Thanks for attending the session everyone!  That's all I have.
 121 [19:48] <deryck> I'll hang around until the next session if any lingering questions arise.

MeetingLogs/devweek1107/FixingLaunchpadBugs (last edited 2011-07-13 09:27:36 by dholbach)