Merge lp:~sil2100/ubuntu-cdimage/uc-series-and-more-rebuild into lp:ubuntu-cdimage

Proposed by Łukasz Zemczak
Status: Merged
Merged at revision: 2061
Proposed branch: lp:~sil2100/ubuntu-cdimage/uc-series-and-more-rebuild
Merge into: lp:ubuntu-cdimage
Diff against target: 179 lines (+72/-20)
3 files modified
bin/rebuild-requests (+3/-0)
lib/cdimage/config.py (+35/-13)
lib/cdimage/tests/test_config.py (+34/-7)
To merge this branch: bzr merge lp:~sil2100/ubuntu-cdimage/uc-series-and-more-rebuild
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+424288@code.launchpad.net

Commit message

Add proper core series handling to the config. Convert the UC milestone series to Ubuntu series.

Description of the change

Add proper core series handling to the config. Convert the UC milestone series to Ubuntu series.

So the previous change wasn't entirely complete. Generally the ISO Tracker milestones result in the DIST being the core series (so like '22'), which doesn't really currently easily translate to anything in cdimage.

It's about time we actually started treating core series a bit more 'serious'. So I'm adding some code to the config.py Series and Config items to properly handle UC series. There were a few different ways to do it - originally I wanted to do a separate entry for Ubuntu Core items (with those having distribution="ubuntu-core"), but then I think that it's enough to re-use existing series. Since UC series and Ubuntu series are basically part of the same thing. This is why I think this way seems a bit better.

Controversial might be the fact of hard-coding that devel == UCXX+2, but I think this is the logical choice. We *anyway* always handle it this way, just implicitly. We always assumed > than latest core to be the devel core series. I think this is the way to go here.

To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Since I added some unit tests, those can be ran by using `PYTHONPATH=lib python3 -m unittest cdimage.tests.test_config` (since the test suite is still not clean due to my simplestream fixing branch not yet finished).

Revision history for this message
Steve Langasek (vorlon) :
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Thank you for your swift review Steve! I answered your inline question inline :)

Revision history for this message
Steve Langasek (vorlon) wrote :

