From a4cef2c4cedf504d7506dc2db8620a6524a2b56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sat, 17 Oct 2026 13:43:33 -0300 Subject: [PATCH] feat(uftp): receive the root image over UFTP on SLES stateless nodes genimage gives the stateless initial ramdisk of a SLES or openSUSE Leap image with dracut 033 or later the same UFTP receiver as an EL image. It adds the helper and uftpd when the image has the UFTP 5 receiver of xcat-dep for its architecture, checks the built ramdisk, and marks it for nodeset. xcatroot receives the first copy of the image over UFTP when nodeset asks for it, and checks it like an HTTP download. --- .../netboot/sles/dracut_033/install.netboot | 10 ++++++++++ .../xcat/netboot/sles/dracut_033/xcatroot | 18 +++++++++++++++++- xCAT-server/share/xcat/netboot/sles/genimage | 10 +++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot index d804091b73..940d5e1753 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot @@ -7,3 +7,13 @@ dracut_install parted mke2fs bc mkswap swapon chmod mkfs mkfs.ext4 mkfs.xfs xfs_ inst "$moddir/xcat-updateflag" "/tmp/updateflag" inst "$moddir/xcatroot" "/sbin/xcatroot" inst_hook cmdline 10 "$moddir/xcat-cmdline.sh" +# genimage adds the UFTP helper only when the image has a UFTP 5 receiver. +if [ -r "$moddir/xcat-rootimg-fetch.sh" ]; then + inst "$moddir/xcat-rootimg-fetch.sh" "/lib/xcat-rootimg-fetch.sh" + for uftpd in /usr/sbin/uftpd /usr/bin/uftpd; do + if [ -x "$uftpd" ]; then + dracut_install "$uftpd" + break + fi + done +fi diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index eec26ec584..3d5f5cd848 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -57,7 +57,23 @@ rootimg_matches_checksum() { return 1 } +# Downloads the image at $1 to the file $2, over UFTP the first time when nodeset asks for it. +rootimg_download() { + if [ -n "$rootimg_uftp" ]; then + rootimg_uftp_port=$rootimg_uftp + rootimg_uftp= + # nodeset asks for UFTP only with the checksum, which the caller checks on the received file. + if [ "$rootimgchecksum" = yes ] && [ -r /lib/xcat-rootimg-fetch.sh ] && . /lib/xcat-rootimg-fetch.sh && + xcat_uftp_rootimg "$1" "$2" /tmp/rootimg.sha256.before "$rootimg_uftp_port" "$(getarg xcat.uftpfp=)"; then + return 0 + fi + logger $SYSLOGHOST -t $log_label -p local4.warning "Cannot receive $1 over UFTP, downloading it over HTTP..." + fi + wget -nv "$1" +} + rootimgchecksum="$(getarg rootimgchecksum=)" +rootimg_uftp="$(getarg xcat.uftp=)" if [ ! -z "$imgurl" ]; then if [ xhttp = x${imgurl%%:*} ] || [ xhttps = x${imgurl%%:*} ]; then @@ -73,7 +89,7 @@ if [ ! -z "$imgurl" ]; then [ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "downloading $imgurl...." echo Getting $imgurl... [ "$rootimgchecksum" != yes ] || rootimg_fetch_checksum "$imgurl" /tmp/rootimg.sha256.before || rm -f /tmp/rootimg.sha256.before - if ! wget -nv $imgurl; then + if ! rootimg_download "$imgurl" "$FILENAME"; then [ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "downloading $imgurl failed,retrying...." rm -f $FILENAME sleep 27 diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index e6475a64f7..24ff1d734b 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1057,6 +1057,10 @@ sub mkinitrd_dracut { my $dracutmpath = $dracutmoduledir . "97xcat/"; mkpath($dracutmpath); + # Only a stateless initial ramdisk that checks the root image receives it over UFTP. + my $uftp_receiver = eval { imgutils::add_uftp_receiver($rootimg_dir, $arch, $dracutmpath, $mode eq 'stateless' && $dracutdir eq 'dracut_033') }; + xdie($@) if $@; + my $perm = (stat("$fullpath/$dracutdir/check"))[2]; cp("$fullpath/$dracutdir/check", $dracutmpath); chmod($perm & 07777, "$dracutmpath/check"); @@ -1177,8 +1181,12 @@ sub mkinitrd_dracut { print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n"; !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver") or die("Error: failed to generate the initial ramdisk for $mode.\n"); + eval { imgutils::check_uftp_initrd($rootimg_dir, "/tmp/initrd.$$.gz", $mode) } or xdie($@) if $uftp_receiver; print "the initial ramdisk for $mode is generated successfully.\n"; - move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz") and mark_rootimg_check($mode); + if (move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz")) { + mark_rootimg_check($mode); + imgutils::mark_uftp_receiver("$destdir/initrd-$mode.gz", $uftp_receiver) if $mode eq 'stateless'; + } }