linux-purge assumes current kernel needs to be installed in Docker container

Bug #1949504 reported by Julio Lajara
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux-purge
Fix Released
Undecided
Jarno Suni

Bug Description

I am unable to run linux-purge inside a Docker container because it assumes that the currently running kernel should always be installed and properly configured which is not a valid assumption when running Ubuntu inside a Docker containrer. When run in a Docker container, its using the kernel of the host, therefore your host could be Ubuntu 20.04 and the container could be running Ubuntu 16.04. Therefore, trying to use the --fix option is not a valid solution in this case which is what it suggests when exits with an error because 16.04 wont have access to the 20.04 kernel packages in the default upstream repos.

Revision history for this message
Julio Lajara (ju2wheels) wrote :

 The situation occurs when using automation testing around linux-purge using containers, its not something likely to be valid in a case outside of using containers, which is why you have the check there.

Revision history for this message
Jarno Suni (jarnos) wrote :

Oh, I am not familiar with containers. Can you check somehow from command line whether you are going to operate on kernels in a container or in a host?

Revision history for this message
Julio Lajara (ju2wheels) wrote : Re: [Bug 1949504] Re: linux-purge assumes current kernel needs to be installed in Docker container

Im not sure of a generalized way where this would work both in Docker
or LXC which im assuming would also hit this issue. It may just be
easier to add a flag to disable this check to enforce the current
running kernel be installed rather than force dependency on a tool to
determine this that may not be installed and leave it up to the end
user to set the CLI flag when using linux-purge inside a container.

A lot of the online recommendations for how to check if you are
running in a container are not things I would ever put into a prod
tool, are container engine specific, or not guaranteed to work.

On Tue, Nov 2, 2021 at 3:45 PM Jarno Suni <email address hidden> wrote:
>
> Oh, I am not familiar with containers. Can you check somehow from
> command line whether you are going to operate on kernels in a container
> or in a host?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1949504
>
> Title:
> linux-purge assumes current kernel needs to be installed in Docker
> container
>
> Status in linux-purge:
> New
>
> Bug description:
> I am unable to run linux-purge inside a Docker container because it
> assumes that the currently running kernel should always be installed
> and properly configured which is not a valid assumption when running
> Ubuntu inside a Docker containrer. When run in a Docker container, its
> using the kernel of the host, therefore your host could be Ubuntu
> 20.04 and the container could be running Ubuntu 16.04. Therefore,
> trying to use the --fix option is not a valid solution in this case
> which is what it suggests when exits with an error because 16.04 wont
> have access to the 20.04 kernel packages in the default upstream
> repos.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux-purge/+bug/1949504/+subscriptions
>

Revision history for this message
Jarno Suni (jarnos) wrote :

I installed Docker. Can you give me instructions on how to reproduce the bug?

Jarno Suni (jarnos)
Changed in linux-purge:
status: New → Incomplete
Revision history for this message
Julio Lajara (ju2wheels) wrote :

Im using Ubuntu 18.04:

start docker container (This is just my own container with Ansible
preinstalled on top of Ubuntu 18.04 Docker image):

```
docker run -it ju2wheels/ansible-base:2.10.x-ubuntu-18.04
```

Get linux-purge, install some linux kernels so theres something there
to actually test removal, and then run linux purge:

```
apt-get update
apt-get install git linux-image-generic
git clone https://git.launchpad.net/linux-purge /opt/linux-purge
/opt/linux-purge/linux-purge --clear-boot --keep 0 --yes
```
It may need to have more CLI command dependencies explicitly installed
in the container but I havent gotten past the error its giving.

On Tue, Nov 2, 2021 at 5:45 PM Jarno Suni <email address hidden> wrote:
>
> I installed Docker. Can you give me instructions on how to reproduce the
> bug?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1949504
>
> Title:
> linux-purge assumes current kernel needs to be installed in Docker
> container
>
> Status in linux-purge:
> New
>
> Bug description:
> I am unable to run linux-purge inside a Docker container because it
> assumes that the currently running kernel should always be installed
> and properly configured which is not a valid assumption when running
> Ubuntu inside a Docker containrer. When run in a Docker container, its
> using the kernel of the host, therefore your host could be Ubuntu
> 20.04 and the container could be running Ubuntu 16.04. Therefore,
> trying to use the --fix option is not a valid solution in this case
> which is what it suggests when exits with an error because 16.04 wont
> have access to the 20.04 kernel packages in the default upstream
> repos.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux-purge/+bug/1949504/+subscriptions
>

Revision history for this message
Jarno Suni (jarnos) wrote :

I am using Ubuntu 20.04. When I run your command, it exits with error: "ansible-playbook: error: the following arguments are required: playbook"

Revision history for this message
Jarno Suni (jarnos) wrote :

BTW why do you want to install kernels in a container, if they are not used anyway?

Revision history for this message
Julio Lajara (ju2wheels) wrote :

We use Ansible inside of Docker to test the automation code we deploy
to actual servers.

On Wed, Nov 3, 2021 at 7:40 AM Jarno Suni <email address hidden> wrote:
>
> BTW why do you want to install kernels in a container, if they are not
> used anyway?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1949504
>
> Title:
> linux-purge assumes current kernel needs to be installed in Docker
> container
>
> Status in linux-purge:
> Incomplete
>
> Bug description:
> I am unable to run linux-purge inside a Docker container because it
> assumes that the currently running kernel should always be installed
> and properly configured which is not a valid assumption when running
> Ubuntu inside a Docker containrer. When run in a Docker container, its
> using the kernel of the host, therefore your host could be Ubuntu
> 20.04 and the container could be running Ubuntu 16.04. Therefore,
> trying to use the --fix option is not a valid solution in this case
> which is what it suggests when exits with an error because 16.04 wont
> have access to the 20.04 kernel packages in the default upstream
> repos.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux-purge/+bug/1949504/+subscriptions
>

