summaryrefslogtreecommitdiff
path: root/omnibus
diff options
context:
space:
mode:
authorVikram Karve <85881329+vkarve-chef@users.noreply.github.com>2023-02-15 01:46:09 +0530
committerGitHub <noreply@github.com>2023-02-14 15:16:09 -0500
commitba03159bd91e88aa4182a8b9cd64cd27a5326316 (patch)
treee6dc3e76fea385ed735173b60ae42377cedb4d7b /omnibus
parent9338a45ad3ea733ed1332a6a13a3ab326df3d7fd (diff)
downloadchef-ba03159bd91e88aa4182a8b9cd64cd27a5326316.tar.gz
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 <vikram.karve@progress.com> Co-authored-by: Phil Dibowitz <phil@ipom.com>
Diffstat (limited to 'omnibus')
-rwxr-xr-xomnibus/package-scripts/angrychef/preinst13
-rwxr-xr-xomnibus/package-scripts/chef/preinst13
2 files changed, 26 insertions, 0 deletions
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.$$"