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
Conversation
There was a problem hiding this 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())): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch! Thanks for noticing!
subiquity/server/kernel.py
Outdated
|
||
async def list_installed_kernels( | ||
rootfs: pathlib.Path, | ||
*, grep_status: str = "grep-status") -> List[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops!
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
64a0c2a
to
10b5714
Compare
c222ea4
to
3088926
Compare
364eb1c
to
537e6a8
Compare
4352ec9
to
c98afd4
Compare
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>
537e6a8
to
817ad85
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, updated :)
subiquity/server/kernel.py
Outdated
|
||
async def list_installed_kernels( | ||
rootfs: pathlib.Path, | ||
*, grep_status: str = "grep-status") -> List[str]: |
There was a problem hiding this comment.
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>
817ad85
to
6424c3c
Compare
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) |
Some more testing is needed but it looks mostly ok.
Depends: #1702