Merge ~alexsander-souza/maas:lp1914812_to_3_4 into maas:3.4

Proposed by Alexsander de Souza
Status: Merged
Approved by: Alexsander de Souza
Approved revision: 820b74b82723396e8d58c4ec6bbc8994df263194
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~alexsander-souza/maas:lp1914812_to_3_4
Merge into: maas:3.4
Diff against target: 340 lines (+129/-10)
6 files modified
src/maasserver/rpc/boot.py (+26/-4)
src/maasserver/rpc/tests/test_boot.py (+81/-6)
src/maasserver/rpc/tests/test_regionservice_calls.py (+1/-0)
src/provisioningserver/kernel_opts.py (+3/-0)
src/provisioningserver/rpc/region.py (+1/-0)
src/provisioningserver/tests/test_kernel_opts.py (+17/-0)
Reviewer Review Type Date Requested Status
Alexsander de Souza Approve
MAAS Lander Approve
Review via email: mp+449763@code.launchpad.net

Commit message

add support to quirks in the ephemeral kernel during xinstall

Some older OSes (like Centos/7) require that we tune the ephemeral OS kernel to match the capabilities of the one being deployed.

(cherry picked from commit 52f344ab28c0e615dcefc134922191fb6b944a9c)

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1914812_to_3_4 lp:~alexsander-souza/maas/+git/maas into -b 3.4 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 820b74b82723396e8d58c4ec6bbc8994df263194

review: Approve
Revision history for this message
Alexsander de Souza (alexsander-souza) wrote :

