PDA

View Full Version : rmacros.sh - stat - $CSPATH/$AL_CTL.2


earthgecko
01-09-2011, 01:08 AM
It "appears" that the rmacros.sh (http://doc.3tera.com/AppLogic29/rsrc/AppLogic29/ClientSideMacros/rmacros.sh ) may have an issue with the stat commands made on $CSPATH/$AL_CTL.2

I have not read through the entire script functions as they all appear to work. $CSPATH/$AL_CTL.2 is not required to exist for the functions to work, they still do. However the stat commands made on $CSPATH/$AL_CTL.2 makes non-useful reports:

stat: cannot stat `/tmp/apl_lnkroot/grid1.of-networks.co.uk.2': No such file or directory

This be rectified by changing the stat commands for variables T1 and T2.

#TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2`
TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2 /dev/NULL 2>&1`
#TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2`
TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2 > /dev/NULL 2>&1`
#TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2`
TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2 > /dev/NULL 2>&1`
#TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2`
TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2 > /dev/NULL 2>&1`


When using the rmacros.sh for automated provisioning, this stat report is non-useful. I could be wrong, but there appears to be no reason to report stat failures to the user.

Emailed to lion (L.Kalev) as well, but do not want to assume that they are still maintaining this.

earthgecko
01-10-2011, 01:46 AM
Lion reply:

I am still the maintainer :)

I don't quite understand how you got the "stat: cannot stat ..." error messages,
given that the file that is being stat-ed is created just before those stat commands
are executed.

I would like to get a reproducible test case where I can see those errors occurring.

BEFORE you do this, just in case: re-download the script and compare it to the
version that you have. It was last updated on Oct 12th 2010. I have made a few minor
bugfixes related to using 'rmacros.sh' non-interactively:

http://wiki.3tera.net/bin/view/AppLogic29/ClientSideMacros
http://wiki.3tera.net/pub/AppLogic29/ClientSideMacros/rmacros.sh

Let me know if this fixes your problem.

regards,

-- LK


Hi Leo

Thanks for the info.

I downloaded the one from http://doc.3tera.com/applogic2/ClientSideMacros.html (however I was sure that I downloaded this on 22 Dec 2010) and yes my version is the older version. I have updated my version. The differences were as follows, but...

< ssh_cmd="ssh -l root $AL_SSH_OPT"
---
> ssh_cmd="ssh $AL_SSH_OPT"
69c46
< if [[ -n "$AL_CTL" ]] && [[ -S $CSPATH/$AL_CTL ]] ; then
---
> if [[ -S $CSPATH/$1 ]] ; then
96,99c73,77
< # redirect all handles of the background ssh process, in case our
< # parent waits for eof on a std handle (it won't get it, if the handle
< # gets dup()ed into the forked ssh)
< $ssh_cmd -M -N -f $AL_CTLSOCKOPT $AL_CTL >/dev/null </dev/null 2>$CSPATH/$AL_CTL.2
---
> # copy stderr descr into '3' and redirect stderr into file
> # NB: can't do that on the 'ssh' command line, 'bash' waits for the file
> # to get closed (which SSH won't do, being forked) and we get stuck.
> exec 3>&2 2>$CSPATH/$AL_CTL.2
> ssh $AL_SSH_OPT -M -N -f $AL_CTLSOCKOPT $AL_CTL
100a79,80
> # re-open '2' as the old stderr and close the '3' handle
> exec 2>&3 3>&-



This version has the same issue. Below is the output and a diff.

[root@nms1 feature83.3tshell]# source /var/scripts/feature83.3tshell/of_rmacros.sh
[root@nms1 feature83.3tshell]# # Set grid controller IP
[root@nms1 feature83.3tshell]# controller grid1.of-networks.co.uk
[root@nms1 feature83.3tshell]# 3t app provision VDS_CentOS54_r1 $NEW_HOST \
> user=$NEW_USER user_pw=$USERPASS root_pw=$ROOTPASS \
> primary_ip=$PRIMARY_IP netmask=$NETMASK gateway=$GATEWAY \
> hostname=$NEW_HOST dns1=$DNS1 dns2=$DNS2 \
> cpu.dflt=$CPU mem.dflt=$MEM VDS_CENTOS54.boot.size=$BOOTSIZE | tee -a $LOGFILE
stat: cannot stat `/tmp/apl_lnkroot/grid1.of-networks.co.uk.2': No such file or directory
Copying volume VDS_CENTOS54.boot ...
Warning: failed to fully mirror volume because one or more servers are disabled
Created volume is in degraded state - repair is needed.
Preparing to copy filesystem... ****Ctrl+Cstat: cannot stat `/tmp/apl_lnkroot/grid1.of-networks.co.uk.2': No such file or directory

[root@nms1 feature83.3tshell]#
[root@nms1 feature83.3tshell]#
[root@nms1 feature83.3tshell]# diff of_rmacros.sh 20110110.rmacros.sh
2,12d1
< #### of_rmacros.sh ####
< #
< # @author L.Kalev
< # @modified Gary Wilson
< # @created 20101222 - Feature #83: Enable 3tshell on nms1
< # @modified 20110109 - Bug #90: of_rmacros.sh - /tmp/apl_lnkroot
< # @copyright L.Kalev 2006 (lion//3tera.com)
< # #original _source http://doc.3tera.com/AppLogic29/rsrc/AppLogic29/ClientSideMacros/rmacros.sh
< # @source https://svn.of-networks.co.uk/svn/infrastructure/all_linux_servers/scripts/feature83.3tshell/of_rmacros.sh
< # @local /var/scripts/feature83.3tshell/of_rmacros.sh
< #
20d8
<
26,31d13
< #####
< # START - Feature #83: Enable 3tshell on nms1
< export AL_SSH_OPT='-o IdentityFile=/root/.ssh/grid1 -o IdentitiesOnly=yes -o StrictHostKeyChecking=no'
< # END - Feature #83
< #####
<
[root@nms1 feature83.3tshell]#


Further, re-adding the changes I made to the previous version resolves this issue again.

[root@nms1 feature83.3tshell]# diff of_rmacros.sh 20110110.rmacros.sh
2,12d1
< #### of_rmacros.sh ####
< #
< # @author L.Kalev
< # @modified Gary Wilson
< # @created 20101222 - Feature #83: Enable 3tshell on nms1
< # @modified 20110109 - Bug #90: of_rmacros.sh - /tmp/apl_lnkroot
< # @copyright L.Kalev 2006 (lion//3tera.com)
< # #original _source http://doc.3tera.com/AppLogic29/rsrc/AppLogic29/ClientSideMacros/rmacros.sh
< # @source https://svn.of-networks.co.uk/svn/infrastructure/all_linux_servers/scripts/feature83.3tshell/of_rmacros.sh
< # @local /var/scripts/feature83.3tshell/of_rmacros.sh
< #
19,24d7
< #######
< # START - Bug #90: of_rmacros.sh - /tmp/apl_lnkroot
< # To overcome stat: cannot stat `/tmp/apl_lnkroot/grid1.of-networks.co.uk.2': No such file or directory
< #mkdir -p /tmp/apl_lnkroot
< ##
<
31,36d13
< #####
< # START - Feature #83: Enable 3tshell on nms1
< export AL_SSH_OPT='-o IdentityFile=/root/.ssh/grid1 -o IdentitiesOnly=yes -o StrictHostKeyChecking=no'
< # END - Feature #83
< #####
<
123,126c100
< #######
< # START: Bug #90: of_rmacros.sh - /tmp/apl_lnkroot
< #TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2`
< TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2 /dev/NULL 2>&1`
---
> TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2`
131,134c105
< #######
< # START: Bug #90: of_rmacros.sh - /tmp/apl_lnkroot
< #TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2`
< TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2 > /dev/NULL 2>&1`
---
> TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2`
181,184c152
< #######
< # START - Bug #90
< #TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2`
< TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2 > /dev/NULL 2>&1`
---
> TC1=`stat --format '%Y' $CSPATH/$AL_CTL.2`
188,191c156
< #######
< # START: Bug #90: of_rmacros.sh - /tmp/apl_lnkroot
< #TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2`
< TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2 > /dev/NULL 2>&1`
---
> TC2=`stat --format '%Y' $CSPATH/$AL_CTL.2`
[root@nms1 feature83.3tshell]#


Running with my modifications to stat.

[root@nms1 snype-probe1]# chmod 0755 /var/scripts/snype-probe1/snype-probe1.init.sh
[root@nms1 snype-probe1]# /var/scripts/snype-probe1/snype-probe1.provision.sh
Copying volume VDS_CENTOS54.boot ...
Warning: failed to fully mirror volume because one or more servers are disabled
Created volume is in degraded state - repair is needed.
Preparing to copy filesystem... *


No stat: cannot stat `/tmp/apl_lnkroot/grid1.of-networks.co.uk.2': No such file or directory error

So not sure... :)

Regards
Gary