From e7f47fd37c7750354665bbb450580e2abe374c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 29 Nov 2022 09:39:25 +0100 Subject: [PATCH 1/4] Revert "ci: temporarily disable the iSCSI test case" This reverts commit a5618aa83c58e95c209fe3062ab819cf65a381db. --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 74e1f42..d031b64 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -35,7 +35,7 @@ jobs: - INITRD_LVM - INITRD_LUKS - INITRD_LUKS_LVM - #- INITRD_ISCSI # iSCSI is missing a generator + - INITRD_ISCSI - SYSEXT container: image: "${{ matrix.distro.name }}:${{ matrix.distro.tag }}" From 5db2a2f8d74b3fd15a6b23da4bd49d51c1f98548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 3 Dec 2022 10:59:50 +0100 Subject: [PATCH 2/4] iscsi-generator: add a PoC generator that brings up iscsi root device This is not indended as a real solution. The generator should be moved to the open-iscsi project. It is added here to show how things should be done using a systemd generator and an initrd unit. The generator does not handle all the initricasies of iscsi. --- .github/workflows/build-fedora.sh | 1 + .../system-generators/iscsi-generator.sh | 98 +++++++++++++++++++ .../disable-in-initrd.conf | 10 ++ 3 files changed, 109 insertions(+) create mode 100755 mkosi.extra-iscsi/usr/lib/systemd/system-generators/iscsi-generator.sh create mode 100644 mkosi.extra-iscsi/usr/lib/systemd/system/iscsi-shutdown.service.d/disable-in-initrd.conf diff --git a/.github/workflows/build-fedora.sh b/.github/workflows/build-fedora.sh index fb0a2ad..2584e43 100755 --- a/.github/workflows/build-fedora.sh +++ b/.github/workflows/build-fedora.sh @@ -295,6 +295,7 @@ for phase in "${PHASES[@]}"; do mkosi --cache "$MKOSI_CACHE" \ --default fedora.mkosi \ --package="NetworkManager,iscsi-initiator-utils" \ + --extra-tree=mkosi.extra-iscsi \ --image-version="$KVER" \ --environment=KERNEL_VERSION="$KVER" \ --output="$INITRD" \ diff --git a/mkosi.extra-iscsi/usr/lib/systemd/system-generators/iscsi-generator.sh b/mkosi.extra-iscsi/usr/lib/systemd/system-generators/iscsi-generator.sh new file mode 100755 index 0000000..afcc66a --- /dev/null +++ b/mkosi.extra-iscsi/usr/lib/systemd/system-generators/iscsi-generator.sh @@ -0,0 +1,98 @@ +#!/bin/bash +set -e + +# Format: +# root=iscsi:[]:[]:[]:[]: +# [root=*] netroot=iscsi:[]:[]:[]:[]: +# +# root= takes precedence over netroot= if root=iscsi[...] + +# Example: +# netroot=iscsi:10.10.10.1::::iqn.2022-01.com.example:iscsi.initrd.test +# /dev/disk/by-path/ip-10.10.10.1:3260-iscsi-iqn.2022-01.com.example:iscsi.initrd.test-lun-1 +# /dev/disk/by-path/ip-10.10.10.1:3260-iscsi-iqn.2022-01.com.example:iscsi.initrd.test-lun-1-part1 +# /dev/disk/by-path/ip-:-iscsi---lun- + +root= +specs=() + +cmdline="${SYSTEMD_PROC_CMDLINE:-$(cat /proc/cmdline)}" + +for arg in $cmdline; do + if [[ $arg == "root="* ]]; then + # The last root= assignment wins. + root="${arg#*=}" + elif [[ $arg == "netroot=iscsi:"* ]]; then + value="${arg#*=}" + # All netroot= invocations matter. + specs+=( "$value" ) + + if [ -z "$root" ]; then + root="$value" + fi + fi +done + +if [[ $root == "iscsi:"* ]]; then + specs+=( "$root" ) +fi + +if [ ${#specs[@]} -eq 0 ]; then + # nothing for us to do + exit 0 +fi + +make_unit() { + # Handle the root= argument + if [[ $root == "iscsi:" ]]; then + : # TODO + fi + + service="${dest_normal}/initrd-iscsi-auto.service" + this="$(realpath "$0")" + cat >"${service}" < Date: Mon, 5 Dec 2022 14:54:04 +0100 Subject: [PATCH 3/4] ci: use networkd for iscsi test It seems that NM doesn't actually wait for the devices to come up during boot, it just probes them. NM in dracut does a bit more magic, like calling nm-initrd-generator among other things: https://github.com/dracutdevs/dracut/blob/master/modules.d/35network-manager/nm-lib.sh. --- .github/workflows/build-fedora.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-fedora.sh b/.github/workflows/build-fedora.sh index 2584e43..95d0ec9 100755 --- a/.github/workflows/build-fedora.sh +++ b/.github/workflows/build-fedora.sh @@ -294,7 +294,7 @@ for phase in "${PHASES[@]}"; do INITRD="initrd_$KVER.cpio.zstd" mkosi --cache "$MKOSI_CACHE" \ --default fedora.mkosi \ - --package="NetworkManager,iscsi-initiator-utils" \ + --package="iscsi-initiator-utils,systemd-networkd" \ --extra-tree=mkosi.extra-iscsi \ --image-version="$KVER" \ --environment=KERNEL_VERSION="$KVER" \ @@ -334,7 +334,7 @@ for phase in "${PHASES[@]}"; do dnsmasq --interface=initrd0 --bind-interfaces --dhcp-range=10.10.10.10,10.10.10.100 grep -q initrd0 /etc/qemu/bridge.conf || echo "allow initrd0" >>/etc/qemu/bridge.conf - iscsi_cmdline="ip=dhcp netroot=iscsi:10.10.10.1::::$target_name" + iscsi_cmdline="ip=dhcp netroot=iscsi:10.10.10.1::::$target_name rd.systemd.wants=systemd-networkd.service rd.systemd.wants=systemd-networkd-wait-online.service" timeout --foreground -k 10 5m \ qemu-kvm -m 1024 -smp "$(nproc)" -nographic -nic bridge,br=initrd0 \ -initrd "$INITRD" \ From f5463aa1e937f7013a4f80007e7f60ffd64a3351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 6 Dec 2022 14:17:04 +0100 Subject: [PATCH 4/4] ci: install iscsi tools in the host fs too We were failing like this: 2022-12-05T14:03:20.0045333Z Syncing filesystems and block devices. 2022-12-05T14:03:20.0521424Z Sending SIGTERM to remaining processes... 2022-12-05T14:03:20.1942427Z Sending SIGKILL to remaining processes... 2022-12-05T14:03:20.3466668Z Unmounting file systems. 2022-12-05T14:03:20.3688161Z All filesystems unmounted. 2022-12-05T14:03:20.3700551Z Deactivating swaps. 2022-12-05T14:03:20.3722192Z All swaps deactivated. 2022-12-05T14:03:20.3729382Z Detaching loop devices. 2022-12-05T14:03:20.3863371Z All loop devices detached. 2022-12-05T14:03:20.3880513Z Stopping MD devices. 2022-12-05T14:03:20.3945671Z All MD devices stopped. 2022-12-05T14:03:20.3968579Z Detaching DM devices. 2022-12-05T14:03:20.4043233Z All DM devices detached. 2022-12-05T14:03:20.4103781Z All filesystems, swaps, loop devices, MD devices and DM devices detached. 2022-12-05T14:03:20.5347085Z Syncing filesystems and block devices. 2022-12-05T14:03:20.5761222Z Powering off. 2022-12-05T14:03:20.5828227Z [ 158.519517] kvm: exiting hardware virtualization 2022-12-05T14:03:20.5901373Z [ 158.527392] sd 2:0:0:1: [sda] Synchronizing SCSI cache 2022-12-05T14:03:25.1142225Z [ 163.054446] ACPI: PM: Preparing to enter system sleep state S5 2022-12-05T14:03:25.1183925Z [ 163.058916] reboot: Power down 2022-12-05T14:03:25.1607472Z + tgtadm --lld iscsi --op delete --mode target --tid=1 2022-12-05T14:03:25.1614934Z tgtadm: this target is still active 2022-12-05T14:03:25.1666245Z ##[error]Process completed with exit code 22. We want iscsi-shutdown.service to disable the device for us. --- .github/workflows/build-fedora.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-fedora.sh b/.github/workflows/build-fedora.sh index 95d0ec9..353a01a 100755 --- a/.github/workflows/build-fedora.sh +++ b/.github/workflows/build-fedora.sh @@ -313,6 +313,7 @@ for phase in "${PHASES[@]}"; do --distribution="$ID" \ --release="$VERSION_ID" \ --format=gpt_btrfs \ + --package="iscsi-initiator-utils" \ --output=rootfs.img popd