Implementing a Parallel World Model Using Linux Containers for Efficient System Administration
Total Page:16
File Type:pdf, Size:1020Kb
Implementing a parallel world model using Linux containers for efficient system administration (Paper) Yasushi Shinjo and Wataru Ishida Jinpeng Wei Department of Computer Science School of Computing and Information Sciences University of Tsukuba Florida International University 1-1-1 Tennoudai, Tsukuba, Ibaraki 305-8573, Japan Miami, Florida, USA Email: [email protected] Abstract—This paper describes the implementation of a par- software updates. However, this method does not help to run allel world model using Linux containers. A parallel world the production environment while testing. (or parallel universe) model allows a user to create multiple To address these problems, we propose providing a parallel execution environments, called worlds, in a single operating system and to manipulate these worlds. This model enables world model at the operating system level. A parallel world or a system administrator to create a new test world that looks parallel universe model is a model to describe time machines like a production world. The system administrator upgrades in science fiction (SF) and to interpret observations in quantum fundamental software and tests applications in the new test physics. In our parallel world model at the operating system world while running the production world. If the applications level, a world is a container of files and an execution environ- do not pass the tests, the administrator deletes the new world. If the applications pass the tests, the administrator merges the ment of processes. Using this parallel world model, a system test world into the production world. Prior to the merge, the administrator can upgrade fundamental software, as follows. administrator can examine the differences between these two 1) Create one or more child worlds for upgrading and worlds, and identify any unintentional file modifications. The parallel world model has been implemented using Linux testing, based on the root world as the production containers and Aufs, a union filesystem. In addition, this im- environment and other existing derived worlds. We allow plementation uses Auditd, an audit tool, to trace file accesses multiple inheritance. A child world inherits files from in worlds. This paper describes the effectiveness of the par- multiple parents in a copy-on-write manner. allel world model by analyzing a software upgrade process. 2) Keep running the root production world while upgrading Experimental results show that the world-related operations are completed within a few seconds, and that it is difficult for remote and testing in child worlds. users to notice the overhead caused by running in parallel worlds. 3) Remove child worlds if the application does not work. 4) Merge the contents of child worlds into the root world if the application works well. Before merging, the system I. INTRODUCTION administrator can show differences between the child worlds and the root world, and see the files that will be Software bugs are found every day, and software up- modified on merging. dates or patches are released regularly. System administra- tors, especially those in small organizations, are very busy We have implemented this parallel world model in Linux upgrading fundamental software, such as Web servers and using Linux containers (LXC) [13]. We realize the copy-on- language processors. It is easy for system administrators to write feature using Aufs, a union filesystem [20]. We also perform software updates. For example, a system administra- use Audit daemon (Auditd), a system audit tool, to trace file tor can perform an update by typing “apt-get update; accesses in worlds and watch for derived files [7]. apt-get-upgrade” in a Debian-based Linux distribution. However, upgrading fundamental software can crash applica- II. COMMANDS FOR MANIPULATING WORLDS tions. System administrators must test their applications after upgrading. If they identify problems, they must undo the This section shows the usage of commands that manipulate upgrade. worlds by using the following scenario. Some systems provide transactional/undoable operations to • The production environment runs a blog application with support these activities of system administrators. Using virtual WordPress [36], which is written in the PHP language machines enables administrators to easily clone the production [32]. The Web server is Apache [31]. environment at the disk block level. However, it is not straight- • Patches are released for WordPress and PHP. The system forward to move the contents of the test environment into the administrator needs to upgrade WordPress and PHP. production environment after testing. Taking filesystem-level • Before actually upgrading, the system administrator must snapshots allows administrators to easily revert destructive test the blog application. $ exec WPUpdate bash wordpress_update.sh Root World phpphp files wordword files The second world is for upgrading PHP. httpd press logs mysqld DBDB press logs files filesfiles files $ wcreate PHPUpdate Root $ wexec PHPUpdate apt-get upgrade php5 inherit and The final world is for testing the blog application. Fig. 1 WPUpdate World copy-on-write PHPUpdate World shows the final direct acyclic graph (DAG) of these worlds. wordword phpphp presspress $ wcreate WPTest WPUpdate PHPUpdate filesfiles filesfiles inherit and Next, the system administrator dumps databases in the root copy-on-write world. Test World $ wexec Root "mysqldump --single-transaction \ --all-databases > backup_root.sql" httpd mysqld DB logslogs DB filesfiles Next, the system administrator restores databases in the test world, runs MySQL server [21], and runs the Apache Web server. Fig. 1. A direct acyclic graph of worlds for upgrading WordPress and PHP. $ wconsole WPTest WPTest$ service mysql start WPTest$ mysql < backup_root.sql • If the blog application works well in testing, the system WPTest$ service apache2 start administrator makes these patches effective in the pro- WPTest$ exit duction environment. • Otherwise, the system administrator keeps the production Next, the system administrator maps the port of the test environment unchanged, finds the causes of the problem world to the host. and considers alternatives. $ wip WPTest forward 80 50080 Table I shows commands for manipulating worlds. In the parallel world model, there is a special world called the root Now, the system administrator begins testing the blog appli- world. The root world, referred to as Root, is the base of other cation with a Web browser. If the application passes the test, derived child worlds. The root world typically runs production the system administrator sees updated files. applications. The following command runs a Web server in the $ wdiff WPUpdate Root root world. + /var/www/html/wordpress/wp-includes/js/q $ wexec Root service apache2 start uicktags.js + /var/www/html/wordpress/wp-includes/sess The system administrator also uses the wconsole com- ion.php mand to run commands interactively. + /var/www/html/wordpress/wp-admin/plugin- Next, the system administrator creates three child worlds. install.php The first world is for upgrading WordPress; its parent is the ... root world. $ wdiff PHPUpdate Root $ wcreate WPUpdate Root ... If no problem is found, the system administrator makes these modifications effective in the root world, and deletes TABLE I COMMANDS FOR MANIPULATING WORLDS. the test world that contains dirty log files and databases. Four fundamental commands $ wdelete WPTest Command Description $ wmerge WPUpdate Root wcreate Create a child world based on one or more parent $ wmerge PHPUpdate Root worlds. wdelete Delete a world. $ wexec Root service apache2 restart wdiff Show differences between two worlds. wmerge Merge a world into another world. If serious problems in the patches are found, the system administrator deletes the worlds and considers alternatives. Supplemental commands Command Description $ wdelete WPTest WPUpdate PHPUpdate wexec Run a command in a world. wconsole Connect a terminal to a world. Note that this process of upgrading and testing is not wip Configure IP addresses and port forwardings. serializable in terms of transaction processing [37]. As we check-off Checks off files on merging. see in this example, we do not need strict serializability in Containers rootfs Filesystem layers Each world has its own network namespace. When we run Test Container read-write a server in a child world, we can allocate an IP address to the mount Union logs DBDB Test child world, or we can map the server’s port number to an httpd mysqld read-only logs files layer files unused port number of the host. We create a child world based on a parent world as follows. mount PHPUpdate Container Union • We create a root directory with Aufs. First, we create phpphp PHPUpdate a new empty directory. Next, we union-mount the new filesfiles layer empty directory and the lower root directory (or directo- ries) of the parent world(s). For example, in Fig. 2, we WPUpdate Container mount union-mount the WPUpdate layer and the Root bottom Union wordword WPUpdate presspress layer layer for the WPUpdate Container. files files • We create a container by cloning a template container with the lxc-clone command. We set the root filesys- Root Container Root bottom layer tem (rootfs) of the container to the directory of Aufs wordword phpphp DB above. httpd mysqld presspress logslogs DB filesfiles files filesfiles files • We configure Auditd. We will describe Auditd in Section III-B. • We execute the container with the lxc-start com- Fig. 2. Implementation of worlds with Linux containers (LXC) and Aufs, a mand. union filesystem. To delete a world, we kill processes in the container, delete the container, unmount the Aufs directory, and remove files in the read-write layer of Aufs. software upgrading and testing. Human administrators solve To show differences between a parent and a child world, conflicts and tolerate miner problems. we show the file names in the Aufs read-write layer of the In this paper, we describe the third implementation of the child. At this time, we exclude some system files that are parallel world model. First, we implemented the model in a automatically modified by LXC.