self-approve back-port

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/rpc/boot.py b/src/maasserver/rpc/boot.py
index c850aa7..931a7e0 100644
--- a/src/maasserver/rpc/boot.py
+++ b/src/maasserver/rpc/boot.py
@@ -223,11 +223,13 @@ def get_boot_config_for_machine(machine, configs, purpose):
223 # LP:2013529, machine HWE kernel might not exist for223 # LP:2013529, machine HWE kernel might not exist for
224 # commissioning osystem/series224 # commissioning osystem/series
225 use_machine_hwe_kernel = False225 use_machine_hwe_kernel = False
226 final_osystem, final_series = osystem, series
226 else:227 else:
227 osystem = machine.get_osystem(default=configs["default_osystem"])228 osystem = machine.get_osystem(default=configs["default_osystem"])
228 series = machine.get_distro_series(229 series = machine.get_distro_series(
229 default=configs["default_distro_series"]230 default=configs["default_distro_series"]
230 )231 )
232 final_osystem, final_series = osystem, series
231 # XXX: roaksoax LP: #1739761 - Since the switch to squashfs (and233 # XXX: roaksoax LP: #1739761 - Since the switch to squashfs (and
232 # drop of iscsi), precise is no longer deployable. To address a234 # drop of iscsi), precise is no longer deployable. To address a
233 # squashfs image is made available allowing it to be deployed in235 # squashfs image is made available allowing it to be deployed in
@@ -317,7 +319,7 @@ def get_boot_config_for_machine(machine, configs, purpose):
317 else:319 else:
318 subarch = "no-such-kernel"320 subarch = "no-such-kernel"
319321
320 return osystem, series, subarch322 return osystem, series, subarch, final_osystem, final_series
321323
322324
323def get_base_url_for_local_ip(local_ip, internal_domain):325def get_base_url_for_local_ip(local_ip, internal_domain):
@@ -352,6 +354,15 @@ def get_final_boot_purpose(machine, arch, purpose):
352 return purpose354 return purpose
353355
354356
357def get_quirks_kernel_opts(
358 final_osystem: str, final_series: str
359) -> str | None:
360 if final_osystem == "centos":
361 return "nvme-core.multipath=0"
362
363 return None
364
365
355@synchronous366@synchronous
356@transactional367@transactional
357def get_config(368def get_config(
@@ -418,6 +429,7 @@ def get_config(
418 if log_port is None:429 if log_port is None:
419 log_port = 514 # Fallback to default UDP syslog port.430 log_port = 514 # Fallback to default UDP syslog port.
420431
432 ephemeral_opts: str | None = None
421 # XXX: Instead of updating the machine directly, we should store the433 # XXX: Instead of updating the machine directly, we should store the
422 # information and update the machine later. The current code doesn't434 # information and update the machine later. The current code doesn't
423 # work when you first boot a machine that has IPMI configured, since435 # work when you first boot a machine that has IPMI configured, since
@@ -542,6 +554,7 @@ def get_config(
542 "log_port": log_port,554 "log_port": log_port,
543 "extra_opts": "",555 "extra_opts": "",
544 "http_boot": True,556 "http_boot": True,
557 "ephemeral_opts": ephemeral_opts or "",
545 }558 }
546559
547 # Log the request into the event log for that machine.560 # Log the request into the event log for that machine.
@@ -554,9 +567,13 @@ def get_config(
554 else:567 else:
555 event_log_pxe_request(machine, purpose)568 event_log_pxe_request(machine, purpose)
556569
557 osystem, series, subarch = get_boot_config_for_machine(570 (
558 machine, configs, purpose571 osystem,
559 )572 series,
573 subarch,
574 final_osystem,
575 final_series,
576 ) = get_boot_config_for_machine(machine, configs, purpose)
560577
561 extra_kernel_opts = machine.get_effective_kernel_options(578 extra_kernel_opts = machine.get_effective_kernel_options(
562 default_kernel_opts=configs["kernel_opts"]579 default_kernel_opts=configs["kernel_opts"]
@@ -580,6 +597,10 @@ def get_config(
580 extra_kernel_opts = merge_kparams_with_extra(597 extra_kernel_opts = merge_kparams_with_extra(
581 kparams, extra_kernel_opts598 kparams, extra_kernel_opts
582 )599 )
600 if final_osystem != "ubuntu":
601 ephemeral_opts = get_quirks_kernel_opts(
602 final_osystem, final_series
603 )
583 else:604 else:
584 purpose = "commissioning" # enlistment605 purpose = "commissioning" # enlistment
585 if configs["use_rack_proxy"]:606 if configs["use_rack_proxy"]:
@@ -665,6 +686,7 @@ def get_config(
665 # As of MAAS 2.4 only HTTP boot is supported. This ensures MAAS 2.3686 # As of MAAS 2.4 only HTTP boot is supported. This ensures MAAS 2.3
666 # rack controllers use HTTP boot as well.687 # rack controllers use HTTP boot as well.
667 "http_boot": True,688 "http_boot": True,
689 "ephemeral_opts": ephemeral_opts or "",
668 }690 }
669 if machine is not None:691 if machine is not None:
670 params["system_id"] = machine.system_id692 params["system_id"] = machine.system_id
diff --git a/src/maasserver/rpc/tests/test_boot.py b/src/maasserver/rpc/tests/test_boot.py
index 9e1f972..6928a67 100644
--- a/src/maasserver/rpc/tests/test_boot.py
+++ b/src/maasserver/rpc/tests/test_boot.py
@@ -235,6 +235,7 @@ class TestGetConfig(MAASServerTestCase):
235 "log_port": 5247,235 "log_port": 5247,
236 "extra_opts": "",236 "extra_opts": "",
237 "http_boot": True,237 "http_boot": True,
238 "ephemeral_opts": "",
238 },239 },
239 config,240 config,
240 )241 )
@@ -280,6 +281,7 @@ class TestGetConfig(MAASServerTestCase):
280 "log_port": syslog_port,281 "log_port": syslog_port,
281 "extra_opts": "",282 "extra_opts": "",
282 "http_boot": True,283 "http_boot": True,
284 "ephemeral_opts": "",
283 },285 },
284 config,286 config,
285 )287 )
@@ -324,6 +326,7 @@ class TestGetConfig(MAASServerTestCase):
324 "log_port": 5247,326 "log_port": 5247,
325 "extra_opts": "",327 "extra_opts": "",
326 "http_boot": True,328 "http_boot": True,
329 "ephemeral_opts": "",
327 },330 },
328 config,331 config,
329 )332 )
@@ -1356,6 +1359,7 @@ class TestGetConfig(MAASServerTestCase):
1356 rack_controller.system_id, local_ip, remote_ip, mac=mac1359 rack_controller.system_id, local_ip, remote_ip, mac=mac
1357 )1360 )
1358 self.assertEqual(distro_series, observed_config["release"])1361 self.assertEqual(distro_series, observed_config["release"])
1362 self.assertEqual("", observed_config["ephemeral_opts"])
13591363
1360 def test_returns_base_image_for_custom_ubuntu_image_xinstall(self):1364 def test_returns_base_image_for_custom_ubuntu_image_xinstall(self):
1361 self.patch(boot_module, "get_boot_filenames").return_value = (1365 self.patch(boot_module, "get_boot_filenames").return_value = (
@@ -1390,6 +1394,32 @@ class TestGetConfig(MAASServerTestCase):
1390 expected_osystem, expected_series = custom_image.base_image.split("/")1394 expected_osystem, expected_series = custom_image.base_image.split("/")
1391 self.assertEqual(expected_osystem, observed_config["osystem"])1395 self.assertEqual(expected_osystem, observed_config["osystem"])
1392 self.assertEqual(expected_series, observed_config["release"])1396 self.assertEqual(expected_series, observed_config["release"])
1397 self.assertEqual("", observed_config["ephemeral_opts"])
1398
1399 def test_returns_quirks_for_centos_image_xinstall(self):
1400 osystem = Config.objects.get_config("default_osystem")
1401 release = Config.objects.get_config("default_distro_series")
1402 rack_controller = factory.make_RackController()
1403 local_ip = factory.make_ip_address()
1404 remote_ip = factory.make_ip_address()
1405 self.make_node(arch_name="amd64")
1406 node = factory.make_Node_with_Interface_on_Subnet(
1407 status=NODE_STATUS.DEPLOYING,
1408 osystem="centos",
1409 distro_series="centos71",
1410 architecture="amd64/generic",
1411 primary_rack=rack_controller,
1412 )
1413 mac = node.get_boot_interface().mac_address
1414 self.patch_autospec(boot_module, "event_log_pxe_request")
1415 observed_config = get_config(
1416 rack_controller.system_id, local_ip, remote_ip, mac=mac
1417 )
1418 self.assertEqual(osystem, observed_config["osystem"])
1419 self.assertEqual(release, observed_config["release"])
1420 self.assertEqual(
1421 "nvme-core.multipath=0", observed_config["ephemeral_opts"]
1422 )
13931423
1394 # XXX: roaksoax LP: #1739761 - Deploying precise is now done using1424 # XXX: roaksoax LP: #1739761 - Deploying precise is now done using
1395 # the commissioning ephemeral environment.1425 # the commissioning ephemeral environment.
@@ -1593,7 +1623,7 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1593 ]1623 ]
1594 )1624 )
15951625
1596 osystem, series, config_arch = get_boot_config_for_machine(1626 osystem, series, config_arch, _, _ = get_boot_config_for_machine(
1597 machine, configs, "xinstall"1627 machine, configs, "xinstall"
1598 )1628 )
15991629
@@ -1634,7 +1664,7 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1634 ]1664 ]
1635 )1665 )
16361666
1637 osystem, series, config_arch = get_boot_config_for_machine(1667 osystem, series, config_arch, _, _ = get_boot_config_for_machine(
1638 machine, configs, "xinstall"1668 machine, configs, "xinstall"
1639 )1669 )
16401670
@@ -1672,7 +1702,7 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1672 ]1702 ]
1673 )1703 )
16741704
1675 osystem, series, config_arch = get_boot_config_for_machine(1705 osystem, series, config_arch, _, _ = get_boot_config_for_machine(
1676 machine, configs, "xinstall"1706 machine, configs, "xinstall"
1677 )1707 )
16781708
@@ -1737,7 +1767,7 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1737 architecture=f"amd64/{legacy_subarch}",1767 architecture=f"amd64/{legacy_subarch}",
1738 )1768 )
17391769
1740 osystem, series, config_arch = get_boot_config_for_machine(1770 osystem, series, config_arch, _, _ = get_boot_config_for_machine(
1741 modern_machine, configs, "xinstall"1771 modern_machine, configs, "xinstall"
1742 )1772 )
1743 self.assertEqual("ubuntu", osystem)1773 self.assertEqual("ubuntu", osystem)
@@ -1745,7 +1775,7 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1745 self.assertEqual(subarch, config_arch)1775 self.assertEqual(subarch, config_arch)
1746 self.assertNotEqual(machine_hwe_kernel, config_arch)1776 self.assertNotEqual(machine_hwe_kernel, config_arch)
17471777
1748 osystem, series, config_arch = get_boot_config_for_machine(1778 osystem, series, config_arch, _, _ = get_boot_config_for_machine(
1749 legacy_machine, configs, "xinstall"1779 legacy_machine, configs, "xinstall"
1750 )1780 )
1751 self.assertEqual("ubuntu", osystem)1781 self.assertEqual("ubuntu", osystem)
@@ -1796,7 +1826,7 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1796 architecture=f"amd64/{legacy_subarch}",1826 architecture=f"amd64/{legacy_subarch}",
1797 )1827 )
17981828
1799 osystem, series, config_arch = get_boot_config_for_machine(1829 osystem, series, config_arch, _, _ = get_boot_config_for_machine(
1800 machine, configs, "commissioning"1830 machine, configs, "commissioning"
1801 )1831 )
1802 self.assertEqual(configs["commissioning_osystem"], osystem)1832 self.assertEqual(configs["commissioning_osystem"], osystem)
@@ -1804,6 +1834,51 @@ class TestGetBootConfigForMachine(MAASServerTestCase):
1804 self.assertEqual(legacy_subarch, config_arch)1834 self.assertEqual(legacy_subarch, config_arch)
1805 self.assertNotEqual(machine_hwe_kernel, config_arch)1835 self.assertNotEqual(machine_hwe_kernel, config_arch)
18061836
1837 def test_get_boot_config_for_machine_centos(self):
1838 subarch = "ga-20.04"
1839 # We need a base image to be present. In fact, we always
1840 # needed that for the new image to boot.
1841 factory.make_default_ubuntu_release_bootable(arch=f"amd64/{subarch}")
1842 factory.make_usable_boot_resource(
1843 name="centos/7",
1844 architecture="amd64/generic",
1845 )
1846 machine = factory.make_Machine(
1847 architecture="amd64/generic",
1848 status=NODE_STATUS.DEPLOYING,
1849 osystem="centos",
1850 distro_series="7",
1851 )
1852 configs = Config.objects.get_configs(
1853 [
1854 "commissioning_osystem",
1855 "commissioning_distro_series",
1856 "enable_third_party_drivers",
1857 "default_min_hwe_kernel",
1858 "default_osystem",
1859 "default_distro_series",
1860 "kernel_opts",
1861 "use_rack_proxy",
1862 "maas_internal_domain",
1863 "remote_syslog",
1864 "maas_syslog_port",
1865 ]
1866 )
1867
1868 (
1869 osystem,
1870 series,
1871 config_arch,
1872 final_osystem,
1873 final_series,
1874 ) = get_boot_config_for_machine(machine, configs, "xinstall")
1875
1876 self.assertEqual(configs["commissioning_osystem"], osystem)
1877 self.assertEqual(configs["commissioning_distro_series"], series)
1878 self.assertEqual(subarch, config_arch)
1879 self.assertEqual("centos", final_osystem)
1880 self.assertEqual("7", final_series)
1881
18071882
1808class TestGetNodeFromMacOrHardwareUUID(MAASServerTestCase):1883class TestGetNodeFromMacOrHardwareUUID(MAASServerTestCase):
1809 def test_get_node_from_mac_or_hardware_uuid_with_regular_mac(self):1884 def test_get_node_from_mac_or_hardware_uuid_with_regular_mac(self):
diff --git a/src/maasserver/rpc/tests/test_regionservice_calls.py b/src/maasserver/rpc/tests/test_regionservice_calls.py
index dbc756a..5a22f1b 100644
--- a/src/maasserver/rpc/tests/test_regionservice_calls.py
+++ b/src/maasserver/rpc/tests/test_regionservice_calls.py
@@ -371,6 +371,7 @@ class TestRegionProtocol_GetBootConfig(MAASTransactionServerTestCase):
371 "fs_host",371 "fs_host",
372 "log_host",372 "log_host",
373 "extra_opts",373 "extra_opts",
374 "ephemeral_opts",
374 ]375 ]
375 ),376 ),
376 )377 )
diff --git a/src/provisioningserver/kernel_opts.py b/src/provisioningserver/kernel_opts.py
index b0da4a0..56f3add 100644
--- a/src/provisioningserver/kernel_opts.py
+++ b/src/provisioningserver/kernel_opts.py
@@ -44,6 +44,7 @@ KernelParametersBase = namedtuple(
44 # verbatim to the kernel command line44 # verbatim to the kernel command line
45 "http_boot", # Used to make sure a MAAS 2.3 rack controller uses45 "http_boot", # Used to make sure a MAAS 2.3 rack controller uses
46 # http_boot.46 # http_boot.
47 "ephemeral_opts", # Same as 'extra_opts' but used only in the ephemeral OS
47 ),48 ),
48)49)
4950
@@ -162,6 +163,8 @@ def compose_kernel_command_line(params):
162 # as it would be nice to have.163 # as it would be nice to have.
163 options += compose_logging_opts(params)164 options += compose_logging_opts(params)
164 options += compose_arch_opts(params)165 options += compose_arch_opts(params)
166 if params.ephemeral_opts:
167 options.append(params.ephemeral_opts)
165 cmdline_sep = get_curtin_kernel_cmdline_sep()168 cmdline_sep = get_curtin_kernel_cmdline_sep()
166 if params.extra_opts:169 if params.extra_opts:
167 # Using --- before extra opts makes both d-i and Curtin install170 # Using --- before extra opts makes both d-i and Curtin install
diff --git a/src/provisioningserver/rpc/region.py b/src/provisioningserver/rpc/region.py
index 6c8ba93..779949b 100644
--- a/src/provisioningserver/rpc/region.py
+++ b/src/provisioningserver/rpc/region.py
@@ -154,6 +154,7 @@ class GetBootConfig(amp.Command):
154 # will try to use TGT as Twisted sets optional parameters to False when154 # will try to use TGT as Twisted sets optional parameters to False when
155 # not defined.155 # not defined.
156 (b"http_boot", amp.Boolean(optional=True)),156 (b"http_boot", amp.Boolean(optional=True)),
157 (b"ephemeral_opts", amp.Unicode(optional=True)),
157 ]158 ]
158 errors = {BootConfigNoResponse: b"BootConfigNoResponse"}159 errors = {BootConfigNoResponse: b"BootConfigNoResponse"}
159160
diff --git a/src/provisioningserver/tests/test_kernel_opts.py b/src/provisioningserver/tests/test_kernel_opts.py
index 396aa4e..7e62449 100644
--- a/src/provisioningserver/tests/test_kernel_opts.py
+++ b/src/provisioningserver/tests/test_kernel_opts.py
@@ -467,3 +467,20 @@ class TestKernelOpts(MAASTestCase):
467 ]467 ]
468 ),468 ),
469 )469 )
470
471 def test_xinstall_compose_kernel_command_line_ephemeral_opts(self):
472 # ephemeral opts MUST appear before the separator
473 mock_get_curtin_sep = self.patch(
474 kernel_opts, "get_curtin_kernel_cmdline_sep"
475 )
476 sep = factory.make_name("sep")
477 mock_get_curtin_sep.return_value = sep
478
479 ephem_opt = "EPHEMERAL_OPT=1"
480 params = self.make_kernel_parameters(
481 purpose="xinstall",
482 ephemeral_opts=ephem_opt,
483 )
484 cmdline = compose_kernel_command_line(params)
485 self.assertIn(ephem_opt, cmdline)
486 self.assertTrue(cmdline.find(sep) > cmdline.find(ephem_opt))

Subscribers

People subscribed via source and target branches