Skip to content

Commit

Permalink
Install nohang from source for ubuntu (#2318)
Browse files Browse the repository at this point in the history
* Install nohang from source for ubuntu

nohang apt repo is not actively maintained, install it from source instead.

try to fix #2195

Signed-off-by: Liyi Meng <meng.mobile@gmail.com>

* Refactoring

1. We don't need zfs on UKI images
2. gnupg is not needed in common
3. Renaming of targets to legacy and current, to re-use between 22+
   versions

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

* Re-generate Dockerfile.kairos-ubuntu

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

* Lint

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

---------

Signed-off-by: Liyi Meng <meng.mobile@gmail.com>
Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
Co-authored-by: Mauro Morales <mauro.morales@spectrocloud.com>
  • Loading branch information
liyimeng and mauromorales authored Mar 12, 2024
1 parent 2665b8f commit e0d76a9
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 60 deletions.
68 changes: 38 additions & 30 deletions images/Dockerfile.kairos-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,31 @@ FROM ${BASE_IMAGE} AS ubuntu-20.04-upstream

FROM ${BASE_IMAGE} AS ubuntu-22.04-upstream

###############################################################
#### build nohang from source ####
###############################################################
# There's an issue between the nohang package provided by
# Ubuntu and the zfsutils-linux package, there is a fix in
# nohang upstream but it's not yet available in the Ubuntu
# package, so we build it from source
FROM ubuntu:22.04 as nohang-src
WORKDIR /root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
make fakeroot git ca-certificates gnupg

RUN git clone -b master --depth=1 https://github.com/hakavlad/nohang.git \
&& cd nohang \
&& echo > deb/DEBIAN/postinst \
&& deb/build.sh

###############################################################
#### Pre-Process Common to All ####
###############################################################
FROM ${FLAVOR}-${FLAVOR_RELEASE}-upstream AS common
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gnupg \
software-properties-common \
&& add-apt-repository ppa:oibaf/test \
&& apt-get update \
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
conntrack \
console-data \
Expand All @@ -70,7 +82,6 @@ RUN apt-get update \
lvm2 \
nano \
nbd-client \
nohang \
open-iscsi \
open-vm-tools \
openssh-server \
Expand All @@ -87,6 +98,11 @@ RUN apt-get update \
tpm2-* \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install nohang
COPY --from=nohang-src /root/nohang/deb/package.deb /tmp/nohang.deb
RUN apt-get install -y --no-install-recommends /tmp/nohang.deb
RUN rm -rf /tmp/nohang.deb

# This target is aimed at UKI images and avoids to install GRUB and any other unnecesary packages
# to the image because there are limitations on the total size
FROM common AS systemd-boot
Expand All @@ -106,6 +122,7 @@ RUN apt-get update \
shim-signed \
snmpd \
squashfs-tools \
zfsutils-linux \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

FROM systemd-boot AS systemd-boot-amd64
Expand Down Expand Up @@ -189,54 +206,45 @@ RUN apt-get update \
###############################################################
#### Common to an Arch and Flavor ####
###############################################################
FROM ${TARGETARCH} AS base-ubuntu-20.04
FROM ${TARGETARCH} AS base-ubuntu-legacy
RUN apt-get update && apt-get install -y --no-install-recommends \
file \
fuse \
patch \
policykit-1 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

FROM ${TARGETARCH} AS base-ubuntu-22.04
FROM ${TARGETARCH} AS base-ubuntu-current
RUN apt-get update && apt-get install -y --no-install-recommends \
firmware-sof-signed \
fuse3 \
pigz \
polkitd \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

FROM base-ubuntu-20.04 AS amd64-base-ubuntu-20.04
FROM base-ubuntu-current AS amd64-base-ubuntu-current
RUN apt-get update
# If a kernel is already installed, don't try to install it again, this way the base image can
# be non-hwe for older releases
RUN apt-get update
RUN [ -z "$(ls -A /lib/modules/)" ] && apt-get install -y --no-install-recommends \
linux-image-generic-hwe-20.04 || true
linux-image-generic-hwe-22.04 || true
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

FROM base-ubuntu-22.04 AS amd64-base-ubuntu-22.04
RUN apt-get update
FROM base-ubuntu-legacy AS amd64-ubuntu-20.04
# If a kernel is already installed, don't try to install it again, this way the base image can
# be non-hwe for older releases
RUN apt-get update
RUN [ -z "$(ls -A /lib/modules/)" ] && apt-get install -y --no-install-recommends \
linux-image-generic-hwe-22.04 || true
linux-image-generic-hwe-20.04 || true
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

FROM amd64-base-ubuntu-22.04 AS amd64-ubuntu-24.04
FROM amd64-base-ubuntu-22.04 AS amd64-ubuntu-23.10
FROM amd64-base-ubuntu-22.04 AS amd64-ubuntu-22.04
RUN apt-get update && apt-get install -y --no-install-recommends \
# zfsutils-linux cannot be installed on 23+ because of a bug with nohang
zfsutils-linux \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
FROM amd64-base-ubuntu-20.04 AS amd64-ubuntu-20.04
RUN apt-get update && apt-get install -y --no-install-recommends \
# zfsutils-linux cannot be installed on 23+ because of a bug with nohang
zfsutils-linux \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
FROM amd64-base-ubuntu-current AS amd64-ubuntu-22.04
FROM amd64-base-ubuntu-current AS amd64-ubuntu-23.10
FROM amd64-base-ubuntu-current AS amd64-ubuntu-24.04

FROM base-ubuntu-22.04 AS arm64-ubuntu-23.10
FROM base-ubuntu-22.04 AS arm64-ubuntu-22.04
FROM base-ubuntu-20.04 AS arm64-ubuntu-20.04
FROM base-ubuntu-legacy AS arm64-ubuntu-20.04
FROM base-ubuntu-legacy AS arm64-ubuntu-22.04
FROM base-ubuntu-legacy AS arm64-ubuntu-23.10

###############################################################
#### Common to a Single Model ####
Expand Down
68 changes: 38 additions & 30 deletions images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,31 @@ FROM ${BASE_IMAGE} AS ubuntu-20.04-upstream

FROM ${BASE_IMAGE} AS ubuntu-22.04-upstream

###############################################################
#### build nohang from source ####
###############################################################
# There's an issue between the nohang package provided by
# Ubuntu and the zfsutils-linux package, there is a fix in
# nohang upstream but it's not yet available in the Ubuntu
# package, so we build it from source
FROM ubuntu:22.04 as nohang-src
WORKDIR /root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
make fakeroot git ca-certificates gnupg

RUN git clone -b master --depth=1 https://github.com/hakavlad/nohang.git \
&& cd nohang \
&& echo > deb/DEBIAN/postinst \
&& deb/build.sh

###############################################################
#### Pre-Process Common to All ####
###############################################################
FROM ${FLAVOR}-${FLAVOR_RELEASE}-upstream AS common
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gnupg \
software-properties-common \
&& add-apt-repository ppa:oibaf/test \
&& apt-get update \
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
conntrack \
console-data \
Expand All @@ -71,7 +83,6 @@ RUN apt-get update \
lvm2 \
nano \
nbd-client \
nohang \
open-iscsi \
open-vm-tools \
openssh-server \
Expand All @@ -88,6 +99,11 @@ RUN apt-get update \
tpm2-* \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

# Install nohang
COPY --from=nohang-src /root/nohang/deb/package.deb /tmp/nohang.deb
RUN apt-get install -y --no-install-recommends /tmp/nohang.deb
RUN rm -rf /tmp/nohang.deb

# This target is aimed at UKI images and avoids to install GRUB and any other unnecesary packages
# to the image because there are limitations on the total size
FROM common AS systemd-boot
Expand All @@ -107,6 +123,7 @@ RUN apt-get update \
shim-signed \
snmpd \
squashfs-tools \
zfsutils-linux \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

FROM systemd-boot AS systemd-boot-amd64
Expand Down Expand Up @@ -190,54 +207,45 @@ RUN apt-get update \
###############################################################
#### Common to an Arch and Flavor ####
###############################################################
FROM ${TARGETARCH} AS base-ubuntu-20.04
FROM ${TARGETARCH} AS base-ubuntu-legacy
RUN apt-get update && apt-get install -y --no-install-recommends \
file \
fuse \
patch \
policykit-1 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

FROM ${TARGETARCH} AS base-ubuntu-22.04
FROM ${TARGETARCH} AS base-ubuntu-current
RUN apt-get update && apt-get install -y --no-install-recommends \
firmware-sof-signed \
fuse3 \
pigz \
polkitd \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

FROM base-ubuntu-20.04 AS amd64-base-ubuntu-20.04
FROM base-ubuntu-current AS amd64-base-ubuntu-current
RUN apt-get update
# If a kernel is already installed, don't try to install it again, this way the base image can
# be non-hwe for older releases
RUN apt-get update
RUN [ -z "$(ls -A /lib/modules/)" ] && apt-get install -y --no-install-recommends \
linux-image-generic-hwe-20.04 || true
linux-image-generic-hwe-22.04 || true
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

FROM base-ubuntu-22.04 AS amd64-base-ubuntu-22.04
RUN apt-get update
FROM base-ubuntu-legacy AS amd64-ubuntu-20.04
# If a kernel is already installed, don't try to install it again, this way the base image can
# be non-hwe for older releases
RUN apt-get update
RUN [ -z "$(ls -A /lib/modules/)" ] && apt-get install -y --no-install-recommends \
linux-image-generic-hwe-22.04 || true
linux-image-generic-hwe-20.04 || true
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

FROM amd64-base-ubuntu-22.04 AS amd64-ubuntu-24.04
FROM amd64-base-ubuntu-22.04 AS amd64-ubuntu-23.10
FROM amd64-base-ubuntu-22.04 AS amd64-ubuntu-22.04
RUN apt-get update && apt-get install -y --no-install-recommends \
# zfsutils-linux cannot be installed on 23+ because of a bug with nohang
zfsutils-linux \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
FROM amd64-base-ubuntu-20.04 AS amd64-ubuntu-20.04
RUN apt-get update && apt-get install -y --no-install-recommends \
# zfsutils-linux cannot be installed on 23+ because of a bug with nohang
zfsutils-linux \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
FROM amd64-base-ubuntu-current AS amd64-ubuntu-22.04
FROM amd64-base-ubuntu-current AS amd64-ubuntu-23.10
FROM amd64-base-ubuntu-current AS amd64-ubuntu-24.04

FROM base-ubuntu-22.04 AS arm64-ubuntu-23.10
FROM base-ubuntu-22.04 AS arm64-ubuntu-22.04
FROM base-ubuntu-20.04 AS arm64-ubuntu-20.04
FROM base-ubuntu-legacy AS arm64-ubuntu-20.04
FROM base-ubuntu-legacy AS arm64-ubuntu-22.04
FROM base-ubuntu-legacy AS arm64-ubuntu-23.10

###############################################################
#### Common to a Single Model ####
Expand Down

0 comments on commit e0d76a9

Please sign in to comment.