Revision history for this message
Jarno Suni (jarnos) wrote :

I am still unable to start the docker container by the command line you gave, even as superuser. Is it because I have 20.04?

Revision history for this message
Julio Lajara (ju2wheels) wrote :

Im on 20.04 as well, it should work fine. Is your user in the `docker` group ? Otherwise you need to run the docker command to start the container as root using sudo.

Revision history for this message
Jarno Suni (jarnos) wrote :

Even if I add the docker group, the command complains about missing playbook argument.

Revision history for this message
Julio Lajara (ju2wheels) wrote :

Ok gotcha, my fault. Our container defaults to running ansible as the
default command.

So you can either use the default base Ubuntu docker image:

docker run -it ubuntu:18.04

or for mine override the entrypoint to be the bash shell:

docker run --entrypoint /bin/bash -it ju2wheels/ansible-base:2.10.x-ubuntu-18.04

On Thu, Nov 4, 2021 at 11:35 AM Jarno Suni <email address hidden> wrote:
>
> Even if I add the docker group, the command complains about missing
> playbook argument.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1949504
>
> Title:
> linux-purge assumes current kernel needs to be installed in Docker
> container
>
> Status in linux-purge:
> Incomplete
>
> Bug description:
> I am unable to run linux-purge inside a Docker container because it
> assumes that the currently running kernel should always be installed
> and properly configured which is not a valid assumption when running
> Ubuntu inside a Docker containrer. When run in a Docker container, its
> using the kernel of the host, therefore your host could be Ubuntu
> 20.04 and the container could be running Ubuntu 16.04. Therefore,
> trying to use the --fix option is not a valid solution in this case
> which is what it suggests when exits with an error because 16.04 wont
> have access to the 20.04 kernel packages in the default upstream
> repos.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux-purge/+bug/1949504/+subscriptions
>

Jarno Suni (jarnos)
Changed in linux-purge:
status: Incomplete → Triaged
Revision history for this message
Jarno Suni (jarnos) wrote :

Can you somehow save the container's state so that you don't have to install linux-image-generic and clone and change linux-purge on each run of docker? I see your ju2wheels/ansible-base:2.10.x-ubuntu-18.04 has git pre-installed.

Revision history for this message
Jarno Suni (jarnos) wrote :

I could change the script to support your use case. However, linux-purge was designed to work on Ubuntu system that has specific packages pre-installed that do not seem to be installed in the docker images. Those include: lsb-release which is needed with --debug and --info; whiptail (or preferably dialog) with --choose (and maybe with --fix); wget and man-db if you use the provided installation/updating/removing scripts.

Revision history for this message
Jarno Suni (jarnos) wrote :

Just curious, why you want to use linux-purge instead of unattended-upgrades for automatic kernel management?

Revision history for this message
Julio Lajara (ju2wheels) wrote :

OK, no problem. Ill find a different way to run the tests outside Docker.

On Tue, Nov 9, 2021 at 4:41 AM Jarno Suni <email address hidden> wrote:
>
> I could change the script to support your use case. However, linux-purge
> was designed to work on Ubuntu system that has specific packages pre-
> installed that do not seem to be installed in the docker images. Those
> include: lsb-release which is needed with --debug and --info; whiptail
> (or preferably dialog) with --choose (and maybe with --fix); wget and
> man-db if you use the provided installation/updating/removing scripts.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1949504
>
> Title:
> linux-purge assumes current kernel needs to be installed in Docker
> container
>
> Status in linux-purge:
> Triaged
>
> Bug description:
> I am unable to run linux-purge inside a Docker container because it
> assumes that the currently running kernel should always be installed
> and properly configured which is not a valid assumption when running
> Ubuntu inside a Docker containrer. When run in a Docker container, its
> using the kernel of the host, therefore your host could be Ubuntu
> 20.04 and the container could be running Ubuntu 16.04. Therefore,
> trying to use the --fix option is not a valid solution in this case
> which is what it suggests when exits with an error because 16.04 wont
> have access to the 20.04 kernel packages in the default upstream
> repos.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux-purge/+bug/1949504/+subscriptions
>

Revision history for this message
Jarno Suni (jarnos) wrote :

I could easily make lsb-release optional so --debug would not break. Interestingly, ubuntu:14.04 container has lsb-release by default. And you do not have to care about whiptail|dialog unless you use those features. And you do not need wget and man-db, if you use git to get linux-purge like you did. I could make it possible for you to run linux-purge, but it demands some work.

Revision history for this message
Jarno Suni (jarnos) wrote :

One odd thing about a docker container ubuntu:14.04 is that realpath utility is not available even though there is coreutils 8.21 installed and even coreutils 8.15 has it according to https://savannah.gnu.org/forum/forum.php?forum_id=7076

Jarno Suni (jarnos)
Changed in linux-purge:
status: Triaged → In Progress
Jarno Suni (jarnos)
Changed in linux-purge:
assignee: nobody → Jarno Suni (jarnos)
Revision history for this message
Jarno Suni (jarnos) wrote :

I think this is fixed in version 1.0.143-de4571a

Changed in linux-purge:
status: In Progress → Fix Committed
Jarno Suni (jarnos)
Changed in linux-purge:
status: Fix Committed → Fix Released
Revision history for this message
Jarno Suni (jarnos) wrote :

Does it work for you now with --no-booted option?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.