Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEM: ensure only one kernel gets installed #1703

Merged
merged 4 commits into from Jul 4, 2023

Conversation

ogayot
Copy link
Member

@ogayot ogayot commented Jun 29, 2023

Some more testing is needed but it looks mostly ok.

Depends: #1702

Copy link
Collaborator

@dbungert dbungert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minus the bit already raised on the other PR.

# If we already have the needed kernel installed, don't bother
# requesting curthooks to install it or we might end up with two
# kernels.
for pkg in await list_installed_kernels(Path(self.tpath())):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what scenario could len(list_installed_kernels) > 1 be true? (not rejecting the for loop, just curious.) Is that indicative of a image construction bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would only happen on broken or half broken scenarios, like:

  • two suggested OEM meta-packages pulling two different kernel flavors (for now there should be only one meta-package per hardware model - in theory)
  • one kernel in the squashfs (don't think we'll ever do that) and the OEM metapkg pulling another flavor

# kernels.
for pkg in await list_installed_kernels(Path(self.tpath())):
if pkg == self.model.kernel.needed_kernel:
self.model.kernel.curthooks_no_install
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um I think this line is incomplete :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch! Thanks for noticing!


async def list_installed_kernels(
rootfs: pathlib.Path,
*, grep_status: str = "grep-status") -> List[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument is unused.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit I expected you to fix this by removing the argument :-) What is the use case for passing a different value here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It felt like it could be a way to substitute a command by another when doing dry-runs - as in
list_installed_kernels(..., grep_status='scripts/replay-grep-status') or something.

But it's not really usable as is - so I guess it should go.

@@ -110,6 +110,7 @@ parts:
# This list includes the dependencies for curtin and probert as well,
# there doesn't seem to be any real benefit to listing them separately.
- cloud-init
- dctrl-tools
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could just stage /usr/bin/grep-dctrl but the whole package is fairly tiny.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - and no Depends so I guess I'll keep the whole package.

# requesting curthooks to install it or we might end up with two
# kernels.
for pkg in await list_installed_kernels(Path(self.tpath())):
if pkg == self.model.kernel.needed_kernel:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all a bit confusing but I don't think we should check this, for two reasons. One is that pkg here will be something like "linux-image-6.2.0-23-generic" or "linux-image-6.1.0-1012-oem" and I think needed_kernel is going to be a metapackage name like "linux-oem-22.04" or "linux" and the other is that even if we think we want "linux-oem-22.04" installing the metapackage might actually install "linux-oem-22.04d" or something.

Basically IMO we should instruct curtin to not install a kernel iff there is any kernel installed already. Luckily this makes the code simpler :-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how things should interact if the autoinstall explicitly requests a different flavour though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you're right. Dan was suggesting a runtime error if there's an explicit kernel flavor + an OEM meta-package. I think it is a sensible approach.

@ogayot ogayot force-pushed the install-oem-ensure-one-kernel branch 2 times, most recently from 64a0c2a to 10b5714 Compare June 30, 2023 10:46
@ogayot ogayot force-pushed the install-oem-kernel-selection branch from c222ea4 to 3088926 Compare June 30, 2023 16:24
@ogayot ogayot force-pushed the install-oem-ensure-one-kernel branch 2 times, most recently from 364eb1c to 537e6a8 Compare June 30, 2023 18:37
@ogayot ogayot force-pushed the install-oem-kernel-selection branch from 4352ec9 to c98afd4 Compare June 30, 2023 18:38
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
By default, OEM meta-packages get installed on ubuntu-desktop and don't
get installed on ubuntu-server. Using autoinstall, we can now give more
control. The autoinstall section supports the following:

Install on server and desktop:

  oem:
    install: true

Do not install even on desktop:

  oem:
    install: false

Install only on desktop (the default):

  oem:
    install: auto

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot force-pushed the install-oem-ensure-one-kernel branch from 537e6a8 to 817ad85 Compare June 30, 2023 18:53
@ogayot ogayot changed the base branch from install-oem-kernel-selection to main June 30, 2023 18:54
@ogayot ogayot requested a review from mwhudson June 30, 2023 18:55
Copy link
Collaborator

@mwhudson mwhudson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is good stuff. I still have a couple of comments but they are very much at the nitpicking level now.

# needed manually. Ideally, we would not hardcode
# var/lib/dpkg/status because it is an implementation detail.
status = Path("var/lib/dpkg/status")
(Path(root) / status).parent.mkdir(parents=True, exist_ok=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nitpicky to the max but a) root is already a Path here b) Path / str works fine? so you can leave status as a string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, updated :)


async def list_installed_kernels(
rootfs: pathlib.Path,
*, grep_status: str = "grep-status") -> List[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I admit I expected you to fix this by removing the argument :-) What is the use case for passing a different value here?

Before running curthooks, we now look in the target if there is an
installed kernel. If there is, we instruct curtin _not_ to install
another one.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
@ogayot ogayot force-pushed the install-oem-ensure-one-kernel branch from 817ad85 to 6424c3c Compare July 3, 2023 08:00
@ogayot
Copy link
Member Author

ogayot commented Jul 3, 2023

I admit I expected you to fix this by removing the argument :-) What is the use case for passing a different value here?

It felt like it could be a way to substitute a command by another when doing dry-runs - as in

list_installed_kernels(..., grep_status='scripts/replay-grep-status')

or something.

But it's not really usable as is - so I guess it should go (and is now gone)

@ogayot ogayot merged commit 54465d1 into canonical:main Jul 4, 2023
9 checks passed
@ogayot ogayot deleted the install-oem-ensure-one-kernel branch July 4, 2023 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants