From 67c1cced8fa82e510448b5d84b0b3ddfbbeda8a7 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Tue, 11 Aug 2020 14:32:33 -0600 Subject: [PATCH] Fix Travis CI issue with Docker server API version mismatch Travis CI is using a version of Docker server that supports API version 1.38. However, the Python PYPI package `docker` version 4.3 was recently released which uses Docker server API version 1.39, and there is apparently no way to tell molecule to configure the `docker` Python API to use a different API. The solution is to install the latest 4.2.x version of the `docker` Python PYPI package. --- .travis/runtox | 18 ++++++++++++++++++ tox.ini | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.travis/runtox b/.travis/runtox index f017482..7981381 100755 --- a/.travis/runtox +++ b/.travis/runtox @@ -16,6 +16,24 @@ ME=$(basename $0) SCRIPTDIR=$(readlink -f $(dirname $0)) BANNERSIZE=90 +# LSR_MOLECULE_DOCKER_VERSION is the version string to pass +# to pip install - this is usually a comparison operator +# followed by a version number e.g. '<4.3' but in reality +# may be anything that pip allows to follow a package name +# in an install specification +if [ -z "${LSR_MOLECULE_DOCKER_VERSION:-}" ]; then + if type docker > /dev/null 2>&1; then + DOCKER_SERVER_API_VERSION=$(docker version --format '{{.Server.APIVersion}}') + case "$DOCKER_SERVER_API_VERSION" in + 1.3[0-8]|1.[0-2]*) LSR_MOLECULE_DOCKER_VERSION='<4.3';; + *) LSR_MOLECULE_DOCKER_VERSION="";; + esac + else + LSR_MOLECULE_DOCKER_VERSION="" + fi +fi +export LSR_MOLECULE_DOCKER_VERSION + . ${SCRIPTDIR}/utils.sh . ${SCRIPTDIR}/config.sh diff --git a/tox.ini b/tox.ini index 8a3a153..05056bf 100644 --- a/tox.ini +++ b/tox.ini @@ -109,7 +109,7 @@ commands = changedir = {toxinidir} deps = {env:LSR_ANSIBLE_DEP:ansible} - docker + docker{env:LSR_MOLECULE_DOCKER_VERSION:} molecule<3 selinux -rmolecule_extra_requirements.txt