Merge ~ltrager/maas:lp1927657 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 804938e78180d8b2dfaff13bb123c6376dd4525c
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1927657
Merge into: maas:master
Diff against target: 48 lines (+7/-7)
2 files modified
src/maasserver/models/node.py (+5/-5)
src/maasserver/models/tests/test_node.py (+2/-2)
Reviewer Review Type Date Requested Status
MAAS Lander Needs Fixing
Alberto Donato (community) Approve
Review via email: mp+402518@code.launchpad.net

Commit message

LP: #1927657 - Always include the default kernel command line options

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

UNIT TESTS
-b lp1927657 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/10026/console
COMMIT: fd34ce29a2f4bea9b7bb5d176c76df907428284f

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1927657 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 72cda3925c38e338072361613eb9242eb1d63c7d

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

The current behavior was a deliberate change (see 7278a2491efb980181bb6a48f44faa87054385db).

Before that change, if you had a machine tagged with multiple tags with kernel cmdline, the first one alphabetically was chosen.
This wasn't very usable, as it didn't allow to combine tags in a usable way.

With the current behavior, all tags are collected (so you can have for tags for different purposes, e.g. serial console, configure hugepages, ...).
Since we now combine them, the global default is much less useful (it's mainly useful if you want parameters to be applied during enlistment), as it's easy to add an extra tag for what you need and set it on the machines you need.

review: Needs Information
Revision history for this message
Lee Trager (ltrager) wrote :

It was an improvement to include kernel options for all tags but it still leaves out the global kernel command line option. This includes everything. The global kernel command line options are defined first. This allows tags to override the kernel command line option as the kernel uses the last definition.

I've verified this by setting my kernel command line to the following and still having the system boot properly
BOOT_IMAGE=/boot/vmlinuz-5.4.0-73-generic root=/dev/null root=/dev/mapper/vg0-lv0 ro

I ran into this bug while testing UEFI SecureBoot with an LXD VM. I needed to add "earlyprintk=efi" to the kernel command line to gather additional debug information. The UI has no way to add a tag with a kernel option, the only way to do a kernel option in the UI is to add a global kernel command line option. The UI states "Boot parameters to pass to the kernel by default" which led me to believe it would always be added. When I deployed Ubuntu on an LXD VM my kernel command line option wasn't added. This was because MAAS automatically tags LXD VMs with "pod-console-logging" which contains a kernel command line option and any tag with a kernel option overrides the global default.

I feel this is safe to land because users can always override the global kernel command line option with a tag. It also makes it much clearer to always add all options instead of sometimes adding the global option and sometimes not.

Revision history for this message
Alberto Donato (ack) wrote :

Sounds good, +1

I think we should change the term "default" in the UI/doc with "global", to make it clear they're always applied, and also perhaps clarify the logic in the doc about how is the command line composed.

A small nit inline

review: Approve
Revision history for this message
Lee Trager (ltrager) wrote :

Thanks for the review. I've filed LP:1928253 to fix the wording in the UI

Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1927657 lp:~ltrager/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/10059/console
COMMIT: 804938e78180d8b2dfaff13bb123c6376dd4525c

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/models/node.py b/src/maasserver/models/node.py
2index a1feb04..0fda60b 100644
3--- a/src/maasserver/models/node.py
4+++ b/src/maasserver/models/node.py
5@@ -3008,16 +3008,16 @@ class Node(CleanSave, TimestampedModel):
6 raise UnknownPowerType("Node power type is unconfigured")
7 return self.bmc.power_type
8
9- def get_effective_kernel_options(self, default_kernel_opts=""):
10+ def get_effective_kernel_options(self, default_kernel_opts=None):
11 """Return a string with kernel commandline."""
12- options = (
13+ options = list(
14 self.tags.exclude(kernel_opts="")
15 .order_by("name")
16 .values_list("kernel_opts", flat=True)
17 )
18- if options:
19- return " ".join(options)
20- return default_kernel_opts or ""
21+ if default_kernel_opts:
22+ options.insert(0, default_kernel_opts)
23+ return " ".join(options)
24
25 def get_osystem(self, default=undefined):
26 """Return the operating system to install that node."""
27diff --git a/src/maasserver/models/tests/test_node.py b/src/maasserver/models/tests/test_node.py
28index 605b238..669eeb4 100644
29--- a/src/maasserver/models/tests/test_node.py
30+++ b/src/maasserver/models/tests/test_node.py
31@@ -2040,7 +2040,7 @@ class TestNode(MAASServerTestCase):
32 node.tags.add(tag)
33 self.assertEqual(node.get_effective_kernel_options(), tag.kernel_opts)
34
35- def test_get_effective_kernel_options_tag_overrides_default(self):
36+ def test_get_effective_kernel_options_tag_includes_default(self):
37 node = factory.make_Node()
38 default_opts = factory.make_string()
39 tag = factory.make_Tag(kernel_opts=factory.make_string())
40@@ -2049,7 +2049,7 @@ class TestNode(MAASServerTestCase):
41 node.get_effective_kernel_options(
42 default_kernel_opts=default_opts
43 ),
44- tag.kernel_opts,
45+ f"{default_opts} {tag.kernel_opts}",
46 )
47
48 def test_acquire(self):

Subscribers

People subscribed via source and target branches