mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-20 06:35:31 +00:00
fix(xcatdsklspost): updatenode leaves /xcatpost populated when site.cleanupdiskfullxcatpost is set
An administrator sets site.cleanupdiskfullxcatpost, deploys a diskfull node, and
/xcatpost is empty. The next updatenode run downloads the postscripts again and
leaves them there. /xcatpost is mode 0755 and most of what lands in it is
world-readable, so material the administrator was told is gone comes back on
every maintenance run and on every reboot.
xcatdsklspost is the script that repopulates /xcatpost on all of those paths, and
it reads only CLEANUPXCATPOST. CLEANUPDISKFULLXCATPOST reaches the node in the
same mypostscript, exported by the site table, and no code reads it. Only
xcatinstallpost does, and that runs once, at install.
Read it in append_xcatpost_cleanup with the rule xcatinstallpost uses: remove the
postscripts when the run returns 0, keep updateflag.awk, and leave everything in
place after a failed run so the node can be examined.
xCAT-test/bats/xcatdsklspost_xcatpost_cleanup.bats captures this. Three of its
six tests fail on the previous commit.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
(cherry picked from commit 873ad1d41c)
This commit is contained in:
committed by
github-actions[bot]
parent
cc49558f77
commit
070fc3ca69
@@ -288,7 +288,9 @@ site Attributes:
|
||||
|
||||
cleanupdiskfullxcatpost: (yes/1 or no/0). Set to 'yes' or '1' to clean up the /xcatpost
|
||||
directory on the diskfull nodes after the
|
||||
postscripts are run with no errors. Default is no.
|
||||
postscripts are run with no errors: at deployment, after each
|
||||
updatenode run, and after a reboot. updateflag.awk stays, so
|
||||
the node can still report its status. Default is no.
|
||||
|
||||
db2installloc: The location which the service nodes should mount for
|
||||
the db2 code to install. Format is hostname:/path. If hostname is
|
||||
|
||||
@@ -1198,7 +1198,9 @@ passed as argument rather than by table value',
|
||||
" postscripts are run. Default is no.\n\n" .
|
||||
" cleanupdiskfullxcatpost: (yes/1 or no/0). Set to 'yes' or '1' to clean up the /xcatpost\n" .
|
||||
" directory on the diskfull nodes after the\n" .
|
||||
" postscripts are run with no errors. Default is no.\n\n" .
|
||||
" postscripts are run with no errors: at deployment, after each\n" .
|
||||
" updatenode run, and after a reboot. updateflag.awk stays, so\n" .
|
||||
" the node can still report its status. Default is no.\n\n" .
|
||||
" db2installloc: The location which the service nodes should mount for\n" .
|
||||
" the db2 code to install. Format is hostname:/path. If hostname is\n" .
|
||||
" omitted, it defaults to the management node. Default is /mntdb2.\n\n" .
|
||||
|
||||
@@ -230,6 +230,12 @@ parsehttpserver ()
|
||||
# The append happens on every path this script serves: node deployment, and each
|
||||
# updatenode, moncfg or reboot run.
|
||||
#
|
||||
# The two site attributes do not ask for the same thing. cleanupxcatpost removes
|
||||
# every file and ignores the result of the run. cleanupdiskfullxcatpost keeps
|
||||
# updateflag.awk, which the node needs to report its status, and removes nothing
|
||||
# after a failed run, so the postscripts stay on the node for diagnosis.
|
||||
# xcatinstallpost applies the same rule at install time.
|
||||
#
|
||||
# $1 - path of the generated mypostscript
|
||||
# $2 - the xcatpost directory to remove the postscripts from
|
||||
#####################################################
|
||||
@@ -238,6 +244,7 @@ append_xcatpost_cleanup()
|
||||
local mypostscript=$1
|
||||
local postdir=$2
|
||||
local cleanupxcatpost
|
||||
local cleanupdiskfullxcatpost
|
||||
|
||||
cleanupxcatpost=`grep CLEANUPXCATPOST= "$mypostscript" |awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z`
|
||||
if [[ "$cleanupxcatpost" =~ ^(1|yes|y)$ ]]; then
|
||||
@@ -245,6 +252,18 @@ append_xcatpost_cleanup()
|
||||
# /xcatpost might be read-only for statelite nodes
|
||||
echo "rm -rf $postdir/*" >> "$mypostscript"
|
||||
fi
|
||||
|
||||
cleanupdiskfullxcatpost=`grep CLEANUPDISKFULLXCATPOST= "$mypostscript" |awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z`
|
||||
if [[ "$cleanupdiskfullxcatpost" =~ ^(1|yes|y)$ ]]; then
|
||||
cat >> "$mypostscript" <<EOF
|
||||
if [ "\$return_value" -eq "0" ]; then
|
||||
cd /
|
||||
find $postdir/ -type f -not -name 'updateflag.awk' -delete
|
||||
find $postdir/ -type d -empty -delete
|
||||
msgutil_r \$MASTER_IP "info" "cleanup of $postdir completed.(\$NODE)" "/var/log/xcat/xcat.log" "\$log_label"
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$XCATDSKLSPOST_SOURCE_ONLY" = "1" ]; then
|
||||
|
||||
Reference in New Issue
Block a user