From 05c90d4c4709b43aa4f63c7171a69d9b779e964b Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 2 Jul 2016 07:32:52 -0400 Subject: [PATCH] fix issue [Customer]initrd stuck in loop and fails to get rootimg.gz for stateless image. #921 @github;use /install/postscripts/updateflag.awk as the script to report status in diskless and diskful provision --- .../share/xcat/install/scripts/chroot.sles | 30 +++++------------ .../share/xcat/install/scripts/post.xcat | 16 ++++++--- .../share/xcat/install/scripts/pre.sles | 33 +++++-------------- .../share/xcat/install/scripts/scriptlib | 22 ------------- .../xcat/netboot/rh/dracut/xcat-updateflag | 24 -------------- .../netboot/rh/dracut_033/xcat-updateflag | 24 -------------- xCAT-server/share/xcat/netboot/rh/genimage | 8 ++--- .../netboot/sles/dracut_033/xcat-updateflag | 24 -------------- xCAT-server/share/xcat/netboot/sles/genimage | 8 ++--- 9 files changed, 35 insertions(+), 154 deletions(-) delete mode 100755 xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag delete mode 100755 xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag delete mode 100755 xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag diff --git a/xCAT-server/share/xcat/install/scripts/chroot.sles b/xCAT-server/share/xcat/install/scripts/chroot.sles index f7cb762cb..0e3d65c95 100644 --- a/xCAT-server/share/xcat/install/scripts/chroot.sles +++ b/xCAT-server/share/xcat/install/scripts/chroot.sles @@ -23,33 +23,19 @@ fi AWK=`find / -name awk | head -1` #old awk /mounts/instsys/bin/awk -f -cat >/tmp/updateflag.awk < 0) - print \$0 - - if(\$0 == "ready") - print "next" |& ns - if(\$0 == "done") - break - } - - close(ns) - - exit 0 -} +(cat >/tmp/updateflag.awk << 'EOF' +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk# EOF +) >/tmp/updateflag.awk chmod 755 /tmp/updateflag.awk -/tmp/updateflag.awk + +/tmp/updateflag.awk $XCATDHOST $XCATDPORT + export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# if [ "$PRINIC" == "mac" ] then diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 7303b00df..baa5eb200 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -28,6 +28,12 @@ if [[ $TFTPDIR != /* ]]; then TFTPDIR="/"$TFTPDIR fi + +(cat << 'EOF' +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk# +EOF +) >/tmp/updateflag + cd /tmp RAND=$(perl -e 'print int(rand(50)). "\n"') if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then @@ -38,7 +44,7 @@ sleep $RAND # Stop if no openssl to help the next bit if [ ! -x /usr/bin/openssl ]; then msgutil_r "$MASTER_IP" "debug" "/usr/bin/openssl does not exist, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi @@ -75,14 +81,14 @@ fi # Stop if no wget to help the next bit if [ ! -x /usr/bin/wget ]; then msgutil_r "$MASTER_IP" "debug" "/usr/bin/wget does not exist, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 20 -T 60 http://$MASTER_IP$INSTALLDIR/postscripts/ -P /xcatpost if [ "$?" != "0" ]; then msgutil_r "$MASTER_IP" "debug" "failed to download postscripts from http://$MASTER_IP$INSTALLDIR/postscripts/, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi chmod -R +x `find /xcatpost/ -maxdepth 1 -print | grep -E -v '^(/xcatpost/|/xcatpost/_xcat|/xcatpost/_ssh|/xcatpost/ca|/xcatpost/hostkeys)$'` @@ -126,7 +132,7 @@ if [ ! -x /xcatpost/mypostscript ]; then # Stop if no getpostscript.awk to help the next bit if [ ! -x /xcatpost/getpostscript.awk ]; then msgutil_r "$MASTER_IP" "debug" "/xcatpost/getpostscript.awk does not exist, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d fi /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript @@ -227,7 +233,7 @@ fi chmod +x /xcatpost/mypostscript if [ ! -x /xcatpost/mypostscript ]; then msgutil_r "$MASTER_IP" "debug" "generate mypostscript file failure, halt ..." "/var/log/xcat/xcat.log" - updateflag $MASTER $XCATIPORT "installstatus failed" + /tmp/updateflag $MASTER $XCATIPORT "installstatus failed" sleep 36500d else if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then diff --git a/xCAT-server/share/xcat/install/scripts/pre.sles b/xCAT-server/share/xcat/install/scripts/pre.sles index f11ad0517..64115e6a5 100644 --- a/xCAT-server/share/xcat/install/scripts/pre.sles +++ b/xCAT-server/share/xcat/install/scripts/pre.sles @@ -19,32 +19,15 @@ fi AWK=`find / -name awk | tail -1` #old awk /mounts/instsys/bin/awk -f -cat >/tmp/bar.awk < /tmp/bar.awk if [ ! -c /dev/vcs ]; then @@ -123,12 +106,12 @@ chmod 755 /tmp/foo.awk chmod 755 /tmp/bar.awk -/tmp/bar.awk "installmonitor" & +/tmp/bar.awk $XCATDHOST $XCATDPORT "installmonitor" & NODESTATUS=#TABLEBLANKOKAY:site:key=nodestatus:value# if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then - /tmp/bar.awk "installstatus installing" & + /tmp/bar.awk $XCATDHOST $XCATDPORT "installstatus installing" & fi /tmp/foo.awk >/tmp/foo.log 2>&1 & diff --git a/xCAT-server/share/xcat/install/scripts/scriptlib b/xCAT-server/share/xcat/install/scripts/scriptlib index dd9b3e168..8471e74f4 100644 --- a/xCAT-server/share/xcat/install/scripts/scriptlib +++ b/xCAT-server/share/xcat/install/scripts/scriptlib @@ -38,25 +38,3 @@ declare -F msgutil &>/dev/null || function msgutil { msgutil_r "" "$@" } -declare -F updateflag &>/dev/null || function updateflag { - awk -v master="$1" -v port="$2" -v flag="$3" 'BEGIN{ - ns = "/inet/tcp/0/" master "/" port - while(1) { - if((ns |& getline) > 0) - print $0 | "logger -t xcat -p local4.info" - else { - print "Retrying flag update" | "logger -t xcat -p local4.info" - close(ns) - system("sleep 10") - } - - if($0 == "ready") - print flag |& ns - if($0 == "done") - break - } - close(ns) - exit 0 - }' - return 0 -} diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag deleted file mode 100755 index 2f9ac3165..000000000 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcat-updateflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/awk -f -#script to feedback the node provision status to xcatd -BEGIN { - - xcatdhost = ARGV[1] - xcatiport = ARGV[2] - - - ns = "/inet/tcp/0/" xcatdhost "/" xcatiport - print "xCAT_xcatd" |& ns - - while(1) { - ns |& getline - - if($0 == "ready") - print ARGV[3] |& ns - if($0 == "done") - break - } - - close(ns) - - exit 0 -} diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag deleted file mode 100755 index 2f9ac3165..000000000 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcat-updateflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/awk -f -#script to feedback the node provision status to xcatd -BEGIN { - - xcatdhost = ARGV[1] - xcatiport = ARGV[2] - - - ns = "/inet/tcp/0/" xcatdhost "/" xcatiport - print "xCAT_xcatd" |& ns - - while(1) { - ns |& getline - - if($0 == "ready") - print ARGV[3] |& ns - if($0 == "done") - break - } - - close(ns) - - exit 0 -} diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 746172726..5c4cb53f6 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -940,8 +940,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; chmod($perm&07777, "$dracutmpath/install"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath); @@ -972,8 +972,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); if ($prinic) { diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag deleted file mode 100755 index 2f9ac3165..000000000 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcat-updateflag +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/awk -f -#script to feedback the node provision status to xcatd -BEGIN { - - xcatdhost = ARGV[1] - xcatiport = ARGV[2] - - - ns = "/inet/tcp/0/" xcatdhost "/" xcatiport - print "xCAT_xcatd" |& ns - - while(1) { - ns |& getline - - if($0 == "ready") - print ARGV[3] |& ns - if($0 == "done") - break - } - - close(ns) - - exit 0 -} diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 24a780a4c..f8c22a91f 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1010,8 +1010,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2]; chmod($perm&07777, "$dracutmpath/install"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); cp("$fullpath/$dracutdir/xcat-prepivot.sh",$dracutmpath); @@ -1042,8 +1042,8 @@ sub mkinitrd_dracut { $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2]; chmod($perm&07777, "$dracutmpath/xcat-cmdline.sh"); - cp("$fullpath/$dracutdir/xcat-updateflag",$dracutmpath); - $perm = (stat("$fullpath/$dracutdir/xcat-updateflag"))[2]; + cp("$installroot/postscripts/updateflag.awk","$dracutmpath/xcat-updateflag"); + $perm = (stat("$installroot/postscripts/updateflag.awk"))[2]; chmod($perm&07777, "$dracutmpath/xcat-updateflag"); if ($prinic) { my $optspec;