From cd933dd5488640ac1c05657e3fe6fe978377734c Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Tue, 10 Jan 2017 14:52:59 -0500 Subject: Workaround for dnf+docker version race condition In some versions of dnf the rpm database can require maintenance after usage. Unfortunately, this trips up get_version_output in the openshift_facts library as the maintenance may interrupt the STDOUT stream. This makes the resulting data returned from get_version_output malformed and unparsable. This change adds an rpm --rebuilddb command before requesting docker version output when the ansible package manager is dnf. This causes the STDOUT maintenance messages to no longer interrupt the expected yaml stream as well as releases locks in the rpm database. --- roles/openshift_facts/library/openshift_facts.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'roles/openshift_facts/library/openshift_facts.py') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index d7e3596fd..0222b664b 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1256,6 +1256,13 @@ def is_service_running(service): return service_running +def rpm_rebuilddb(): + """ + Runs rpm --rebuilddb to ensure the db is in good shape. + """ + module.run_command(['/usr/bin/rpm', '--rebuilddb']) # noqa: F405 + + def get_version_output(binary, version_cmd): """ runs and returns the version output for a command """ cmd = [] @@ -1966,6 +1973,11 @@ class OpenShiftFacts(object): if 'docker' in roles: docker = dict(disable_push_dockerhub=False, options='--log-driver=json-file --log-opt max-size=50m') + # NOTE: This is a workaround for a dnf output racecondition that can occur in + # some situations. See https://bugzilla.redhat.com/show_bug.cgi?id=918184 + if self.system_facts['ansible_pkg_mgr'] == 'dnf': + rpm_rebuilddb() + version_info = get_docker_version_info() if version_info is not None: docker['api_version'] = version_info['api_version'] -- cgit v1.2.3