How a large development project on a tight release schedule and a tight budget can use open source to tackle the problems of version control and release management.
Say you have a large piece of software, a complicated Web site or a whole bunch of little ones. You also have a gaggle of coders and a farm of machines on which to deploy the end product. Worst of all, the client insists on a short turnaround time for critical changes. Proprietary products that may provide you with a systematic, unified development, testing and deployment process typically are expensive and offer limited deployment options. They often require new hardware resources and software licenses simply to support installation of the system itself. Such a solution can be difficult to sell to managers who are concerned about cost and to developers who are concerned about learning a new and complicated process.
However, managing the development process from end to end on a tight schedule without such a unified approach can lead to serious inefficiencies, schedule slippage and, in general, big headaches. If you're the administrator of such a project, chances are you're spending a lot of time dealing with the management of code releases. On the other hand, you already may be using an expensive piece of proprietary software that solves all of your problems today, but the higher-ups are balking at the ever-increasing license renewal fees. You need to present them with an alternative. It's also possible that you release code only once a year and have more free time than you know what to do with, but you happen to be an automation junkie. If any of these scenarios seem familiar to you, read on.
Various open-source products can be adapted to minimize costs and developer frustration while taming your out-of-control release process by serving as the glue between existing toolsets. Maybe you even can start making it home in time to play a round or two of Scrabble before bedtime.
I base the examples presented in this article on a few assumptions that hopefully are common or generic enough that the principles can be extrapolated easily to fit with the particulars of a real environment. Our developers probably already use a bug-tracking system (BTS), such as Bugzilla, ClearQuest or Mantis, or an in-house database solution to track change requests and bugs. They also may be using a version control system (VCS), such as Arch, CVS or Subversion, to manage the actual code changes called for in various BTS entries.
If they're not using a BTS and a VCS for a large project, these developers probably have either superhuman organization skills or a high level of tolerance for emotional trauma. Which BTS and VCS we use is not essential to this discussion, and any exploration of the pros and cons between one system and another requires much more text than I am allotted here. In short, they all should support the building blocks needed for the type of process we'd like to employ. Namely, most any BTS can:
Assign a unique ID to all issues or bugs in its database.
Allow you to use the unique ID to track the state of an issue and store and retrieve a listing of any source files it effects.
Any VCS worth its salt (sorry VSS fans) can:
Allow some form of branching and merging of a central code hierarchy.
Allow a command-line client process to connect over a secure network connection in order to perform updates.
We use a Subversion (SVN) repository with the SVN+SSH access method enabled as our VCS and a generic MySQL database table as the BTS. We use Python, which tends to be quite readable even for the novice programmer, as our scripting language of choice. Chances are your distribution has packages for all of these products readily available; configuring them will be left as an exercise for the reader. The target machines are generic Web servers, all of which support SSH connections as well as the VCS client tools.
Here's the 10,000-foot overview of the example end-to-end process we are likely to be starting out with:
An issue is generated in the BTS and is assigned an ID of 001 and an initial status of “new”. It includes, or will include, a listing of file paths that represent new or changed files within the VCS repository and is assigned to the appropriate developer.
The assignee developer makes changes to his local copy of the source code, checks these changes into the VCS repository and updates the status of BTS ID# 001 to “in testing”.
The testing server is updated with the new changes.
A QA tester charged with reviewing all BTS items with a status of “in testing” verifies that the changes to the code are what is desired and updates the status of BTS ID 001 to “ready for production”.
A release manager then packages all changes affected by BTS ID# 001 into a release and updates the status of BTS ID# 001 to “in production”.
The live server is updated with the changes.
For the most part, we're managing to fix bugs and add new features to the code base without bugging the system administrator for much, aside from the occasional password reset or RAM upgrade. But steps 3 and 6 require us somehow to get the code out of the VCS and onto a live system. We could cut and paste files from the VCS into a folder on our hard drive, zip it up, send it to the sysadmin and ask him to unzip it on the live system. Or, we could take advantage of the structure of our VCS and its utilities to do the work for us and completely avoid having a conversation with the administrator, whose time tends to be a hot commodity.
If we structured our VCS to encompass a branching scheme that mirrors our various statuses in the BTS, we likely would end up with a BRANCH to which developers add new, untested changes and a TRUNK that includes only code that is “in production”, although it easily could be the other way around. It then becomes a relatively simple matter of using the branch merging capabilities of the VCS to move “ready for production” code from the testing BRANCH to the stable TRUNK. Because no development changes happen on our TRUNK, merging from BRANCH to TRUNK is not likely to cause any conflicts. Managing the last step of moving the code from the VCS to the live system becomes even easier, because updating simply is a matter of using the VCS client utility to pull down all changes that occurred on the TRUNK of the repository.
So now all the pieces are there to allow quick and accurate code deployment, but we still need to ask our sysadmin to run the VCS client tools on the live system. We further can minimize our demands on the sysadmin's time, however, if he or she is willing to give our release manager an SSH login with permission to run the VCS client on the live system.
Once we've got the infrastructure in place to support performing content updates by way of our VCS, the next logical step is to remove further the need for manual intervention at release time. It now is possible for us to create a script that can use the VCS client tools to pull code updates to a live system. This method increases its usefulness as the number of machines we need to update increases. If our script has access to a list of all the target machines that need to be updated, we can hit them all in one fell swoop.
This piece of the puzzle, like the example, can be a simple script that the release manager runs from the command line of his workstation. Or, it can be a fancy Web-based GUI that a team of release managers can use to update any number of machines from any Web browser with a mouse click. In either case, it is useful to create a user ID on the client machines that has permissions to connect back to the VCS system without being prompted for login information. This may require configuring the user account on the client machines with SSH keys that allow it to connect back to the VCS server.
With this script in place on the client machines, we can update client copies of VCS files from a central location over an encrypted SSH connection.
Now we have a reasonably efficient process that piggybacks almost seamlessly onto a process that our developers were, for the most part, already using. It also allows content updates with the click of a button. So what's stopping us from scripting the updates to the testing servers so that they happen automatically at regular intervals, allowing developers the chance to see their changes show up on a live test system without asking for an update? All we need to do is run the client script on the testing servers as a cron job.
Also, as long as we're asking crazy questions, why not take advantage of the power of our BTS's database back end to drive the whole process and really cut down on process management bottlenecks? To do so, our script generates a list of files that need to be merged between branches by running a query for all IDs with a status of “ready for production”. The script uses the resulting lists as input for functions that perform the merge commands and update the BTS ID statuses to “in production” automatically.
Let's look at our amended 10,000-foot overview now that we've got all the bells and whistles incorporated:
An issue is generated in the BTS and assigned to the appropriate developer.
The assignee developer makes changes to his local copy of the source code, checks these changes into the TEST branch of the VCS repository and updates the status in the BTS.
The testing server content is updated automatically by a cron job.
A QA tester verifies that the changes to the code are correct and updates the status in the BTS.
A release manager presses a button to launch our merge script, which merges all changes into the stable TRUNK and updates the BTS.
One last click by the release manager, and the production systems are updated to the latest code by way of our VCS client script.
Steps 5 and 6 easily could be combined too, thereby halving the amount of work our release manager needs to perform.
Chances are at some point we'll want to add a staging branch to our VCS repository and enable our content update system to pull updates from this intermediate branch onto a staging server. QA then could see all the changes on a live system before the client does. Or, the client could be given access in order to provide final approval. Once staging has been given the thumbs up, moving updates to a production system is as easy as performing the already automated steps of merging from the staging branch to the stable TRUNK and running the content update script against the production servers.
Although these examples represent something of an oversimplification of the issues involved—for example, we haven't addressed the potential need for database structure updates—we have covered some core concepts that can be expanded on to build a truly functional, tailor-made system. In fact, we well may be approaching development process nirvana, and we still haven't spent dollar one on software licenses. Rather, we've simply written a few basic scripts to glue together our bug-tracking and version control systems. As a result, management now has more money in the reserve fund and fewer heart palpitations. Our sysadmins have more time to devote to removing spyware from desktops. Best of all, we've made it home for that round of Scrabble with time to spare. That's the power of open source for you.
Resources for this article: /article/8141.