Merge lp:~mvo/launchpad/maintenance-check-precise into lp:launchpad

Proposed by Michael Vogt on 2011-11-14
Status: Merged
Approved by: Graham Binns on 2012-01-03
Approved revision: no longer in the source branch.
Merged at revision: 14623
Proposed branch: lp:~mvo/launchpad/maintenance-check-precise
Merge into: lp:launchpad
Diff against target: 210 lines (+90/-48)
1 file modified
cronscripts/publishing/maintenance-check.py (+90/-48)
To merge this branch: bzr merge lp:~mvo/launchpad/maintenance-check-precise
Reviewer Review Type Date Requested Status
Graham Binns (community) code 2011-11-14 Approve on 2012-01-03
Review via email: mp+82125@code.launchpad.net

Commit Message

[r=gmb][bug=911175] Make the support-timeframe information that gets added to the 'Packages' file in ubuntu more flexible for the upcomming 12.04 LTS release

Description of the Change

This branch makes the support-timeframe information that gets added to the "Packages" file in ubuntu more flexible for the upcomming 12.04 LTS release.

When 10.04 (lucid) was released we added "Supported: {5y,3y,18m}" tags into the Packages file that is stored on archive.ubuntu.com. This was needed because the individual packages get a different support time based on the "seed" they are in. The server packages are longer supported than the ubuntu-desktop packages etc. The additional information makes it trivial people to check the support status of a particular package and also allows scripts like "ubuntu-support-status" to work.

For the upcoming 12.04 the timeframe is changed compared to lucid. The desktop packages are also supported for 5y and there may be architecture changes. The current code in LP is not flexible enough to handle different set of rules for LTS releases, it expected that the rules are all the same. This branch fixes this by adding a UbuntuMaintenance class that can than be used to extend for LTS releases.

Please note that I'm NOT a LP developer, this is a drive-by fix and I did not run ran the testsuite (as outlined in https://dev.launchpad.net/PatchSubmission) yet.

The QA I have done on this to run:
$ python launchpad/trunk/cronscripts/publishing/maintenance-check.py lucid > /tmp/lucid-old-code
$ python launchpad/maintenance-check-precise/cronscripts/publishing/maintenance-check.py lucid > /tmp/lucid-new-code
$ diff -u /tmp/lucid-old-code /tmp/lucid-new-code
(and the same for maverick).

To post a comment you must log in.
Graham Binns (gmb) wrote :

Hi Michael,

I'm marking this as Needs-Information because of the point about QA below. I'm happy with the code, barring one or two tweaks.

Thanks for this branch. There were a bunch of cosmetic things that
needed cleaning up, but rather than ask you to do it I've pushed up a
branch with those cleanups here:
lp:~gmb/launchpad/maintenance-check-precise. Please merge that before
landing your branch.

I'll run the test suite on the branch for you presently and report any failures.

A couple of other things:

[1]

I'd love to see some tests for this, but it doesn't seem as if there are any in the codebase (aside from a test to see if maintenance-check.py runs as part of cron.germinate). Do you know how we can QA this properly to ensure that it doesn't break things horribly? (It's okay if you don't; I can ask people who will know).

[2]

131 +
132 +# python-apt compat, the fallback can be removed once the code
133 +# runs on lucid or newer
134 +try:
135 + AcquireProgress = apt.progress.base.AcquireProgress
136 + OpProgress = apt.progress.base.OpProgress
137 +except AttributeError:
138 + # really old (hardy) interface
139 + AcquireProgress = apt.progress.FetchProgress
140 + OpProgress = apt.progress.OpProgress
141 +

Is this really necessary? I thought all our machines ran at least Lucid
now. Or is this necessary until Hardy server gets EoL'd in 2013?

review: Needs Information (code)
Michael Vogt (mvo) wrote :

Thanks a bunch for your branch! I merged it back into my branch now.

