Merge lp:~brian-murray/ubuntu-release-upgrader/remove-aufs into lp:ubuntu-release-upgrader

Proposed by Brian Murray
Status: Merged
Merged at revision: 3053
Proposed branch: lp:~brian-murray/ubuntu-release-upgrader/remove-aufs
Merge into: lp:ubuntu-release-upgrader
Diff against target: 480 lines (+9/-352)
8 files modified
DistUpgrade/DistUpgradeAufs.py (+0/-289)
DistUpgrade/DistUpgradeController.py (+0/-25)
DistUpgrade/DistUpgradeMain.py (+2/-5)
DistUpgrade/DistUpgradeView.py (+0/-15)
data/DistUpgrade.cfg (+0/-11)
data/do-release-upgrade.8 (+0/-3)
debian/changelog (+7/-0)
do-release-upgrade (+0/-4)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-release-upgrader/remove-aufs
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+324216@code.launchpad.net

Description of the change

I spoke with Michael about the --sandbox option failing and he recommended just removing the aufs support so I did.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

LGTM, one minor comment inline.

review: Approve
Revision history for this message
Brian Murray (brian-murray) wrote :

Okay, I'll make that change.

3054. By Brian Murray

Remove error handling for AUFS option in environ.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'DistUpgrade/DistUpgradeAufs.py'
2--- DistUpgrade/DistUpgradeAufs.py 2015-01-20 22:44:02 +0000
3+++ DistUpgrade/DistUpgradeAufs.py 1970-01-01 00:00:00 +0000
4@@ -1,289 +0,0 @@
5-# DistUpgradeAufs.py
6-#
7-# Copyright (c) 2009-2012 Canonical
8-#
9-# Author: Michael Vogt <michael.vogt@ubuntu.com>
10-#
11-# This program is free software; you can redistribute it and/or
12-# modify it under the terms of the GNU General Public License as
13-# published by the Free Software Foundation; either version 2 of the
14-# License, or (at your option) any later version.
15-#
16-# This program is distributed in the hope that it will be useful,
17-# but WITHOUT ANY WARRANTY; without even the implied warranty of
18-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-# GNU General Public License for more details.
20-#
21-# You should have received a copy of the GNU General Public License
22-# along with this program; if not, write to the Free Software
23-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24-# USA
25-
26-import logging
27-import os
28-import subprocess
29-import tempfile
30-
31-
32-def aufsOptionsAndEnvironmentSetup(options, config):
33- """ setup the environment based on the config and options
34- It will use
35- config("Aufs","Enabled") - to show if its enabled
36- and
37- config("Aufs","RWDir") - for the writable overlay dir
38- """
39- logging.debug("aufsOptionsAndEnvironmentSetup()")
40- # enabled from the commandline (full overlay by default)
41- if options and options.useAufs:
42- logging.debug("enabling full overlay from commandline")
43- config.set("Aufs", "Enabled", "True")
44- config.set("Aufs", "EnableFullOverlay", "True")
45-
46- # setup environment based on config
47- tmprw = tempfile.mkdtemp(prefix="upgrade-rw-")
48- aufs_rw_dir = config.getWithDefault("Aufs", "RWDir", tmprw)
49- logging.debug("using '%s' as aufs_rw_dir" % aufs_rw_dir)
50- os.environ["RELEASE_UPGRADE_AUFS_RWDIR"] = aufs_rw_dir
51- config.set("Aufs", "RWDir", aufs_rw_dir)
52- # now the chroot tmpdir
53- tmpchroot = tempfile.mkdtemp(prefix="upgrade-chroot-")
54- os.chmod(tmpchroot, 0o755)
55- aufs_chroot_dir = config.getWithDefault("Aufs", "ChrootDir", tmpchroot)
56- logging.debug("using '%s' as aufs chroot dir" % aufs_chroot_dir)
57-
58- if config.getWithDefault("Aufs", "EnableFullOverlay", False):
59- logging.debug("enabling aufs full overlay (from config)")
60- config.set("Aufs", "Enabled", "True")
61- os.environ["RELEASE_UPGRADE_USE_AUFS_FULL_OVERLAY"] = "1"
62- if config.getWithDefault("Aufs", "EnableChrootOverlay", False):
63- logging.debug("enabling aufs chroot overlay")
64- config.set("Aufs", "Enabled", "True")
65- os.environ["RELEASE_UPGRADE_USE_AUFS_CHROOT"] = aufs_chroot_dir
66- if config.getWithDefault("Aufs", "EnableChrootRsync", False):
67- logging.debug("enable aufs chroot rsync back to real system")
68- os.environ["RELEASE_UPGRADE_RSYNC_AUFS_CHROOT"] = "1"
69-
70-
71-def _bindMount(from_dir, to_dir, rbind=False):
72- " helper that bind mounts a given dir to a new place "
73- if not os.path.exists(to_dir):
74- os.makedirs(to_dir)
75- if rbind:
76- bind = "--rbind"
77- else:
78- bind = "--bind"
79- cmd = ["mount", bind, from_dir, to_dir]
80- logging.debug("cmd: %s" % cmd)
81- res = subprocess.call(cmd)
82- if res != 0:
83- # FIXME: revert already mounted stuff
84- logging.error(
85- "Failed to bind mount from '%s' to '%s'" % (from_dir, to_dir))
86- return False
87- return True
88-
89-
90-def _aufsOverlayMount(target, rw_dir, chroot_dir="/"):
91- """
92- helper that takes a target dir and mounts a rw dir over it, e.g.
93- /var , /tmp/upgrade-rw
94- """
95- if not os.path.exists(rw_dir + target):
96- os.makedirs(rw_dir + target)
97- if not os.path.exists(chroot_dir + target):
98- os.makedirs(chroot_dir + target)
99- # FIXME: figure out when to use aufs and when to use overlayfs
100- use_overlayfs = False
101- if use_overlayfs:
102- cmd = ["mount",
103- "-t", "overlayfs",
104- "-o", "upperdir=%s,lowerdir=%s" % (rw_dir + target, target),
105- "none",
106- chroot_dir + target]
107- else:
108- cmd = ["mount",
109- "-t", "aufs",
110- "-o", "br:%s:%s=ro" % (rw_dir + target, target),
111- "none",
112- chroot_dir + target]
113- res = subprocess.call(cmd)
114- if res != 0:
115- # FIXME: revert already mounted stuff
116- logging.error("Failed to mount rw aufs overlay for '%s'" % target)
117- return False
118- logging.debug("cmd '%s' return '%s' " % (cmd, res))
119- return True
120-
121-
122-def is_aufs_mount(dir):
123- " test if the given dir is already mounted with aufs overlay "
124- with open("/proc/mounts") as f:
125- for line in f:
126- (device, mountpoint, fstype, options, a, b) = line.split()
127- if device == "none" and fstype == "aufs" and mountpoint == dir:
128- return True
129- return False
130-
131-
132-def is_submount(mountpoint, systemdirs):
133- " helper: check if the given mountpoint is a submount of a systemdir "
134- logging.debug("is_submount: %s %s" % (mountpoint, systemdirs))
135- for d in systemdirs:
136- if not d.endswith("/"):
137- d += "/"
138- if mountpoint.startswith(d):
139- return True
140- return False
141-
142-
143-def is_real_fs(fs):
144- if fs.startswith("fuse"):
145- return False
146- if fs in ["rootfs", "tmpfs", "proc", "fusectrl", "aufs",
147- "devpts", "binfmt_misc", "sysfs"]:
148- return False
149- return True
150-
151-
152-def doAufsChrootRsync(aufs_chroot_dir):
153- """
154- helper that rsyncs the changes in the aufs chroot back to the
155- real system
156- """
157- from .DistUpgradeMain import SYSTEM_DIRS
158- for d in SYSTEM_DIRS:
159- if not os.path.exists(d):
160- continue
161- # its important to have the "/" at the end of source
162- # and dest so that rsync knows what to do
163- cmd = ["rsync", "-aHAX", "--del", "-v", "--progress",
164- "/%s/%s/" % (aufs_chroot_dir, d),
165- "/%s/" % d]
166- logging.debug("running: '%s'" % cmd)
167- ret = subprocess.call(cmd)
168- logging.debug("rsync back result for %s: %i" % (d, ret))
169- return True
170-
171-
172-def doAufsChroot(aufs_rw_dir, aufs_chroot_dir):
173- " helper that sets the chroot up and does chroot() into it "
174- if not setupAufsChroot(aufs_rw_dir, aufs_chroot_dir):
175- return False
176- os.chroot(aufs_chroot_dir)
177- os.chdir("/")
178- return True
179-
180-
181-def setupAufsChroot(rw_dir, chroot_dir):
182- " setup aufs chroot that is based on / but with a writable overlay "
183- # with the chroot aufs we can just rsync the changes back
184- # from the chroot dir to the real dirs
185- #
186- # (if we run rsync with --backup --backup-dir we could even
187- # create something vaguely rollbackable
188-
189- # get the mount points before the aufs buisiness starts
190- with open("/proc/mounts") as f:
191- mounts = f.read()
192- from .DistUpgradeMain import SYSTEM_DIRS
193- systemdirs = SYSTEM_DIRS
194-
195- # aufs mount or bind mount required dirs
196- for d in os.listdir("/"):
197- d = os.path.join("/", d)
198- if os.path.isdir(d):
199- if d in systemdirs:
200- logging.debug("bind mounting %s" % d)
201- if not _aufsOverlayMount(d, rw_dir, chroot_dir):
202- return False
203- else:
204- logging.debug("overlay mounting %s" % d)
205- if not _bindMount(d, chroot_dir + d, rbind=True):
206- return False
207-
208- # create binds for the systemdirs
209- #needs_bind_mount = set()
210- for line in mounts.split("\n"):
211- line = line.strip()
212- if not line:
213- continue
214- (device, mountpoint, fstype, options, a, b) = line.split()
215- if (fstype != "aufs" and
216- not is_real_fs(fstype) and
217- is_submount(mountpoint, systemdirs)):
218- logging.debug("found %s that needs bind mount", mountpoint)
219- if not _bindMount(mountpoint, chroot_dir + mountpoint):
220- return False
221- return True
222-
223-
224-def setupAufs(rw_dir):
225- " setup aufs overlay over the rootfs "
226- # * we need to find a way to tell all the existing daemon
227- # to look into the new namespace. so probably something
228- # like a reboot is required and some hackery in initramfs-tools
229- # to ensure that we boot into a overlay ready system
230- # * this is much less of a issue with the aufsChroot code
231- logging.debug("setupAufs")
232- if not os.path.exists("/proc/mounts"):
233- logging.debug("no /proc/mounts, can not do aufs overlay")
234- return False
235-
236- from .DistUpgradeMain import SYSTEM_DIRS
237- systemdirs = SYSTEM_DIRS
238- # verify that there are no submounts of a systemdir and collect
239- # the stuff that needs bind mounting (because a aufs does not
240- # include sub mounts)
241- needs_bind_mount = set()
242- needs_bind_mount.add("/var/cache/apt/archives")
243- with open("/proc/mounts") as f:
244- for line in f:
245- (device, mountpoint, fstype, options, a, b) = line.split()
246- if is_real_fs(fstype) and is_submount(mountpoint, systemdirs):
247- logging.warning("mountpoint %s submount of systemdir" %
248- mountpoint)
249- return False
250- if (fstype != "aufs" and
251- not is_real_fs(fstype) and
252- is_submount(mountpoint, systemdirs)):
253- logging.debug("found %s that needs bind mount", mountpoint)
254- needs_bind_mount.add(mountpoint)
255-
256- # aufs mounts do not support stacked filesystems, so
257- # if we mount /var we will loose the tmpfs stuff
258- # first bind mount varun and varlock into the tmpfs
259- for d in needs_bind_mount:
260- if not _bindMount(d, rw_dir + "/needs_bind_mount/" + d):
261- return False
262- # setup writable overlay into /tmp/upgrade-rw so that all
263- # changes are written there instead of the real fs
264- for d in systemdirs:
265- if not is_aufs_mount(d):
266- if not _aufsOverlayMount(d, rw_dir):
267- return False
268- # now bind back the tempfs to the original location
269- for d in needs_bind_mount:
270- if not _bindMount(rw_dir + "/needs_bind_mount/" + d, d):
271- return False
272-
273- # The below information is only of historical relevance:
274- # now what we *could* do to apply the changes is to
275- # mount -o bind / /orig
276- # (bind is important, *not* rbind that includes submounts)
277- #
278- # This will give us the original "/" without the
279- # aufs rw overlay - *BUT* only if "/" is all on one parition
280- #
281- # then apply the diff (including the whiteouts) to /orig
282- # e.g. by "rsync -av /tmp/upgrade-rw /orig"
283- # "script that search for whiteouts and removes them"
284- # (whiteout files start with .wh.$name
285- # whiteout dirs with .wh..? - check with aufs man page)
286- return True
287-
288-
289-if __name__ == "__main__":
290- logging.basicConfig(level=logging.DEBUG)
291- #print(setupAufs("/tmp/upgrade-rw"))
292- print(setupAufsChroot("/tmp/upgrade-chroot-rw",
293- "/tmp/upgrade-chroot"))
294
295=== modified file 'DistUpgrade/DistUpgradeController.py'
296--- DistUpgrade/DistUpgradeController.py 2016-08-10 15:09:46 +0000
297+++ DistUpgrade/DistUpgradeController.py 2017-05-18 17:34:09 +0000
298@@ -57,7 +57,6 @@
299 from .DistUpgradeConfigParser import DistUpgradeConfig
300 from .DistUpgradeQuirks import DistUpgradeQuirks
301 from .DistUpgradeAptCdrom import AptCdrom
302-from .DistUpgradeAufs import setupAufs, aufsOptionsAndEnvironmentSetup
303
304 # workaround broken relative import in python-apt (LP: #871007), we
305 # want the local version of distinfo.py from oneiric, but because of
306@@ -138,9 +137,6 @@
307 self.config.add_section("Options")
308 self.config.set("Options","withNetwork", str(self.useNetwork))
309
310- # aufs stuff
311- aufsOptionsAndEnvironmentSetup(self.options, self.config)
312-
313 # some constants here
314 self.fromDist = self.config.get("Sources","From")
315 self.toDist = self.config.get("Sources","To")
316@@ -399,27 +395,6 @@
317 "supported with this tool." % (release, self.toDist)))
318 sys.exit(1)
319
320- # setup aufs
321- if self.config.getWithDefault("Aufs", "EnableFullOverlay", False):
322- aufs_rw_dir = self.config.get("Aufs","RWDir")
323- if not setupAufs(aufs_rw_dir):
324- logging.error("aufs setup failed")
325- self._view.error(_("Sandbox setup failed"),
326- _("It was not possible to create the sandbox "
327- "environment."))
328- return False
329-
330- # all good, tell the user about the sandbox mode
331- logging.info("running in aufs overlay mode")
332- self._view.information(_("Sandbox mode"),
333- _("This upgrade is running in sandbox "
334- "(test) mode. All changes are written "
335- "to '%s' and will be lost on the next "
336- "reboot.\n\n"
337- "*No* changes written to a system directory "
338- "from now until the next reboot are "
339- "permanent.") % aufs_rw_dir)
340-
341 # setup backports (if we have them)
342 if self.options and self.options.havePrerequists:
343 backportsdir = os.getcwd()+"/backports"
344
345=== modified file 'DistUpgrade/DistUpgradeMain.py'
346--- DistUpgrade/DistUpgradeMain.py 2017-05-03 10:03:08 +0000
347+++ DistUpgrade/DistUpgradeMain.py 2017-05-18 17:34:09 +0000
348@@ -33,8 +33,8 @@
349 from optparse import OptionParser
350 from gettext import gettext as _
351
352-# dirs that the packages will touch, this is needed for AUFS/overlayfs
353-# and also for the sanity check before the upgrade
354+# dirs that the packages will touch, this is needed for the sanity check
355+# before the upgrade
356 SYSTEM_DIRS = ["/bin",
357 "/boot",
358 "/etc",
359@@ -54,9 +54,6 @@
360 def do_commandline():
361 " setup option parser and parse the commandline "
362 parser = OptionParser()
363- parser.add_option("-s", "--sandbox", dest="useAufs", default=False,
364- action="store_true",
365- help=_("Sandbox upgrade using aufs"))
366 parser.add_option("-c", "--cdrom", dest="cdromPath", default=None,
367 help=_("Use the given path to search for a cdrom with upgradable packages"))
368 parser.add_option("--have-prerequists", dest="havePrerequists",
369
370=== modified file 'DistUpgrade/DistUpgradeView.py'
371--- DistUpgrade/DistUpgradeView.py 2016-02-08 22:40:04 +0000
372+++ DistUpgrade/DistUpgradeView.py 2017-05-18 17:34:09 +0000
373@@ -30,7 +30,6 @@
374 import signal
375 import select
376
377-from .DistUpgradeAufs import doAufsChroot, doAufsChrootRsync
378 from .DistUpgradeApport import apport_pkgfailure
379
380
381@@ -212,12 +211,6 @@
382 def run(self, pm):
383 pid = self.fork()
384 if pid == 0:
385- # check if we need to setup/enable the aufs chroot stuff
386- if "RELEASE_UPGRADE_USE_AUFS_CHROOT" in os.environ:
387- if not doAufsChroot(os.environ["RELEASE_UPGRADE_AUFS_RWDIR"],
388- os.environ["RELEASE_UPGRADE_USE_AUFS_CHROOT"]):
389- print("ERROR: failed to setup aufs chroot overlay")
390- os._exit(1)
391 # child, ignore sigpipe, there are broken scripts out there
392 # like etckeeper (LP: #283642)
393 signal.signal(signal.SIGPIPE,signal.SIG_IGN)
394@@ -232,14 +225,6 @@
395 os._exit(res)
396 self.child_pid = pid
397 res = os.WEXITSTATUS(self.wait_child())
398- # check if we want to sync the changes back, *only* do that
399- # if res is positive
400- if (res == 0 and
401- "RELEASE_UPGRADE_RSYNC_AUFS_CHROOT" in os.environ):
402- logging.info("doing rsync commit of the update")
403- if not doAufsChrootRsync(os.environ["RELEASE_UPGRADE_USE_AUFS_CHROOT"]):
404- logging.error("FATAL ERROR: doAufsChrootRsync() returned FALSE")
405- return pm.RESULT_FAILED
406 return res
407
408 def error(self, pkg, errormsg):
409
410=== modified file 'data/DistUpgrade.cfg'
411--- data/DistUpgrade.cfg 2017-04-24 21:15:03 +0000
412+++ data/DistUpgrade.cfg 2017-05-18 17:34:09 +0000
413@@ -128,17 +128,6 @@
414 ;SourcesList-ia64=prerequists-sources.ports.list
415 ;SourcesList-hppa=prerequists-sources.ports.list
416
417-[Aufs]
418-; this is a xor option, either full or chroot overlay
419-;EnableFullOverlay=yes
420-;EnableChrootOverlay=yes
421-; sync changes from the chroot back to the real system
422-;EnableChrootRsync=yes
423-; what chroot dir to use
424-;ChrootDir=/tmp/upgrade-chroot
425-; the RW dir to use (either for full overlay or chroot overlay)
426-;RWDir=/tmp/upgrade-rw
427-
428 [Network]
429 MaxRetries=3
430
431
432=== modified file 'data/do-release-upgrade.8'
433--- data/do-release-upgrade.8 2012-06-13 11:47:22 +0000
434+++ data/do-release-upgrade.8 2017-05-18 17:34:09 +0000
435@@ -28,8 +28,5 @@
436 .TP
437 \fB\-f\fR FRONTEND, \fB\-\-frontend\fR=\fIFRONTEND\fR
438 Run the specified frontend
439-.TP
440-\fB\-s\fR, \fB\-\-sandbox\fR
441-Test upgrade with a sandbox aufs overlay
442 .SH "SEE ALSO"
443 \fBupdate\-manager\fR(8), \fBapt\-get\fR(8)
444
445=== modified file 'debian/changelog'
446--- debian/changelog 2017-05-03 16:12:01 +0000
447+++ debian/changelog 2017-05-18 17:34:09 +0000
448@@ -1,3 +1,10 @@
449+ubuntu-release-upgrader (1:17.10.3) UNRELEASED; urgency=medium
450+
451+ * Remove --sandbox (aufs support) as it has been broken for some time and
452+ was rather unused. (LP: #1605259)
453+
454+ -- Brian Murray <brian@ubuntu.com> Wed, 17 May 2017 14:38:24 -0700
455+
456 ubuntu-release-upgrader (1:17.10.2) artful; urgency=medium
457
458 [ Balint Reczey ]
459
460=== modified file 'do-release-upgrade'
461--- do-release-upgrade 2015-04-16 23:00:33 +0000
462+++ do-release-upgrade 2017-05-18 17:34:09 +0000
463@@ -96,8 +96,6 @@
464 parser.add_option ("-f", "--frontend", default="DistUpgradeViewText",
465 dest="frontend",
466 help=_("Run the specified frontend"))
467- parser.add_option ("-s","--sandbox", action="store_true", default=False,
468- help=_("Test upgrade with a sandbox aufs overlay"))
469 parser.add_option ("-c", "--check-dist-upgrade-only", action="store_true",
470 default=check_only,
471 help=_("Check only if a new distribution release is "
472@@ -158,8 +156,6 @@
473 fetcher.run_options += ["--mode=%s" % options.mode,
474 "--frontend=%s" % options.frontend,
475 ]
476- if options.sandbox:
477- fetcher.run_options.append("--sandbox")
478 if options.devel_release:
479 fetcher.run_options.append("--devel-release")
480 fetcher.run()

Subscribers

People subscribed via source and target branches