Fix idempotency on RHEL8

On RHEL8, podman is shipped by default with podman-docker which installs
an alias so the operators can still use "docker" CLI, but the command
will be converted to run "podman" instead:

  Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg

We don't want to remove the rpm or create /etc/containers/nodocker so
the operators have the warning and now we are moving to Podman by
default.

So we need to change Paunch to detect if Docker was actually running
before removing docker-managed containers, instead of using 'which
docker', we'll check for the actual docker socket if it exists.

Co-Authored-By: Cédric Jeanneret <cjeanner@redhat.com>
Change-Id: I628c2fe7e962412f0d7e1c3e044d02c5a2fabd77
(cherry picked from commit 2ed3e83fde)
This commit is contained in:
Emilien Macchi 2019-08-28 10:20:09 -04:00
parent 0be2e7a9b2
commit 1eae0becff
1 changed files with 3 additions and 1 deletions

View File

@ -13,6 +13,7 @@
import distutils.spawn
import json
import os
import re
import shutil
import tenacity
@ -67,7 +68,8 @@ class BaseBuilder(object):
# container that runs under Docker first before starting it with
# Podman. The container will be removed later in THT during
# upgrade_tasks.
if self.runner.cont_cmd == 'podman' and self.which('docker'):
if self.runner.cont_cmd == 'podman' and \
os.path.exists('/var/run/docker.sock'):
self.runner.stop_container(container, 'docker', quiet=True)
self.log.debug("Apply action {} for container {}.".format(