Thanks, lgtm then

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/rebuild-requests'
--- bin/rebuild-requests 2022-06-09 08:31:08 +0000
+++ bin/rebuild-requests 2022-06-09 12:23:48 +0000
@@ -201,6 +201,9 @@
201 # Due to the different structure, IMAGE_TYPE is the channel201 # Due to the different structure, IMAGE_TYPE is the channel
202 # here202 # here
203 env['CHANNEL'] = entry[2]203 env['CHANNEL'] = entry[2]
204 # And cdimage still uses distro series for the core series
205 # builds
206 env['DIST'] = Series.find_by_core_series(env['DIST']).name
204 image_type = "daily-live"207 image_type = "daily-live"
205208
206 cmd = ["for-project", project, "cron.%s" % image_type]209 cmd = ["for-project", project, "cron.%s" % image_type]
207210
=== modified file 'lib/cdimage/config.py'
--- lib/cdimage/config.py 2022-05-02 18:54:08 +0000
+++ lib/cdimage/config.py 2022-06-09 12:23:48 +0000
@@ -85,6 +85,21 @@
85 return series85 return series
86 raise ValueError("No series with distribution %s" % distribution)86 raise ValueError("No series with distribution %s" % distribution)
8787
88 @classmethod
89 def find_by_core_series(self, core_series):
90 for series in all_series:
91 if series.core_series == core_series:
92 return series
93 else:
94 raise ValueError(
95 "No Ubuntu Core series %s" % core_series)
96
97 @classmethod
98 def latest_core(self):
99 for series in reversed(all_series):
100 if getattr(series, "_core_series", None):
101 return series
102
88 def __str__(self):103 def __str__(self):
89 return self.name104 return self.name
90105
@@ -148,6 +163,17 @@
148 def realversion(self):163 def realversion(self):
149 return getattr(self, "pointversion", self.version)164 return getattr(self, "pointversion", self.version)
150165
166 @property
167 def core_series(self):
168 core_version = getattr(self, "_core_series", None)
169 if not core_version and self.is_latest:
170 # Automatically handle the devel series being 'XX+2', without
171 # having to manually bump it everytime we prepare for the next
172 # core series
173 latest_core = Series.latest_core()
174 core_version = str(int(latest_core.core_series) + 2)
175 return core_version
176
151177
152# TODO: This should probably come from a configuration file.178# TODO: This should probably come from a configuration file.
153all_series.extend([179all_series.extend([
@@ -194,14 +220,16 @@
194 Series(220 Series(
195 "xenial", "16.04", "Xenial Xerus",221 "xenial", "16.04", "Xenial Xerus",
196 pointversion="16.04.7",222 pointversion="16.04.7",
197 all_lts_projects=True),223 all_lts_projects=True,
224 _core_series="16"),
198 Series("yakkety", "16.10", "Yakkety Yak"),225 Series("yakkety", "16.10", "Yakkety Yak"),
199 Series("zesty", "17.04", "Zesty Zapus"),226 Series("zesty", "17.04", "Zesty Zapus"),
200 Series("artful", "17.10", "Artful Aardvark"),227 Series("artful", "17.10", "Artful Aardvark"),
201 Series(228 Series(
202 "bionic", "18.04", "Bionic Beaver",229 "bionic", "18.04", "Bionic Beaver",
203 pointversion="18.04.6",230 pointversion="18.04.6",
204 all_lts_projects=True),231 all_lts_projects=True,
232 _core_series="18"),
205 Series("cosmic", "18.10", "Cosmic Cuttlefish"),233 Series("cosmic", "18.10", "Cosmic Cuttlefish"),
206 Series("disco", "19.04", "Disco Dingo"),234 Series("disco", "19.04", "Disco Dingo"),
207 Series(235 Series(
@@ -210,13 +238,15 @@
210 Series(238 Series(
211 "focal", "20.04", "Focal Fossa",239 "focal", "20.04", "Focal Fossa",
212 pointversion="20.04.4",240 pointversion="20.04.4",
213 all_lts_projects=True),241 all_lts_projects=True,
242 _core_series="20"),
214 Series("groovy", "20.10", "Groovy Gorilla"),243 Series("groovy", "20.10", "Groovy Gorilla"),
215 Series("hirsute", "21.04", "Hirsute Hippo"),244 Series("hirsute", "21.04", "Hirsute Hippo"),
216 Series("impish", "21.10", "Impish Indri"),245 Series("impish", "21.10", "Impish Indri"),
217 Series(246 Series(
218 "jammy", "22.04", "Jammy Jellyfish",247 "jammy", "22.04", "Jammy Jellyfish",
219 all_lts_projects=True),248 all_lts_projects=True,
249 _core_series="22"),
220 Series("kinetic", "22.10", "Kinetic Kudu"),250 Series("kinetic", "22.10", "Kinetic Kudu"),
221251
222 Series("14.09", "14.09", "RTM 14.09", distribution="ubuntu-rtm"),252 Series("14.09", "14.09", "RTM 14.09", distribution="ubuntu-rtm"),
@@ -516,15 +546,7 @@
516546
517 @property547 @property
518 def core_series(self):548 def core_series(self):
519 if self["DIST"] >= "xenial" and self["DIST"] <= "artful":549 return self["DIST"].core_series
520 return '16'
521 if self["DIST"] >= "bionic" and self["DIST"] <= "eoan":
522 return '18'
523 if self["DIST"] == "focal":
524 return '20'
525 if self["DIST"] >= "groovy":
526 return '22'
527 return None
528550
529 def livefs_project_for_arch(self, arch):551 def livefs_project_for_arch(self, arch):
530 if arch not in self.livefs_arch_mapping:552 if arch not in self.livefs_arch_mapping:
531553
=== modified file 'lib/cdimage/tests/test_config.py'
--- lib/cdimage/tests/test_config.py 2022-02-14 19:13:02 +0000
+++ lib/cdimage/tests/test_config.py 2022-06-09 12:23:48 +0000
@@ -22,6 +22,11 @@
22import os22import os
23from textwrap import dedent23from textwrap import dedent
2424
25try:
26 from unittest import mock
27except ImportError:
28 import mock
29
25from cdimage.config import Config, Series, all_series30from cdimage.config import Config, Series, all_series
26from cdimage.tests.helpers import TestCase, mkfile31from cdimage.tests.helpers import TestCase, mkfile
2732
@@ -47,6 +52,34 @@
47 self.assertRaises(52 self.assertRaises(
48 ValueError, Series.latest, distribution="nonexistent")53 ValueError, Series.latest, distribution="nonexistent")
4954
55 def test_find_by_core_series(self):
56 series = Series.find_by_core_series("20")
57 self.assertEqual(("focal", "20.04", "Focal Fossa"), tuple(series))
58 self.assertRaises(
59 ValueError, Series.find_by_core_series, core_series="21")
60
61 def test_latest_core(self):
62 series = Series.latest_core()
63 self.assertEqual("ubuntu", series.distribution)
64 self.assertTrue(getattr(series, "_core_series"))
65
66 @mock.patch("lib.cdimage.config.all_series")
67 def test_core_series(self, all_series):
68 impish = Series("impish", "21.10", "Impish Indri")
69 jammy = Series(
70 "jammy", "22.04", "Jammy Jellyfish",
71 all_lts_projects=True,
72 _core_series="22")
73 kinetic = Series("kinetic", "22.10", "Kinetic Kudu")
74 all_series = [
75 impish,
76 jammy,
77 kinetic
78 ]
79 self.assertEqual("22", jammy.core_series)
80 self.assertEqual("24", kinetic.core_series)
81 self.assertEqual(None, impish.core_series)
82
50 def test_str(self):83 def test_str(self):
51 series = Series.find_by_name("warty")84 series = Series.find_by_name("warty")
52 self.assertEqual("warty", str(series))85 self.assertEqual("warty", str(series))
@@ -384,15 +417,9 @@
384 self.assertEqual("16", config.core_series)417 self.assertEqual("16", config.core_series)
385 config["DIST"] = "bionic"418 config["DIST"] = "bionic"
386 self.assertEqual("18", config.core_series)419 self.assertEqual("18", config.core_series)
387 config["DIST"] = "cosmic"
388 self.assertEqual("18", config.core_series)
389 config["DIST"] = "disco"
390 self.assertEqual("18", config.core_series)
391 config["DIST"] = "eoan"
392 self.assertEqual("18", config.core_series)
393 config["DIST"] = "focal"420 config["DIST"] = "focal"
394 self.assertEqual("20", config.core_series)421 self.assertEqual("20", config.core_series)
395 config["DIST"] = "hirsute"422 config["DIST"] = "jammy"
396 self.assertEqual("22", config.core_series)423 self.assertEqual("22", config.core_series)
397424
398 def test_arches(self):425 def test_arches(self):

Subscribers

People subscribed via source and target branches