(1) As for the tests, I know this is pretty bad currently, I will think a bit about it - would you accept regular unittest2 tests? A proper LP test setup on a lucid VM is pretty expensive timewise for me.

(2) If all machines that run this code are on lucid, thats really excellent. I put it there because I wanted to be cautious, but if its not needed I will be more than happy to get rid of it.

Graham Binns (gmb) wrote :

On 16 November 2011 11:26, Michael Vogt <email address hidden> wrote:
> Thanks a bunch for your branch! I merged it back into my branch now.
>
> (1) As for the tests, I know this is pretty bad currently, I will think a bit about it - would you accept regular unittest2 tests? A proper LP test setup on a lucid VM is pretty expensive timewise for me.

That will certainly work for me. If you write the tests I'll do the
work to integrate them into the LP suite.

> (2) If all machines that run this code are on lucid, thats really excellent. I put it there because I wanted to be cautious, but if its not needed I will be more than happy to get rid of it.

Okay, I'll double-check with the LOSAs on this one and get back to you.

Graham Binns (gmb) wrote :

On 16 November 2011 11:26, Michael Vogt <email address hidden> wrote:
> (2) If all machines that run this code are on lucid, thats really excellent. I put it there because I wanted to be cautious, but if its not needed I will be more than happy to get rid of it.

I've just checked with the LOSAs; mthaddon confirms that all machines
are running Lucid, so let's drop this and rejoice! :)

Colin Watson (cjwatson) wrote :

If it helps the QA question, I intend to rewrite maintenance-check in terms of python-germinate at some point in the not too distant future and integrate it into generate-extra-overrides. This is part of my work item in https://blueprints.launchpad.net/ubuntu/+spec/foundations-p-image-build-pipeline to get extra overrides generated before the publisher writes indexes so that we stop having hysteresis across publisher runs. As part of that I'm more than happy to write much more comprehensive unit tests, and this will also reduce this script's dependency on external URLs (notably the germinate output on people.canonical.com).

I hope to be able to do this within about the next two months.

Colin Watson (cjwatson) wrote :

Oh, and to QA this before any of my future work lands, the simplest way to do this right now is as follows, on mawson:

 * Run cronscripts/publishing/cron.germinate.
 * Take a backup of /srv/launchpad.net/ubuntu-archive/ubuntu-misc.
 * Apply Michael's branch.
 * Run cronscripts/publishing/cron.germinate again.
 * Diff /srv/launchpad.net/ubuntu-archive/ubuntu-misc against the backup and sign off any differences.

(You can set the TEST_LAUNCHPADROOT environment variable if at any point you need to run cron.germinate from somewhere other than /srv/launchpad.net/codelines/current.)

