From ae21b3556ff215c0f73bc0ebbc90d72fa59a3459 Mon Sep 17 00:00:00 2001 From: Sean Mooney Date: Tue, 1 Sep 2020 14:11:45 +0000 Subject: [PATCH] move cleanup of pyc files Previously pyc files were only cleaned if clean.sh was run. with this change a new clean_pyc_files function was introduced with the logic that was previously in clean.sh but it is now invoked from unstack.sh With the previous behavior you could not stack with horizon enabled then unstack and stack again due to the presence of pyc files that were owned by root. By moving the clean to unstack in stead of clean.sh you can now stack, unstack and stack again without hitting the pyc issue. since unstack is invoked by clean the existing clean.sh behavior has not changed in practice except for the fact the pyc files are removed sooner in the process. This change also removes support for findutils < 4.2.3 Ubuntu 12.04 and CentOS 6 both have 4.4.2 since they were released 8 years ago and are now EOL its fair to assume that all modern distros have 4.2.3+ https://repology.org/project/findutils/versions Change-Id: I13c9aad9be7e0930a0d875b7d382090caf0b8982 --- clean.sh | 9 --------- functions-common | 7 +++++++ unstack.sh | 2 ++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clean.sh b/clean.sh index 685a719cfb..cb0a8b4bef 100755 --- a/clean.sh +++ b/clean.sh @@ -145,12 +145,3 @@ done rm -rf ~/.config/openstack -# Clean up all *.pyc files -if [[ -n "$DEST" ]] && [[ -d "$DEST" ]]; then - find_version=`find --version | awk '{ print $NF; exit}'` - if vercmp "$find_version" "<" "4.2.3" ; then - sudo find $DEST -name "*.pyc" -print0 | xargs -0 rm - else - sudo find $DEST -name "*.pyc" -delete - fi -fi diff --git a/functions-common b/functions-common index ffbd631fb2..547f6df038 100644 --- a/functions-common +++ b/functions-common @@ -2415,6 +2415,13 @@ function time_totals { $xtrace } +function clean_pyc_files { + # Clean up all *.pyc files + if [[ -n "$DEST" ]] && [[ -d "$DEST" ]]; then + sudo find $DEST -name "*.pyc" -delete + fi +} + # Restore xtrace $_XTRACE_FUNCTIONS_COMMON diff --git a/unstack.sh b/unstack.sh index 276111edb9..3197cf136f 100755 --- a/unstack.sh +++ b/unstack.sh @@ -182,3 +182,5 @@ if is_service_enabled cinder && is_package_installed lvm2; then clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME || /bin/true clean_lvm_filter fi + +clean_pyc_files