From ba03159bd91e88aa4182a8b9cd64cd27a5326316 Mon Sep 17 00:00:00 2001 From: Vikram Karve <85881329+vkarve-chef@users.noreply.github.com> Date: Wed, 15 Feb 2023 01:46:09 +0530 Subject: Update pre-install cleanup (#13562) Script now updated to first attempt direct folder deletion. Fall back to existing move-delete strategy only if that doesn't work, likely due to EBUSY error on RHEL --------- Signed-off-by: Vikram Karve Co-authored-by: Phil Dibowitz --- omnibus/package-scripts/angrychef/preinst | 13 +++++++++++++ omnibus/package-scripts/chef/preinst | 13 +++++++++++++ 2 files changed, 26 insertions(+) (limited to 'omnibus') diff --git a/omnibus/package-scripts/angrychef/preinst b/omnibus/package-scripts/angrychef/preinst index e38c3f7a3e..db01c9dfdf 100755 --- a/omnibus/package-scripts/angrychef/preinst +++ b/omnibus/package-scripts/angrychef/preinst @@ -7,9 +7,22 @@ # this programming language. do not touch. # - if you are under 40, get peer review from your elders. +# This whole file exists because on some versions of RPM, during upgrades, the postrm script +# runs AFTER the installation of the upgraded RPM. Oops. See https://github.com/chef/chef/pull/7964 + INSTALLER_DIR=/opt/chef + if [ -e $INSTALLER_DIR ]; then echo "removing $INSTALLER_DIR..." + rm -rf $INSTALLER_DIR || true +fi + +# Sometimes, on some platforms, we get an EBUSY error trying to delete this, which will cause issues +# with the upgrades. So we move it so it won't interfere with the upgrade, then delete it, which will +# cause the OS to free the space once it's no longer used (when the current chef run ends, or whatever +# else is using those libs). See: https://github.com/chef/chef/pull/8046 +if [ -e $INSTALLER_DIR ]; then + echo "Some files failed to delete, moving them so we don't interfere with upgrades, and then removing them" # have to do this dance of moving /opt/chef to a tmp dir since files may be in use tmp_dir="/opt/.chef.$$" diff --git a/omnibus/package-scripts/chef/preinst b/omnibus/package-scripts/chef/preinst index e38c3f7a3e..db01c9dfdf 100755 --- a/omnibus/package-scripts/chef/preinst +++ b/omnibus/package-scripts/chef/preinst @@ -7,9 +7,22 @@ # this programming language. do not touch. # - if you are under 40, get peer review from your elders. +# This whole file exists because on some versions of RPM, during upgrades, the postrm script +# runs AFTER the installation of the upgraded RPM. Oops. See https://github.com/chef/chef/pull/7964 + INSTALLER_DIR=/opt/chef + if [ -e $INSTALLER_DIR ]; then echo "removing $INSTALLER_DIR..." + rm -rf $INSTALLER_DIR || true +fi + +# Sometimes, on some platforms, we get an EBUSY error trying to delete this, which will cause issues +# with the upgrades. So we move it so it won't interfere with the upgrade, then delete it, which will +# cause the OS to free the space once it's no longer used (when the current chef run ends, or whatever +# else is using those libs). See: https://github.com/chef/chef/pull/8046 +if [ -e $INSTALLER_DIR ]; then + echo "Some files failed to delete, moving them so we don't interfere with upgrades, and then removing them" # have to do this dance of moving /opt/chef to a tmp dir since files may be in use tmp_dir="/opt/.chef.$$" -- cgit v1.2.1