From 070fc3ca696fc365859ce890d79483c76a701007 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:46:38 -0300 Subject: [PATCH] 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 873ad1d41c9807dedfd8b94d5143d2569392ac68) --- .../admin-guides/references/man5/site.5.rst | 4 +++- perl-xCAT/xCAT/Schema.pm | 4 +++- xCAT/postscripts/xcatdsklspost | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man5/site.5.rst b/docs/source/guides/admin-guides/references/man5/site.5.rst index 0496a919e..5da893f95 100644 --- a/docs/source/guides/admin-guides/references/man5/site.5.rst +++ b/docs/source/guides/admin-guides/references/man5/site.5.rst @@ -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 diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 4fdafac6b..d3618bef1 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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" . diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index 5b8774f79..f8272561d 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -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" <