From 27a7ca0556da33580e89eaf62b878dbad661fd35 Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Fri, 18 Jan 2013 17:26:23 +0000 Subject: [PATCH] Fix bugs 3284 and 3285 - xCAT-genesis-scripts-x86_64 trying to run mknb when xcatd is not ready git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14921 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-genesis-builder/buildrpm | 42 +++++++++++++++-- .../xCAT-genesis-scripts.spec | 20 ++++++--- xCAT-server/lib/xcat/plugins/AAsn.pm | 24 +++++----- xCAT-server/sbin/xcatconfig | 45 ++++++++++--------- xCAT/xCAT.spec | 2 +- xCATsn/xCATsn.spec | 19 +++++++- 6 files changed, 105 insertions(+), 47 deletions(-) diff --git a/xCAT-genesis-builder/buildrpm b/xCAT-genesis-builder/buildrpm index e774bb2c2..ae1d7a042 100755 --- a/xCAT-genesis-builder/buildrpm +++ b/xCAT-genesis-builder/buildrpm @@ -1,13 +1,47 @@ +# Build the xCAT-genesis-base rpm on a host system. +# Option 1: install the xCAT-genesis-builder rpm (that includes this file) on a system installed with +# the distro you want to use to build xCAT-genesis-base. +# Option 2: untar the root file system of the distro you want to use and then chroot into it and copy +# this whole dir into it somewhere (like /tmp). +# Then run this script. The optional 1st arg should be mcp if you are building against mcp. +HOSTOS="$1" DIR=`dirname $0` -mkdir -p /usr/share/dracut/modules.d/97xcat -cp $DIR/* /usr/share/dracut/modules.d/97xcat +DIR=`realpath $DIR` + +# get the input files for dracut in the right place +DRACUTMODDIR=/usr/share/dracut/modules.d/97xcat +mkdir -p $DRACUTMODDIR +cp $DIR/* $DRACUTMODDIR +if [ "$HOSTOS" = "mcp" ]; then + mv -f $DRACUTMODDIR/install.$HOSTOS $DRACUTMODDIR/install + mv -f $DRACUTMODDIR/installkernel.$HOSTOS $DRACUTMODDIR/installkernel +fi mkdir -p /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs + +# run dracut +echo Creating the initramfs in /tmp/xcatgenesis.$$.rfs using dracut ... dracut -m "xcat base" -f /tmp/xcatgenesis.$$.rfs + +echo Expanding the initramfs into /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs ... cd /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/fs zcat /tmp/xcatgenesis.$$.rfs|cpio -dumi -cp /boot/vmlinuz-`uname -r` /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel + +# add the kernel +if [ "$HOSTOS" = "mcp" ]; then + echo Adding kernel /boot/vmlinuz-* ... + cp /boot/vmlinuz-* /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel +else + echo Adding kernel /boot/vmlinuz-`uname -r` ... + cp /boot/vmlinuz-`uname -r` /tmp/xcatgenesis.$$/opt/xcat/share/xcat/netboot/genesis/`uname -m`/kernel +fi cd - + +# create tar file +echo Tarring /tmp/xcatgenesis.$$/opt into ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 ... cd /tmp/xcatgenesis.$$ tar jcf ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 opt + +# build the rpm +echo Building xCAT-genesis-base rpm from ~/rpmbuild/SOURCES/xCAT-genesis-base-`uname -m`.tar.bz2 and $DIR/xCAT-genesis-base.spec ... rpmbuild -ba $DIR/xCAT-genesis-base.spec -rm -rf /usr/share/dracut/modules.d/97xcat +rm -rf $DRACUTMODDIR diff --git a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec index e29bc6eec..0c5abd353 100644 --- a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec +++ b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec @@ -56,14 +56,20 @@ rm opt/xcat/share/xcat/netboot/genesis/x86_64/fs/LICENSE.html cd - +# Since this rpm is being installed/updated, we need to run mknb to combine it with +# xCAT-genesis-base-x86_64, but mknb will not work during an initial install of xcat +# until the xCAT meta pkg has run xcatconfig or xCATsn has started xcatd. Use of a trigger +# allows us to tell those pkgs to run the code below after they run their %post scriptlets. +# (If xCAT or xCATsn is installed already, this trigger will run when xCAT-genesis-scripts +# is installed/updated.) + %post -if [ "$1" == "2" -o -e /opt/xcat/sbin/mknb ]; then #only on upgrade, or if the rest of xcat is already installed - if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image - . /etc/profile.d/xcat.sh - echo mknb %{tarch}... - mknb %{tarch} - fi -fi +# Touch this file to tell the xCAT and xCATsn rpms that when they install/update they +# should run mknb. Tried to use rpm triggers, but in several cases the trigger would +# get run multiple times. +#echo "touching /etc/xcat/genesis-scripts-updated" +touch /etc/xcat/genesis-scripts-updated + %Files %defattr(-,root,root) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index 70136c042..ce0aa6939 100644 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -1248,19 +1248,19 @@ sub setup_TFTP } else { #if not mounting, have to regenerate.... - #first, run mknb to get nbfs and such going? my $cmdref; - use xCAT_plugin::mknb; - for my $architecture ("ppc64", "x86", "x86_64") - { - unless (-d "$::XCATROOT/share/xcat/netboot/$architecture") - { - next; - } - $cmdref->{command}->[0] = "mknb"; - $cmdref->{arg}->[0] = $architecture; - $doreq->($cmdref, \&xCAT::Client::handle_response); - } + # mknb is now run in xCATsn.spec + #use xCAT_plugin::mknb; + #for my $architecture ("ppc64", "x86", "x86_64") + #{ + # unless (-d "$::XCATROOT/share/xcat/netboot/$architecture") + # { + # next; + # } + # $cmdref->{command}->[0] = "mknb"; + # $cmdref->{arg}->[0] = $architecture; + # $doreq->($cmdref, \&xCAT::Client::handle_response); + #} #now, run nodeset enact on my $mactab = xCAT::Table->new('mac'); diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index b3405b3c6..5156d75a1 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -405,9 +405,6 @@ if ($::INITIALINSTALL || $::FORCE) } } - # run mknb - only needed for Intel platforms for now - &mknb; - # makenetworks and setup http &makenetworks; &setuphttp; @@ -548,6 +545,7 @@ if ($::INITIALINSTALL || $::FORCE) my $linux_note = "xCAT is now running, it is recommended to tabedit networks \nand set a dynamic ip address range on any networks where nodes \nare to be discovered. Then, run makedhcp -n to create a new dhcpd \nconfiguration file, and \/etc\/init.d\/dhcpd restart. Either examine sample \nconfiguration templates, or write your own, or specify a value per \nnode with nodeadd or tabedit."; xCAT::MsgUtils->message('I', $linux_note); + } else { #AIX # makenetworks &makenetworks; @@ -559,6 +557,11 @@ if ($::INITIALINSTALL || $::FORCE) } #End - more - Linux-only config +# Run mknb to put xCAT-genesis-scripts-x86_64 and xCAT-genesis-base-x86_64 together and in /tftpboot +if (($::INITIALINSTALL || $::UPDATEINSTALL) && $::osname eq 'Linux') { + &mknb; +} + END { # Remove xcatconfig itself from the inittab @@ -1838,32 +1841,30 @@ sub setupLinuxexports =head3 mknb - creates a network boot root image on Linux + Creates a network boot root image on Linux + Run mknb to put xCAT-genesis-scripts-x86_64 and xCAT-genesis-base-x86_64 together and in /tftpboot =cut #----------------------------------------------------------------------------- sub mknb { - if ($::arch eq "x86_64" || $::arch eq "x86") - { - foreach my $ar (qw(x86_64)) - { - my $cmd = "XCATBYPASS=Y $::XCATROOT/sbin/mknb $ar"; - my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message('E', - "The mknb $ar command returned error: $::RUNCMD_RC."); - } - else - { - xCAT::MsgUtils->message('I', - "The mknb $ar command completed successfully."); - } - } + # The xCAT-genesis-scripts.spec file touches /etc/xcat/genesis-scripts-updated so we know to run + # mknb here. + if ($::arch eq "x86_64" && (-f '/etc/xcat/genesis-scripts-updated') ) { + unlink '/etc/xcat/genesis-scripts-updated'; + my $cmd = "$::XCATROOT/sbin/mknb $::arch"; + xCAT::MsgUtils->message('I', "Running '$cmd', triggered by the installation/update of xCAT-genesis-scripts-x86_64 ..."); + #my $outref = xCAT::Utils->runcmd("$cmd", 0); + system($cmd); + if ($? != 0) { + my $rc = $? >> 8; + xCAT::MsgUtils->message('E', "The 'mknb $::arch' command returned error code: $rc."); } - + else { + xCAT::MsgUtils->message('I', "The 'mknb $::arch' command completed successfully."); + } + } } #----------------------------------------------------------------------------- diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index fa0285aa0..23832897a 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -56,7 +56,7 @@ Requires: conserver-xcat %endif %ifarch i386 i586 i686 x86 x86_64 -Requires: syslinux xCAT-genesis-x86_64 elilo-xcat +Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat Requires: ipmitool-xcat >= 1.8.9 Requires: xnba-undi %endif diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index a26cbf340..4ed20d254 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -51,7 +51,7 @@ Requires: conserver-xcat %endif %ifarch i386 i586 i686 x86 x86_64 -Requires: syslinux xCAT-genesis-x86_64 elilo-xcat +Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat Requires: ipmitool-xcat >= 1.8.9 Requires: xnba-undi %endif @@ -177,6 +177,23 @@ fi %endif +# Run mknb if xCAT-genesis-scripts-x86_64 changed +%ifos linux +# prevent running it during install into chroot image and only run it if xCAT-genesis-scripts-x86_64 +# was recently updated. +if [ -f "/proc/cmdline" -a -f "/etc/xcat/genesis-scripts-updated" ]; then + rm -f /etc/xcat/genesis-scripts-updated + # On the SN do not run mknb if we are sharing /tftpboot with the MN + SHAREDTFTP=`/opt/xcat/sbin/tabdump site | grep sharedtftp | cut -d'"' -f 4` + if [ "$SHAREDTFTP" != "1" ]; then + . /etc/profile.d/xcat.sh + echo Running '"'mknb %{tarch}'"', triggered by the installation/update of xCAT-genesis-scripts-x86_64 ... + mknb %{tarch} + fi +fi +%endif + + %clean %files