This procedure should take well under half an hour. I did it recently for another branch, so I'd be happy to QA this if you want. I'd like to see Michael's branch landed, both because it would be good for appropriate Supported extra overrides to be in place for Precise as soon as possible, and because the longer it remains outstanding the more I'll have to deal with conflicts between this and my work in progress (for instance, I think I'll already have to resolve my new-python-apt branch against this, assuming that this one lands first).

Graham Binns (gmb) wrote :

Thanks to Colin and Michael for their stirling work. I'll get this landed in the near future.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cronscripts/publishing/maintenance-check.py'
2--- cronscripts/publishing/maintenance-check.py 2011-12-24 13:09:35 +0000
3+++ cronscripts/publishing/maintenance-check.py 2012-01-03 11:04:30 +0000
4@@ -2,9 +2,6 @@
5 #
6 # python port of the nice maintainace-check script by Nick Barcet
7 #
8-# Taken from:
9-# https://code.edge.launchpad.net/~mvo/ubuntu-maintenance-check/python-port
10-# (where it will vanish once taken here)
11
12 import logging
13 from optparse import OptionParser
14@@ -16,6 +13,43 @@
15 import apt
16 import apt_pkg
17
18+
19+class UbuntuMaintenance(object):
20+ """ Represents the support timeframe for a regular ubuntu release """
21+
22+ # architectures that are full supported (including LTS time)
23+ PRIMARY_ARCHES = [
24+ "i386",
25+ "amd64",
26+ ]
27+
28+ # architectures we support (but not for LTS time)
29+ SUPPORTED_ARCHES = PRIMARY_ARCHES + ["armel"]
30+
31+ # what defines the seeds is documented in wiki.ubuntu.com/SeedManagement
32+ SERVER_SEEDS = [
33+ "server-ship",
34+ "supported-server",
35+ ]
36+ DESKTOP_SEEDS = [
37+ "ship",
38+ "supported-desktop",
39+ "supported-desktop-extra",
40+ ]
41+ SUPPORTED_SEEDS = ["all"]
42+
43+ # normal support timeframe
44+ # time, seeds
45+ SUPPORT_TIMEFRAME = [
46+ ("18m", SUPPORTED_SEEDS),
47+ ]
48+
49+ # distro names that we check the seeds for
50+ DISTRO_NAMES = [
51+ "ubuntu",
52+ ]
53+
54+
55 # This is fun! We have a bunch of cases for 10.04 LTS
56 #
57 # - distro "ubuntu" follows SUPPORT_TIMEFRAME_LTS but only for
58@@ -24,41 +58,44 @@
59 # considered *but* only follow SUPPORT_TIMEFRAME
60 # - anything that is in armel follows SUPPORT_TIMEFRAME
61 #
62-
63-# codename of the lts releases
64-LTS_RELEASES = ["dapper", "hardy", "lucid"]
65-
66-# architectures that are full supported (including LTS time)
67-PRIMARY_ARCHES = ["i386", "amd64"]
68-
69-# architectures we support (but not for LTS time)
70-SUPPORTED_ARCHES = PRIMARY_ARCHES + ["armel"]
71-
72-# what defines the seeds is documented in wiki.ubuntu.com/SeedManagement
73-SERVER_SEEDS = ["supported-server", "server-ship"]
74-DESKTOP_SEEDS = ["ship", "supported-desktop", "supported-desktop-extra"]
75-SUPPORTED_SEEDS = ["all"]
76-
77-# normal support timeframe
78-# time, seeds, arches
79-SUPPORT_TIMEFRAME = [
80- ("18m", SUPPORTED_SEEDS),
81-]
82-
83-# lts support timeframe
84-# time, seeds, arches
85-SUPPORT_TIMEFRAME_LTS = [
86- ("5y", SERVER_SEEDS),
87- ("3y", DESKTOP_SEEDS),
88- ("18m", SUPPORTED_SEEDS),
89-]
90-
91-# distro names and if they get LTS support (order is important)
92-DISTRO_NAMES_AND_LTS_SUPPORT = [
93- ("ubuntu", True),
94- ("kubuntu", True),
95- ("netbook", False),
96- ]
97+class LucidUbuntuMaintenance(UbuntuMaintenance):
98+ """ Represents the support timeframe for a 10.04 (lucid) LTS release,
99+ the exact rules differ from LTS release to LTS release
100+ """
101+
102+ # lts support timeframe, order is important, least supported must be last
103+ # time, seeds
104+ SUPPORT_TIMEFRAME = [
105+ ("5y", UbuntuMaintenance.SERVER_SEEDS),
106+ ("3y", UbuntuMaintenance.DESKTOP_SEEDS),
107+ ("18m", UbuntuMaintenance.SUPPORTED_SEEDS),
108+ ]
109+
110+ # on a LTS this is significant, it defines what names get LTS support
111+ DISTRO_NAMES = [
112+ "ubuntu",
113+ "kubuntu",
114+ ]
115+
116+
117+class PreciseUbuntuMaintenance(UbuntuMaintenance):
118+ """ The support timeframe for the 12.04 (precise) LTS release.
119+ This changes the timeframe for desktop packages from 3y to 5y
120+ """
121+
122+ # lts support timeframe, order is important, least supported must be last
123+ # time, seeds
124+ SUPPORT_TIMEFRAME = [
125+ ("5y", UbuntuMaintenance.SERVER_SEEDS),
126+ ("5y", UbuntuMaintenance.DESKTOP_SEEDS),
127+ ("18m", UbuntuMaintenance.SUPPORTED_SEEDS),
128+ ]
129+
130+ # on a LTS this is significant, it defines what names get LTS support
131+ DISTRO_NAMES = [
132+ "ubuntu",
133+ ]
134+
135
136 # Names of the distribution releases that are not supported by this
137 # tool. All later versions are supported.
138@@ -312,6 +349,12 @@
139 else:
140 distro = "lucid"
141
142+ # maintenance class to use
143+ klass = globals().get("%sUbuntuMaintenance" % distro.capitalize())
144+ if klass is None:
145+ klass = UbuntuMaintenance
146+ ubuntu_maintenance = klass()
147+
148 # make sure our deb-src information is up-to-date
149 create_and_update_deb_src_source_list(distro)
150
151@@ -326,7 +369,7 @@
152
153 # go over the distros we need to check
154 pkg_support_time = {}
155- for (name, lts_supported) in DISTRO_NAMES_AND_LTS_SUPPORT:
156+ for name in ubuntu_maintenance.DISTRO_NAMES:
157
158 # get basic structure file
159 try:
160@@ -336,17 +379,13 @@
161 continue
162
163 # get dicts of pkgname -> support timeframe string
164- support_timeframe = SUPPORT_TIMEFRAME
165- if lts_supported and distro in LTS_RELEASES:
166- support_timeframe = SUPPORT_TIMEFRAME_LTS
167- else:
168- support_timeframe = SUPPORT_TIMEFRAME
169+ support_timeframe = ubuntu_maintenance.SUPPORT_TIMEFRAME
170 get_packages_support_time(
171 structure, name, pkg_support_time, support_timeframe)
172
173 # now go over the bits in main that we have not seen (because
174 # they are not in any seed and got added manually into "main"
175- for arch in PRIMARY_ARCHES:
176+ for arch in ubuntu_maintenance.PRIMARY_ARCHES:
177 rootdir = "./aptroot.%s" % distro
178 apt_pkg.config.set("APT::Architecture", arch)
179 cache = apt.Cache(rootdir=rootdir)
180@@ -356,6 +395,9 @@
181 logging.exception("cache.update() failed")
182 cache.open()
183 for pkg in cache:
184+ # ignore multiarch package names
185+ if ":" in pkg.name:
186+ continue
187 if not pkg.name in pkg_support_time:
188 pkg_support_time[pkg.name] = support_timeframe[-1][0]
189 logging.warn(
190@@ -404,12 +446,12 @@
191 # go over the supported arches, they are divided in
192 # first-class (PRIMARY) and second-class with different
193 # support levels
194- for arch in SUPPORTED_ARCHES:
195+ for arch in ubuntu_maintenance.SUPPORTED_ARCHES:
196 # ensure we do not overwrite arch-specific overwrites
197 pkgname_and_arch = "%s/%s" % (pkgname, arch)
198 if pkgname_and_arch in pkg_support_time:
199 break
200- if arch in PRIMARY_ARCHES:
201+ if arch in ubuntu_maintenance.PRIMARY_ARCHES:
202 # arch with full LTS support
203 print "%s %s %s" % (
204 pkgname_and_arch, SUPPORT_TAG,
205@@ -419,4 +461,4 @@
206 # support_timeframe
207 print "%s %s %s" % (
208 pkgname_and_arch, SUPPORT_TAG,
209- SUPPORT_TIMEFRAME[0][0])
210+ ubuntu_maintenance.SUPPORT_TIMEFRAME[-1][0])