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
1=== modified file 'bin/rebuild-requests'
2--- bin/rebuild-requests 2022-06-09 08:31:08 +0000
3+++ bin/rebuild-requests 2022-06-09 12:23:48 +0000
4@@ -201,6 +201,9 @@
5 # Due to the different structure, IMAGE_TYPE is the channel
6 # here
7 env['CHANNEL'] = entry[2]
8+ # And cdimage still uses distro series for the core series
9+ # builds
10+ env['DIST'] = Series.find_by_core_series(env['DIST']).name
11 image_type = "daily-live"
12
13 cmd = ["for-project", project, "cron.%s" % image_type]
14
15=== modified file 'lib/cdimage/config.py'
16--- lib/cdimage/config.py 2022-05-02 18:54:08 +0000
17+++ lib/cdimage/config.py 2022-06-09 12:23:48 +0000
18@@ -85,6 +85,21 @@
19 return series
20 raise ValueError("No series with distribution %s" % distribution)
21
22+ @classmethod
23+ def find_by_core_series(self, core_series):
24+ for series in all_series:
25+ if series.core_series == core_series:
26+ return series
27+ else:
28+ raise ValueError(
29+ "No Ubuntu Core series %s" % core_series)
30+
31+ @classmethod
32+ def latest_core(self):
33+ for series in reversed(all_series):
34+ if getattr(series, "_core_series", None):
35+ return series
36+
37 def __str__(self):
38 return self.name
39
40@@ -148,6 +163,17 @@
41 def realversion(self):
42 return getattr(self, "pointversion", self.version)
43
44+ @property
45+ def core_series(self):
46+ core_version = getattr(self, "_core_series", None)
47+ if not core_version and self.is_latest:
48+ # Automatically handle the devel series being 'XX+2', without
49+ # having to manually bump it everytime we prepare for the next
50+ # core series
51+ latest_core = Series.latest_core()
52+ core_version = str(int(latest_core.core_series) + 2)
53+ return core_version
54+
55
56 # TODO: This should probably come from a configuration file.
57 all_series.extend([
58@@ -194,14 +220,16 @@
59 Series(
60 "xenial", "16.04", "Xenial Xerus",
61 pointversion="16.04.7",
62- all_lts_projects=True),
63+ all_lts_projects=True,
64+ _core_series="16"),
65 Series("yakkety", "16.10", "Yakkety Yak"),
66 Series("zesty", "17.04", "Zesty Zapus"),
67 Series("artful", "17.10", "Artful Aardvark"),
68 Series(
69 "bionic", "18.04", "Bionic Beaver",
70 pointversion="18.04.6",
71- all_lts_projects=True),
72+ all_lts_projects=True,
73+ _core_series="18"),
74 Series("cosmic", "18.10", "Cosmic Cuttlefish"),
75 Series("disco", "19.04", "Disco Dingo"),
76 Series(
77@@ -210,13 +238,15 @@
78 Series(
79 "focal", "20.04", "Focal Fossa",
80 pointversion="20.04.4",
81- all_lts_projects=True),
82+ all_lts_projects=True,
83+ _core_series="20"),
84 Series("groovy", "20.10", "Groovy Gorilla"),
85 Series("hirsute", "21.04", "Hirsute Hippo"),
86 Series("impish", "21.10", "Impish Indri"),
87 Series(
88 "jammy", "22.04", "Jammy Jellyfish",
89- all_lts_projects=True),
90+ all_lts_projects=True,
91+ _core_series="22"),
92 Series("kinetic", "22.10", "Kinetic Kudu"),
93
94 Series("14.09", "14.09", "RTM 14.09", distribution="ubuntu-rtm"),
95@@ -516,15 +546,7 @@
96
97 @property
98 def core_series(self):
99- if self["DIST"] >= "xenial" and self["DIST"] <= "artful":
100- return '16'
101- if self["DIST"] >= "bionic" and self["DIST"] <= "eoan":
102- return '18'
103- if self["DIST"] == "focal":
104- return '20'
105- if self["DIST"] >= "groovy":
106- return '22'
107- return None
108+ return self["DIST"].core_series
109
110 def livefs_project_for_arch(self, arch):
111 if arch not in self.livefs_arch_mapping:
112
113=== modified file 'lib/cdimage/tests/test_config.py'
114--- lib/cdimage/tests/test_config.py 2022-02-14 19:13:02 +0000
115+++ lib/cdimage/tests/test_config.py 2022-06-09 12:23:48 +0000
116@@ -22,6 +22,11 @@
117 import os
118 from textwrap import dedent
119
120+try:
121+ from unittest import mock
122+except ImportError:
123+ import mock
124+
125 from cdimage.config import Config, Series, all_series
126 from cdimage.tests.helpers import TestCase, mkfile
127
128@@ -47,6 +52,34 @@
129 self.assertRaises(
130 ValueError, Series.latest, distribution="nonexistent")
131
132+ def test_find_by_core_series(self):
133+ series = Series.find_by_core_series("20")
134+ self.assertEqual(("focal", "20.04", "Focal Fossa"), tuple(series))
135+ self.assertRaises(
136+ ValueError, Series.find_by_core_series, core_series="21")
137+
138+ def test_latest_core(self):
139+ series = Series.latest_core()
140+ self.assertEqual("ubuntu", series.distribution)
141+ self.assertTrue(getattr(series, "_core_series"))
142+
143+ @mock.patch("lib.cdimage.config.all_series")
144+ def test_core_series(self, all_series):
145+ impish = Series("impish", "21.10", "Impish Indri")
146+ jammy = Series(
147+ "jammy", "22.04", "Jammy Jellyfish",
148+ all_lts_projects=True,
149+ _core_series="22")
150+ kinetic = Series("kinetic", "22.10", "Kinetic Kudu")
151+ all_series = [
152+ impish,
153+ jammy,
154+ kinetic
155+ ]
156+ self.assertEqual("22", jammy.core_series)
157+ self.assertEqual("24", kinetic.core_series)
158+ self.assertEqual(None, impish.core_series)
159+
160 def test_str(self):
161 series = Series.find_by_name("warty")
162 self.assertEqual("warty", str(series))
163@@ -384,15 +417,9 @@
164 self.assertEqual("16", config.core_series)
165 config["DIST"] = "bionic"
166 self.assertEqual("18", config.core_series)
167- config["DIST"] = "cosmic"
168- self.assertEqual("18", config.core_series)
169- config["DIST"] = "disco"
170- self.assertEqual("18", config.core_series)
171- config["DIST"] = "eoan"
172- self.assertEqual("18", config.core_series)
173 config["DIST"] = "focal"
174 self.assertEqual("20", config.core_series)
175- config["DIST"] = "hirsute"
176+ config["DIST"] = "jammy"
177 self.assertEqual("22", config.core_series)
178
179 def test_arches(self):

Subscribers

People subscribed via source and target branches