Skip to content

Commit 2153b7d

Browse files
Make redhat exhaustive test install command more robust (#17592) (#17603)
We are seeing a frequent issue in CI where tests are failing to install via package manager on rhel8. It looks like the issue may be due to processes that are being terminated and leaving behind lock files on the rpm database. This commit udpates the install method to try to do a database rebuild routine which will force lock files to be removed. This fix assumes that at the time of testing, our tests should take priority over any package manager operation and we can prioritize our command over anything else that may be interacting with the package manager. (cherry picked from commit 01962f6) Co-authored-by: Cas Donoghue <[email protected]>
1 parent fab297e commit 2153b7d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

qa/rspec/commands/redhat.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,21 @@ def architecture_extension
4242
end
4343
end
4444

45-
def install(package)
46-
cmd = sudo_exec!("yum install -y #{package}")
45+
def install(package, retry_db_mismatch = true)
46+
cmd = sudo_exec!("yum install -y #{package}")
4747
if cmd.exit_status != 0
48+
if retry_db_mismatch && cmd.stderr.to_s.include?("DB_VERSION_MISMATCH")
49+
# There appears to be a race condition where lockfiles are left behind by
50+
# processes that are not properly terminated. This can cause the RPM database to
51+
# be in an inconsistent state. The solution is to remove and rebuild. See
52+
# https://github.com/elastic/endgame-create-iso/pull/33 for example in our CI
53+
puts "DB_VERSION_MISMATCH detected, fixing RPM database"
54+
sudo_exec!("rm -f /var/lib/rpm/__db*")
55+
sudo_exec!("rpm --rebuilddb")
56+
return install(package, false)
57+
end
4858
raise InstallException.new(cmd.stderr.to_s)
4959
end
50-
5160
end
5261

5362
def uninstall(package)

0 commit comments

Comments
 (0)