Skip to content

Commit

Permalink
Check Docker versions to ensure internal resolving works in test envi…
Browse files Browse the repository at this point in the history
…ronment.

Due to a change in Docker's DNS resolver (moby/moby#47589) in version 25.0.5 (https://docs.docker.com/engine/release-notes/25.0/#2505), traffic to the mock resolver used in integration/batch tests is no longer forwarded. This is fixed in moby/moby#47822 in version 26.0.3 (https://docs.docker.com/engine/release-notes/26.0/#2603).

- Temporary add upgrade commands to CI because 26.0.3 is not yet in the default CI image
- Add checks to warn about incompatible versions
- Add documentation to help developers get the right versions
  • Loading branch information
aequitas committed May 31, 2024
1 parent 0e85771 commit 89c3240
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 2 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,24 @@ jobs:
PY_COLORS: "1"

steps:
- if: ${{ matrix.os }} == ubuntu-24.04
name: Upgrade to at least Docker 26.1.3 to fix DNS issues
run: |
# install Docker apt repository
sudo apt update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# upgrade Docker
sudo apt install --upgrade docker-ce
- name: Enable ip6tables in Docker
run: |
sudo bash -c 'echo "{ \"ip6tables\": true, \"experimental\":true}" > /etc/docker/daemon.json'
Expand Down Expand Up @@ -527,6 +545,24 @@ jobs:
PY_COLORS: "1"

steps:
- if: ${{ matrix.os }} == ubuntu-24.04
name: Upgrade to at least Docker 26.1.3 to fix DNS issues
run: |
# install Docker apt repository
sudo apt update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# upgrade Docker
sudo apt install --upgrade docker-ce
- name: Enable ip6tables in Docker
run: |
sudo bash -c 'echo "{ \"ip6tables\": true, \"experimental\":true}" > /etc/docker/daemon.json'
Expand Down
3 changes: 2 additions & 1 deletion documentation/Docker-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ An OCI compatible container runtime with [Compose V2](https://docs.docker.com/co
- [Docker](https://docs.docker.com/get-docker/) for Linux, (supported, tested version 24.0.2)
- [Docker](https://docs.docker.com/get-docker/) for Mac (supported, tested version 4.21.0)
- [Colima](https://github.com/abiosoft/colima) for Mac (recommended, tested version 0.5.5)
- [OrbStack](https://orbstack.dev/download) for Mac (non open source, free, tested version 1.6.1)
- [Docker](https://docs.docker.com/get-docker/) for Windows (untested)

**notice**: newer versions of Docker (25+) might experience issues with internal DNS resolver. This is possibly a bug in Docker Compose:
**notice**: some versions of Docker Engine might experience issues with internal DNS resolving and will cause tests to fail. Versions from and including `25.0.5` to and including `26.1.2` should be avoided.

**notice**: your Docker runtime should be configured with enough memory and CPU, otherwise the environment will be unstable. Minimum is at least 4GB memory and 2 CPU cores, more is better for quicker rebuild/restart of images/containers.

Expand Down
21 changes: 21 additions & 0 deletions integration_tests/batch/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess
import pytest
from packaging.version import Version


@pytest.fixture(autouse=True)
def check_docker_version():
"""Some versions of Docker/Compose are incompatible because of the way their networking/DNS
works. Check this and instruct the user how to resolve the issues."""

docker_server_version = subprocess.check_output(
"docker version --format '{{.Server.Version}}'",
shell=True,
universal_newlines=True,
).strip()

if Version("25.0.5") <= Version(docker_server_version) < Version("26.1.3"):
pytest.fail(
f"Docker Server version {docker_server_version} not compatible, refer to "
"`documentation/Docker-getting-started.md#Prerequisites` for more info."
)
2 changes: 1 addition & 1 deletion integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def pytest_report_header(config):

try:
docker_compose_version = subprocess.check_output(
" docker compose version --short", shell=True, universal_newlines=True
"docker compose version --short", shell=True, universal_newlines=True
).strip()
except Exception:
docker_compose_version = "n/a"
Expand Down
21 changes: 21 additions & 0 deletions integration_tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess
import pytest
from packaging.version import Version


@pytest.fixture(autouse=True)
def check_docker_version():
"""Some versions of Docker/Compose are incompatible because of the way their networking/DNS
works. Check this and instruct the user how to resolve the issues."""

docker_server_version = subprocess.check_output(
"docker version --format '{{.Server.Version}}'",
shell=True,
universal_newlines=True,
).strip()

if Version("25.0.5") <= Version(docker_server_version) < Version("26.1.3"):
pytest.fail(
f"Docker Server version {docker_server_version} not compatible, refer to "
"`documentation/Docker-getting-started.md#Prerequisites` for more info."
)

0 comments on commit 89c3240

Please sign in to comment.