From 9ecfd71f8e78261f5150fb1f55ce0cfd77708250 Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Thu, 25 Feb 2021 09:14:08 +0100 Subject: [PATCH 1/6] [IMP] add healthcheck support for http and smtp this enables the user to configure a healthcheck for containers that can be used to automatically restart proxies resolving to no longer active ips due to PRE_RESOLVE --- Dockerfile | 14 +++- README.md | 49 ++++++++++++ healthcheck.py | 124 +++++++++++++++++++++++++++++++ tests/run_tests.sh | 76 +++++++++++++++++++ tests/test.yaml | 152 ++++++++++++++++++++++++++++++++++++++ tests/test_healthcheck.sh | 9 +++ 6 files changed, 421 insertions(+), 3 deletions(-) create mode 100755 healthcheck.py create mode 100755 tests/run_tests.sh create mode 100644 tests/test.yaml create mode 100755 tests/test_healthcheck.sh diff --git a/Dockerfile b/Dockerfile index f1b2c40..a8586ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ FROM python:3-alpine ENTRYPOINT ["dumb-init", "--"] CMD ["proxy"] -RUN apk add --no-cache -t .build build-base &&\ +HEALTHCHECK CMD ["healthcheck"] +RUN apk add --no-cache -t .build build-base curl-dev &&\ apk add --no-cache socat &&\ - pip install --no-cache-dir dnspython dumb-init &&\ + apk add --no-cache libcurl &&\ + pip install --no-cache-dir dnspython dumb-init pycurl &&\ apk del .build ENV NAMESERVERS="208.67.222.222 8.8.8.8 208.67.220.220 8.8.4.4" \ PORT="80 443" \ @@ -11,8 +13,14 @@ ENV NAMESERVERS="208.67.222.222 8.8.8.8 208.67.220.220 8.8.4.4" \ MODE=tcp \ VERBOSE=0 \ MAX_CONNECTIONS=100 \ - UDP_ANSWERS=1 + UDP_ANSWERS=1 \ + HTTP_HEALTHCHECK=0\ + HTTP_HEALTHCHECK_URL="http://\$TARGET/"\ + SMTP_HEALTHCHECK=0\ + SMTP_HEALTHCHECK_URL="smtp://\$TARGET/"\ + SMTP_HEALTHCHECK_COMMAND="HELP" COPY proxy.py /usr/local/bin/proxy +COPY healthcheck.py /usr/local/bin/healthcheck # Labels ARG BUILD_DATE diff --git a/README.md b/README.md index 9c3fb05..5e639e4 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,29 @@ Use these environment variables: Required. It's the host name where the incoming connections will be redirected to. +### `HTTP_HEALTHCHECK` + +Default: `0` + +Set to `1` to enable healthcheck with pycurl http requests. This is useful if the target +uses a deployment where the ip of the service gets changed frequently (e.g. +`accounts.google.com`) and you are using [`PRE_RESOLVE`](#pre_resolve) + +#### Automatically restarting unhealthy proxies + +When you enable the http healthcheck the container marks itself as unhealthy but does +nothing. (see https://github.com/moby/moby/pull/22719) + +If you want to restart your proxies automatically, you can use +https://github.com/willfarrell/docker-autoheal. + +### `HTTP_HEALTHCHECK_URL` + +Default: `http://$TARGET/` + +Url to use in [`HTTP_HEALTHCHECK`](#http_healthcheck) if enabled. `$TARGET` gets +replaced inside the url by the configured [`TARGET`](#target). + ### `MODE` Default: `tcp` @@ -94,6 +117,32 @@ Set to `1` to force using the specified [nameservers](#nameservers) to resolve t This is especially useful when using a network alias to whitelist an external API. +### `SMTP_HEALTHCHECK` + +Default: `0` + +Set to `1` to enable healthcheck with pycurl smtp requests. This is useful if the target +uses a deployment where the ip of the service gets changed frequently (e.g. +`smtp.eu.sparkpostmail.com`) and you are using [`PRE_RESOLVE`](#pre_resolve) + +#### Automatically restarting unhealthy proxies + +see [HTTP_HEALTHCHECK](#http_healthcheck) + +### `SMTP_HEALTHCHECK_URL` + +Default: `smtp://$TARGET/` + +Url to use in [`SMTP_HEALTHCHECK`](#smtp_healthcheck) if enabled. `$TARGET` gets +replaced inside the url by the configured [`TARGET`](#target). + +### `SMTP_HEALTHCHECK_COMMAND` + +Default: `HELP` + +Enables changing the healthcheck command for servers that do not support `HELP` (e.g. +for [MailHog](https://github.com/mailhog/MailHog) you can use `QUIT`) + ### `UDP_ANSWERS` Default: `1` diff --git a/healthcheck.py b/healthcheck.py new file mode 100755 index 0000000..5ac8470 --- /dev/null +++ b/healthcheck.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 + +import logging +import os + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger("healthcheck") + + +def error(message, exception=None): + logger.error(message) + if exception is None: + exit(1) + else: + raise exception + + +def http_healthcheck(): + """ + Use pycurl to check if the target server is still responding via proxy.py + :return: None + """ + import re + + import pycurl + + check_url = os.environ.get("HTTP_HEALTHCHECK_URL", "http://localhost/") + target = os.environ.get("TARGET", "localhost") + check_url_with_target = check_url.replace("$TARGET", target) + port = re.search("https?://[^:]*(?::([^/]+))?", check_url_with_target)[1] or "80" + print("checking %s via 127.0.0.1" % check_url_with_target) + logger.info("checking %s via 127.0.0.1" % check_url_with_target) + try: + request = pycurl.Curl() + request.setopt(pycurl.URL, check_url_with_target) + # do not send the request to the target directly but use our own socat proxy process to check if it's still + # working + request.setopt(pycurl.RESOLVE, ["{}:{}:127.0.0.1".format(target, port)]) + request.perform() + request.close() + except pycurl.error as e: + error("error while checking http connection", e) + + +def smtp_healthcheck(): + """ + Use pycurl to check if the target server is still responding via proxy.py + :return: None + """ + import re + + import pycurl + + check_url = os.environ.get("SMTP_HEALTHCHECK_URL", "smtp://localhost/") + check_command = os.environ.get("SMTP_HEALTHCHECK_COMMAND", "HELP") + target = os.environ.get("TARGET", "localhost") + check_url_with_target = check_url.replace("$TARGET", target) + port = re.search("smtp://[^:]*(?::([^/]+))?", check_url_with_target)[1] or "25" + logger.info("checking %s via 127.0.0.1" % check_url_with_target) + try: + request = pycurl.Curl() + request.setopt(pycurl.URL, check_url_with_target) + request.setopt(pycurl.CUSTOMREQUEST, check_command) + # do not send the request to the target directly but use our own socat proxy process to check if it's still + # working + request.setopt(pycurl.RESOLVE, ["{}:{}:127.0.0.1".format(target, port)]) + request.perform() + request.close() + except pycurl.error as e: + error("error while checking smtp connection", e) + + +def process_healthcheck(): + """ + Check that at least one socat process exists per port and no more than the number of configured max connections + processes exist for each port. + :return: + """ + import subprocess + + ports = os.environ["PORT"].split() + max_connections = int(os.environ["MAX_CONNECTIONS"]) + logger.info( + "checking socat processes for port(s) %s having at least one and less than %d socat processes" + % (ports, max_connections) + ) + socat_processes = ( + subprocess.check_output(["sh", "-c", "grep -R socat /proc/[0-9]*/cmdline"]) + .decode("utf-8") + .split("\n") + ) + pids = [process.split("/")[2] for process in socat_processes if process] + if len(pids) < len(ports): + # if we have less than the number of ports socat processes we do not need to count processes per port and can + # fail fast + error("Expected at least %d socat processes" % len(ports)) + port_process_count = {port: 0 for port in ports} + for pid in pids: + # foreach socat pid we detect the port it's for by checking the last argument (connect to) that ends with + # :{ip}:{port} for our processes + try: + with open("/proc/%d/cmdline" % int(pid)) as fp: + # arguments in /proc/.../cmdline are split by null bytes + cmd = [part for part in "".join(fp.readlines()).split("\x00") if part] + port = cmd[2].split(":")[-1] + port_process_count[port] = port_process_count[port] + 1 + except FileNotFoundError: + # ignore processes no longer existing (possibly retrieved an answer) + pass + for port in ports: + if port_process_count[port] == 0: + error("Missing socat process(es) for port: %s" % port) + if port_process_count[port] >= max_connections + 1: + error( + "More than %d + 1 socat process(es) for port: %s" + % (max_connections, port) + ) + + +process_healthcheck() +if os.environ.get("HTTP_HEALTHCHECK", "0") == "1": + http_healthcheck() +if os.environ.get("SMTP_HEALTHCHECK", "0") == "1": + smtp_healthcheck() diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..37df699 --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +set -e +for arg in "$@" ; do + echo arg $arg + if [[ "$arg" == "DEBUG" ]] ; then + DEBUG=1 + else + TEST_FILTER="$arg" + fi +done +DEBUG=${DEBUG:-0} +TEST_FILTER=${TEST_FILTER:-} + +function cleanup() { + if [[ $DEBUG == 1 ]]; then + docker-compose -f tests/test.yaml ps + docker-compose -f tests/test.yaml exec -T proxy_preresolve /usr/local/bin/healthcheck || true + docker-compose -f tests/test.yaml exec -T proxy_without_preresolve /usr/local/bin/healthcheck || true + docker-compose -f tests/test.yaml top + docker-compose -f tests/test.yaml logs + fi + docker-compose -f tests/test.yaml down -v --remove-orphans +} +trap cleanup EXIT + +function with_prefix() { + local prefix + prefix="$1" + shift + "$@" 2>&1 | while read -r line; do + echo "$prefix" "$line" + done + return "${PIPESTATUS[0]}" +} + +function run_tests() { + for service in $(docker-compose -f tests/test.yaml config --services); do + if [[ ( $service == test_* || ( $DEBUG = 1 && $service == debug_* ) ) && $service == *"$TEST_FILTER"* ]] ; then + echo "running $service" + with_prefix "$service:" docker-compose -f tests/test.yaml run --rm "$service" + fi + done +} + +function change_target_ips() { + for target in "target" "target_smtp"; do + #spin up a second target and remove the first target container to give it a new ip (simulates a new deployment of an external cloud service) + local target_container_id + target_container_id=$(docker-compose -f tests/test.yaml ps -q "$target") + if [[ "$target_container_id" != "" ]] ; then + if [[ $DEBUG == 1 ]] ; then + docker inspect "$target_container_id" | grep '"IPAddress": "[^"]\+' + fi + docker-compose -f tests/test.yaml up -d --scale "$target=2" "$target" + docker stop "$target_container_id" | xargs echo "stopped ${target}_1" + docker rm "$target_container_id" | xargs echo "removed ${target}_1" + if [[ $DEBUG == 1 ]] ; then + target_container_id=$(docker-compose -f tests/test.yaml ps -q "$target") + docker inspect "$target_container_id" | grep '"IPAddress": "[^"]\+' + fi + fi + done + # give docker some time to restart unhealthy containers + sleep 5 +} + +with_prefix "build:" docker-compose -f tests/test.yaml build + +# make sure all tests pass when target is up +run_tests + +# when target changes ip +with_prefix "changing target_ip:" change_target_ips + +# all tests still should pass +run_tests diff --git a/tests/test.yaml b/tests/test.yaml new file mode 100644 index 0000000..791eda9 --- /dev/null +++ b/tests/test.yaml @@ -0,0 +1,152 @@ +version: "3.8" +services: + autoheal: + image: willfarrell/autoheal + restart: unless-stopped + environment: + AUTOHEAL_INTERVAL: 1 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + + proxy_preresolve: + build: + dockerfile: Dockerfile + context: .. + labels: + autoheal: "true" + depends_on: + - target + - autoheal + networks: + default: + aliases: + - target_preresolve.example.com + simulated_outside: + environment: + TARGET: target.example.com + PRE_RESOLVE: 1 + NAMESERVERS: "127.0.0.11" #use local docker nameserver + HTTP_HEALTHCHECK: 1 + healthcheck: + test: ["CMD", "healthcheck"] + interval: 1s + timeout: 1s + retries: 0 + start_period: 1s + restart: unless-stopped + + proxy_without_preresolve: + build: + dockerfile: Dockerfile + context: .. + labels: + autoheal: "true" + depends_on: + - target + - autoheal + networks: + default: + aliases: + - target_without_preresolve.example.com + simulated_outside: + environment: + TARGET: target.example.com + # use no pre resolving (target gets resolved on every request) + PRE_RESOLVE: 0 + NAMESERVERS: "127.0.0.11" #use local docker nameserver + HTTP_HEALTHCHECK: 1 + healthcheck: + test: ["CMD", "healthcheck"] + interval: 1s + timeout: 1s + retries: 0 + start_period: 1s + restart: unless-stopped + + proxy_smtp: + build: + dockerfile: Dockerfile + context: .. + labels: + autoheal: "true" + depends_on: + - target_smtp + - autoheal + networks: + default: + aliases: + - target_smtp.example.com + simulated_outside: + environment: + TARGET: smtp.example.com + PORT: 1025 + PRE_RESOLVE: 1 + NAMESERVERS: "127.0.0.11" #use local docker nameserver + SMTP_HEALTHCHECK: 1 + SMTP_HEALTHCHECK_URL: "smtp://$$TARGET:1025/" + # mailhog doesn't support HELP command + SMTP_HEALTHCHECK_COMMAND: "QUIT" + healthcheck: + test: ["CMD", "healthcheck"] + interval: 1s + timeout: 1s + retries: 0 + start_period: 1s + restart: unless-stopped + + target: + image: nginx + networks: + simulated_outside: + aliases: + - target.example.com + + target_smtp: + image: mailhog/mailhog + networks: + simulated_outside: + aliases: + - smtp.example.com + + test_ping: + image: bash + depends_on: + - proxy_preresolve + - proxy_without_preresolve + # ping all proxies (to make sure it is supported) + command: + bash -c 'ping -c 1 target_preresolve.example.com && ping -c 1 + target_without_preresolve.example.com' + + test_wait: + image: bash + depends_on: + - proxy_preresolve + # wait 5 seconds (default dns timeout for proxies) + command: timeout 10 sleep 5 + + test_proxy_preresolve: + image: curlimages/curl + depends_on: + - proxy_preresolve + command: timeout 10 curl -v 'target_preresolve.example.com' + + test_proxy_without_preresolve: + image: curlimages/curl + depends_on: + - proxy_without_preresolve + command: timeout 10 curl -v 'target_without_preresolve.example.com' + + test_proxy_smtp: + image: curlimages/curl + depends_on: + - proxy_smtp + # -X QUIT because mailhog doesn't support HELP + command: timeout 10 curl -v 'smtp://target_smtp.example.com:1025' -X QUIT + +networks: + # we do not allow communication to the outside + simulated_outside: + internal: true + default: + internal: true diff --git a/tests/test_healthcheck.sh b/tests/test_healthcheck.sh new file mode 100755 index 0000000..73ea79b --- /dev/null +++ b/tests/test_healthcheck.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +docker-compose -f tests/test.yaml build proxy_preresolve +docker-compose -f tests/test.yaml up -d proxy_preresolve +docker-compose -f tests/test.yaml exec proxy_preresolve /usr/local/bin/healthcheck +docker-compose -f tests/test.yaml stop target +# healthcheck should fail if target is stopped +! docker-compose -f tests/test.yaml exec proxy_preresolve /usr/local/bin/healthcheck From 30a787c0b0fa4e35f91fc7d9bf5a5f5d27b93588 Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Thu, 8 Jul 2021 15:52:11 +0200 Subject: [PATCH 2/6] [IMP] move tests for healtcheck to pytest --- tests/{test.yaml => healthcheck.yaml} | 43 +------ tests/run_tests.sh | 76 ------------ tests/test_healtcheck.py | 168 ++++++++++++++++++++++++++ tests/test_healthcheck.sh | 9 -- 4 files changed, 172 insertions(+), 124 deletions(-) rename tests/{test.yaml => healthcheck.yaml} (70%) delete mode 100755 tests/run_tests.sh create mode 100644 tests/test_healtcheck.py delete mode 100755 tests/test_healthcheck.sh diff --git a/tests/test.yaml b/tests/healthcheck.yaml similarity index 70% rename from tests/test.yaml rename to tests/healthcheck.yaml index 791eda9..6f38e7c 100644 --- a/tests/test.yaml +++ b/tests/healthcheck.yaml @@ -5,6 +5,7 @@ services: restart: unless-stopped environment: AUTOHEAL_INTERVAL: 1 + AUTOHEAL_CONTAINER_LABEL: "AUTOHEAL_${COMPOSE_PROJECT_NAME}" volumes: - /var/run/docker.sock:/var/run/docker.sock @@ -13,7 +14,7 @@ services: dockerfile: Dockerfile context: .. labels: - autoheal: "true" + - "AUTOHEAL_${COMPOSE_PROJECT_NAME}=true" depends_on: - target - autoheal @@ -40,7 +41,7 @@ services: dockerfile: Dockerfile context: .. labels: - autoheal: "true" + - "AUTOHEAL_${COMPOSE_PROJECT_NAME}=true" depends_on: - target - autoheal @@ -68,7 +69,7 @@ services: dockerfile: Dockerfile context: .. labels: - autoheal: "true" + - "AUTOHEAL_${COMPOSE_PROJECT_NAME}=true" depends_on: - target_smtp - autoheal @@ -108,42 +109,6 @@ services: aliases: - smtp.example.com - test_ping: - image: bash - depends_on: - - proxy_preresolve - - proxy_without_preresolve - # ping all proxies (to make sure it is supported) - command: - bash -c 'ping -c 1 target_preresolve.example.com && ping -c 1 - target_without_preresolve.example.com' - - test_wait: - image: bash - depends_on: - - proxy_preresolve - # wait 5 seconds (default dns timeout for proxies) - command: timeout 10 sleep 5 - - test_proxy_preresolve: - image: curlimages/curl - depends_on: - - proxy_preresolve - command: timeout 10 curl -v 'target_preresolve.example.com' - - test_proxy_without_preresolve: - image: curlimages/curl - depends_on: - - proxy_without_preresolve - command: timeout 10 curl -v 'target_without_preresolve.example.com' - - test_proxy_smtp: - image: curlimages/curl - depends_on: - - proxy_smtp - # -X QUIT because mailhog doesn't support HELP - command: timeout 10 curl -v 'smtp://target_smtp.example.com:1025' -X QUIT - networks: # we do not allow communication to the outside simulated_outside: diff --git a/tests/run_tests.sh b/tests/run_tests.sh deleted file mode 100755 index 37df699..0000000 --- a/tests/run_tests.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env bash -set -e -for arg in "$@" ; do - echo arg $arg - if [[ "$arg" == "DEBUG" ]] ; then - DEBUG=1 - else - TEST_FILTER="$arg" - fi -done -DEBUG=${DEBUG:-0} -TEST_FILTER=${TEST_FILTER:-} - -function cleanup() { - if [[ $DEBUG == 1 ]]; then - docker-compose -f tests/test.yaml ps - docker-compose -f tests/test.yaml exec -T proxy_preresolve /usr/local/bin/healthcheck || true - docker-compose -f tests/test.yaml exec -T proxy_without_preresolve /usr/local/bin/healthcheck || true - docker-compose -f tests/test.yaml top - docker-compose -f tests/test.yaml logs - fi - docker-compose -f tests/test.yaml down -v --remove-orphans -} -trap cleanup EXIT - -function with_prefix() { - local prefix - prefix="$1" - shift - "$@" 2>&1 | while read -r line; do - echo "$prefix" "$line" - done - return "${PIPESTATUS[0]}" -} - -function run_tests() { - for service in $(docker-compose -f tests/test.yaml config --services); do - if [[ ( $service == test_* || ( $DEBUG = 1 && $service == debug_* ) ) && $service == *"$TEST_FILTER"* ]] ; then - echo "running $service" - with_prefix "$service:" docker-compose -f tests/test.yaml run --rm "$service" - fi - done -} - -function change_target_ips() { - for target in "target" "target_smtp"; do - #spin up a second target and remove the first target container to give it a new ip (simulates a new deployment of an external cloud service) - local target_container_id - target_container_id=$(docker-compose -f tests/test.yaml ps -q "$target") - if [[ "$target_container_id" != "" ]] ; then - if [[ $DEBUG == 1 ]] ; then - docker inspect "$target_container_id" | grep '"IPAddress": "[^"]\+' - fi - docker-compose -f tests/test.yaml up -d --scale "$target=2" "$target" - docker stop "$target_container_id" | xargs echo "stopped ${target}_1" - docker rm "$target_container_id" | xargs echo "removed ${target}_1" - if [[ $DEBUG == 1 ]] ; then - target_container_id=$(docker-compose -f tests/test.yaml ps -q "$target") - docker inspect "$target_container_id" | grep '"IPAddress": "[^"]\+' - fi - fi - done - # give docker some time to restart unhealthy containers - sleep 5 -} - -with_prefix "build:" docker-compose -f tests/test.yaml build - -# make sure all tests pass when target is up -run_tests - -# when target changes ip -with_prefix "changing target_ip:" change_target_ips - -# all tests still should pass -run_tests diff --git a/tests/test_healtcheck.py b/tests/test_healtcheck.py new file mode 100644 index 0000000..d3a9e01 --- /dev/null +++ b/tests/test_healtcheck.py @@ -0,0 +1,168 @@ +import hashlib +import json +import logging +import os.path +from time import sleep + +import plumbum.commands.processes +import pytest +from plumbum import local +from plumbum.cmd import docker, docker_compose + +HEALTHCHECK_YAML = os.path.abspath("tests/healthcheck.yaml") + +PROXY_TARGET_PAIRS = [ + ("proxy_preresolve", "target"), + ("proxy_smtp", "target_smtp"), + ("proxy_without_preresolve", "target"), +] + +logger = logging.getLogger() + +_healthcheck = docker_compose["-f", HEALTHCHECK_YAML] +_get_container_id = _healthcheck["ps", "-q"] + + +def _get_container_id_and_ip(service_name): + container_id = _get_container_id(service_name).strip() + container_info = json.loads(docker("inspect", container_id)) + return ( + container_id, + container_info[0]["NetworkSettings"]["Networks"][ + "%s_simulated_outside" % local.env["COMPOSE_PROJECT_NAME"] + ]["IPAddress"], + ) + + +def _new_ip(target): + # we get the container id of the currently running target to be able to force changing ips by scaling up + # and then stopping the old container + old_container_id, old_ip = _get_container_id_and_ip(target) + + # start a second instance of the target + _healthcheck("up", "-d", "--scale", "%s=2" % target, target) + + # stop and remove the old container + docker("stop", old_container_id) + docker("rm", old_container_id) + + # verify that we got a new ip (should not be able to reuse the old one) + new_container_id, new_ip = _get_container_id_and_ip(target) + assert old_container_id != new_container_id + assert old_ip != new_ip + + +def _wait_for(proxy, message, callback, *args): + try: + while message not in callback(*args): + # try again in one second (to not hammer the CPU) + sleep(1) + except Exception: + # add additional infos to any error to make tracing down the error easier + logger.error("failed waiting for '%s'" % message) + logger.error(_healthcheck("logs", "autoheal")) + logger.error(_healthcheck("ps")) + logger.error(_healthcheck("exec", "-T", proxy, "healthcheck", retcode=None)) + raise + + +def _sha256(text): + return hashlib.sha256(str(text).encode("utf-8")).hexdigest() + + +@pytest.fixture(scope="function", autouse=True) +def _cleanup_docker_compose(tmp_path): + with local.cwd(tmp_path): + custom_compose_project_name = "{}_{}".format( + os.path.basename(tmp_path), _sha256(tmp_path)[:6] + ) + with local.env(COMPOSE_PROJECT_NAME=custom_compose_project_name) as env: + yield env + + # stop autoheal first to prevent it from restarting containers to be stopped + _healthcheck("stop", "autoheal") + _healthcheck("down", "-v") + + +@pytest.mark.parametrize("proxy,target", PROXY_TARGET_PAIRS) +def test_healthcheck_ok(proxy, target): + # given a started proxy with healthcheck + _healthcheck("up", "-d", proxy) + + # when everything is ok and target is Up + assert "Up" in _healthcheck("ps", target) + + # then healthcheck should be successful + _healthcheck("exec", "-T", proxy, "healthcheck") + + +@pytest.mark.parametrize("proxy,target", PROXY_TARGET_PAIRS) +def test_healthcheck_failing(proxy, target): + # given a started proxy with healthcheck + _healthcheck("up", "-d", proxy) + + # when target is not reachable + _healthcheck("stop", target) + assert " Exit " in _healthcheck("ps", target) + + # then healthcheck should return an error (non zero exit code) + with pytest.raises( + plumbum.commands.processes.ProcessExecutionError, + match=r"Unexpected exit code: (1|137)", + ): + _healthcheck("exec", "-T", proxy, "healthcheck") + + +@pytest.mark.parametrize( + "proxy,target", + (p for p in PROXY_TARGET_PAIRS if p[0] != "proxy_without_preresolve"), +) +@pytest.mark.timeout(60) +def test_healthcheck_autoheal(proxy, target): + # given a started proxy with healthcheck + _healthcheck("up", "-d", proxy) + proxy_container_id = _get_container_id(proxy).strip() + # that was healthy + _wait_for(proxy, "Up (healthy)", _healthcheck, "ps", proxy) + + # when target gets a new ip + _new_ip(target) + + # then autoheal should restart the proxy + _wait_for( + proxy, + "(%s) found to be unhealthy - Restarting container now" + % proxy_container_id[:12], + _healthcheck, + "logs", + "autoheal", + ) + + # and the proxy should become healthy + _wait_for(proxy, "Up (healthy)", _healthcheck, "ps", proxy) + + # and healthcheck should be successful + _healthcheck("exec", "-T", proxy, "healthcheck") + + +def test_healthcheck_autoheal_proxy_without_preresolve(): + # given a started proxy with healthcheck + proxy = "proxy_without_preresolve" + _healthcheck("up", "-d", proxy) + # that was healthy + _wait_for(proxy, "Up (healthy)", _healthcheck, "ps", proxy) + + # when target gets a new ip + _new_ip("target") + + # then healthcheck should be always successful (we wait just for 5 seconds/healthchecks) + for _ in range(0, 5): + _healthcheck("exec", "-T", proxy, "healthcheck") + sleep(1) + + # and autoheal shouldn't have restarted anything + assert not [ + line + for line in _healthcheck("logs", "autoheal").split("\n") + if line and not line.startswith("Attaching to ") + ] diff --git a/tests/test_healthcheck.sh b/tests/test_healthcheck.sh deleted file mode 100755 index 73ea79b..0000000 --- a/tests/test_healthcheck.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -e - -docker-compose -f tests/test.yaml build proxy_preresolve -docker-compose -f tests/test.yaml up -d proxy_preresolve -docker-compose -f tests/test.yaml exec proxy_preresolve /usr/local/bin/healthcheck -docker-compose -f tests/test.yaml stop target -# healthcheck should fail if target is stopped -! docker-compose -f tests/test.yaml exec proxy_preresolve /usr/local/bin/healthcheck From cb4f2c6b7fc8941a308942a7e6ae892733f05ac7 Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Mon, 12 Jul 2021 09:53:58 +0200 Subject: [PATCH 3/6] [FIX] enable starting autoheal privileged for SELinux --- tests/healthcheck.yaml | 1 + tests/test_healtcheck.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/healthcheck.yaml b/tests/healthcheck.yaml index 6f38e7c..0552a6c 100644 --- a/tests/healthcheck.yaml +++ b/tests/healthcheck.yaml @@ -6,6 +6,7 @@ services: environment: AUTOHEAL_INTERVAL: 1 AUTOHEAL_CONTAINER_LABEL: "AUTOHEAL_${COMPOSE_PROJECT_NAME}" + privileged: "${OS_NEEDS_PRIVILEGES_FOR_DOCKER_SOCK:-false}" volumes: - /var/run/docker.sock:/var/run/docker.sock diff --git a/tests/test_healtcheck.py b/tests/test_healtcheck.py index d3a9e01..57d3ad7 100644 --- a/tests/test_healtcheck.py +++ b/tests/test_healtcheck.py @@ -6,8 +6,8 @@ import plumbum.commands.processes import pytest -from plumbum import local -from plumbum.cmd import docker, docker_compose +from plumbum import TF, local +from plumbum.cmd import docker, docker_compose, which HEALTHCHECK_YAML = os.path.abspath("tests/healthcheck.yaml") @@ -70,13 +70,25 @@ def _sha256(text): return hashlib.sha256(str(text).encode("utf-8")).hexdigest() +@pytest.fixture(scope="session") +def os_needs_privileges(): + if which["getenforce"] & TF: + # if we can find getenforce on the current system, SELinux is probably installed and we need to start + # autoheal with privileges + return "true" + return "false" + + @pytest.fixture(scope="function", autouse=True) -def _cleanup_docker_compose(tmp_path): +def _cleanup_docker_compose(tmp_path, os_needs_privileges): with local.cwd(tmp_path): custom_compose_project_name = "{}_{}".format( os.path.basename(tmp_path), _sha256(tmp_path)[:6] ) - with local.env(COMPOSE_PROJECT_NAME=custom_compose_project_name) as env: + with local.env( + COMPOSE_PROJECT_NAME=custom_compose_project_name, + OS_NEEDS_PRIVILEGES_FOR_DOCKER_SOCK=os_needs_privileges, + ) as env: yield env # stop autoheal first to prevent it from restarting containers to be stopped From 2507c58cc6f1cbe7d4a1516616eb4049e95bb09c Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Wed, 15 Dec 2021 16:04:25 +0100 Subject: [PATCH 4/6] [IMP] healthcheck: implement timeouts for healthchecks this should help if ports are/become firewalled for healthcheck to be able to mark container as unhealthy --- README.md | 14 + healthcheck.py | 6 + poetry.lock | 631 ++++++++++++++++--------------- pyproject.toml | 1 + tests/healthcheck.yaml | 23 ++ tests/not_responding_tcp_port.py | 31 ++ tests/test_healtcheck.py | 35 ++ 7 files changed, 436 insertions(+), 305 deletions(-) create mode 100755 tests/not_responding_tcp_port.py diff --git a/README.md b/README.md index 5e639e4..0c3a5b2 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,13 @@ Default: `http://$TARGET/` Url to use in [`HTTP_HEALTHCHECK`](#http_healthcheck) if enabled. `$TARGET` gets replaced inside the url by the configured [`TARGET`](#target). +### `HTTP_HEALTHCHECK_TIMEOUT_MS` + +Default: `2000` + +Timeout in milliseconds for http healthcheck. This is used as a timeout for connecting +and receiving an answer. You may end up with twice the time spend. + ### `MODE` Default: `tcp` @@ -143,6 +150,13 @@ Default: `HELP` Enables changing the healthcheck command for servers that do not support `HELP` (e.g. for [MailHog](https://github.com/mailhog/MailHog) you can use `QUIT`) +### `SMTP_HEALTHCHECK_TIMEOUT_MS` + +Default: `2000` + +Timeout in milliseconds for smtp healthcheck. This is used as a timeout for connecting +and receiving an answer. You may end up with twice the time spend. + ### `UDP_ANSWERS` Default: `1` diff --git a/healthcheck.py b/healthcheck.py index 5ac8470..69e0e7e 100755 --- a/healthcheck.py +++ b/healthcheck.py @@ -25,6 +25,7 @@ def http_healthcheck(): import pycurl check_url = os.environ.get("HTTP_HEALTHCHECK_URL", "http://localhost/") + check_timeout_ms = int(os.environ.get("HTTP_HEALTHCHECK_TIMEOUT_MS", 2000)) target = os.environ.get("TARGET", "localhost") check_url_with_target = check_url.replace("$TARGET", target) port = re.search("https?://[^:]*(?::([^/]+))?", check_url_with_target)[1] or "80" @@ -36,6 +37,8 @@ def http_healthcheck(): # do not send the request to the target directly but use our own socat proxy process to check if it's still # working request.setopt(pycurl.RESOLVE, ["{}:{}:127.0.0.1".format(target, port)]) + request.setopt(pycurl.CONNECTTIMEOUT_MS, check_timeout_ms) + request.setopt(pycurl.TIMEOUT_MS, check_timeout_ms) request.perform() request.close() except pycurl.error as e: @@ -53,6 +56,7 @@ def smtp_healthcheck(): check_url = os.environ.get("SMTP_HEALTHCHECK_URL", "smtp://localhost/") check_command = os.environ.get("SMTP_HEALTHCHECK_COMMAND", "HELP") + check_timeout_ms = int(os.environ.get("SMTP_HEALTHCHECK_TIMEOUT_MS", 2000)) target = os.environ.get("TARGET", "localhost") check_url_with_target = check_url.replace("$TARGET", target) port = re.search("smtp://[^:]*(?::([^/]+))?", check_url_with_target)[1] or "25" @@ -64,6 +68,8 @@ def smtp_healthcheck(): # do not send the request to the target directly but use our own socat proxy process to check if it's still # working request.setopt(pycurl.RESOLVE, ["{}:{}:127.0.0.1".format(target, port)]) + request.setopt(pycurl.CONNECTTIMEOUT_MS, check_timeout_ms) + request.setopt(pycurl.TIMEOUT_MS, check_timeout_ms) request.perform() request.close() except pycurl.error as e: diff --git a/poetry.lock b/poetry.lock index d1e474c..c1ef8c3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,40 +1,25 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + [[package]] name = "appdirs" version = "1.4.4" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = "*" - -[[package]] -name = "atomicwrites" -version = "1.4.0" -description = "Atomic file writes." -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "attrs" -version = "21.2.0" -description = "Classes Without Boilerplate" -category = "dev" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" - -[package.extras] -dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit"] -docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] -tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface"] -tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins"] +files = [ + {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, + {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, +] [[package]] name = "black" version = "20.8b1" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.6" +files = [ + {file = "black-20.8b1.tar.gz", hash = "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"}, +] [package.dependencies] appdirs = "*" @@ -52,41 +37,67 @@ d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] [[package]] name = "click" -version = "8.0.1" +version = "8.1.7" description = "Composable command line interface toolkit" -category = "dev" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} [[package]] name = "colorama" -version = "0.4.4" +version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.0" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, + {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, +] + +[package.extras] +test = ["pytest (>=6)"] [[package]] name = "execnet" -version = "1.9.0" +version = "2.0.2" description = "execnet: rapid multi-Python deployment" -category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.7" +files = [ + {file = "execnet-2.0.2-py3-none-any.whl", hash = "sha256:88256416ae766bc9e8895c76a87928c0012183da3cc4fc18016e6f050e025f41"}, + {file = "execnet-2.0.2.tar.gz", hash = "sha256:cc59bc4423742fd71ad227122eb0dd44db51efb3dc4095b45ac9a08c770096af"}, +] [package.extras] -testing = ["pre-commit"] +testing = ["hatch", "pre-commit", "pytest", "tox"] [[package]] name = "flake8" version = "3.9.2" description = "the modular source code checker: pep8 pyflakes and co" -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +files = [ + {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"}, + {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"}, +] [package.dependencies] mccabe = ">=0.6.0,<0.7.0" @@ -95,397 +106,407 @@ pyflakes = ">=2.3.0,<2.4.0" [[package]] name = "iniconfig" -version = "1.1.1" -description = "iniconfig: brain-dead simple config-ini parsing" -category = "dev" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" optional = false -python-versions = "*" +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] [[package]] name = "mccabe" version = "0.6.1" description = "McCabe checker, plugin for flake8" -category = "dev" optional = false python-versions = "*" +files = [ + {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, + {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, +] [[package]] name = "mypy-extensions" -version = "0.4.3" -description = "Experimental type system extensions for programs checked with the mypy typechecker." -category = "dev" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." optional = false -python-versions = "*" +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] [[package]] name = "packaging" -version = "21.0" +version = "23.2" description = "Core utilities for Python packages" -category = "dev" optional = false -python-versions = ">=3.6" - -[package.dependencies] -pyparsing = ">=2.0.2" +python-versions = ">=3.7" +files = [ + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, +] [[package]] name = "pathspec" -version = "0.8.1" +version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.8" +files = [ + {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, + {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, +] [[package]] name = "pluggy" -version = "0.13.1" +version = "1.4.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=3.8" +files = [ + {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, + {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, +] [package.extras] dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] [[package]] name = "plumbum" -version = "1.7.0" +version = "1.8.2" description = "Plumbum: shell combinators library" -category = "main" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4,>=2.7" +python-versions = ">=3.6" +files = [ + {file = "plumbum-1.8.2-py3-none-any.whl", hash = "sha256:3ad9e5f56c6ec98f6f7988f7ea8b52159662ea9e915868d369dbccbfca0e367e"}, + {file = "plumbum-1.8.2.tar.gz", hash = "sha256:9e6dc032f4af952665f32f3206567bc23b7858b1413611afe603a3f8ad9bfd75"}, +] [package.dependencies] -pypiwin32 = {version = "*", markers = "platform_system == \"Windows\" and platform_python_implementation != \"PyPy\""} +pywin32 = {version = "*", markers = "platform_system == \"Windows\" and platform_python_implementation != \"PyPy\""} [package.extras] -dev = ["pytest", "pytest-cov", "pytest-mock", "pytest-timeout", "paramiko", "psutil"] -docs = ["recommonmark (>=0.5.0)", "Sphinx (>=3.0.0)", "sphinx-rtd-theme (>=0.5.0)"] +dev = ["paramiko", "psutil", "pytest (>=6.0)", "pytest-cov", "pytest-mock", "pytest-timeout"] +docs = ["sphinx (>=4.0.0)", "sphinx-rtd-theme (>=1.0.0)"] ssh = ["paramiko"] [[package]] name = "py" -version = "1.10.0" +version = "1.11.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] [[package]] name = "pycodestyle" version = "2.7.0" description = "Python style guide checker" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"}, + {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, +] [[package]] name = "pyflakes" version = "2.3.1" description = "passive checker of Python programs" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" - -[[package]] -name = "pyparsing" -version = "2.4.7" -description = "Python parsing module" -category = "dev" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" - -[[package]] -name = "pypiwin32" -version = "223" -description = "" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -pywin32 = ">=223" +files = [ + {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"}, + {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"}, +] [[package]] name = "pytest" -version = "6.2.4" +version = "8.0.0" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" +files = [ + {file = "pytest-8.0.0-py3-none-any.whl", hash = "sha256:50fb9cbe836c3f20f0dfa99c565201fb75dc54c8d76373cd1bde06b06657bdb6"}, + {file = "pytest-8.0.0.tar.gz", hash = "sha256:249b1b0864530ba251b7438274c4d251c58d868edaaec8762893ad4a0d71c36c"}, +] [package.dependencies] -atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} -attrs = ">=19.2.0" colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<1.0.0a1" -py = ">=1.8.2" -toml = "*" +pluggy = ">=1.3.0,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-forked" -version = "1.3.0" +version = "1.6.0" description = "run tests in isolated forked subprocesses" -category = "dev" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.7" +files = [ + {file = "pytest-forked-1.6.0.tar.gz", hash = "sha256:4dafd46a9a600f65d822b8f605133ecf5b3e1941ebb3588e943b4e3eb71a5a3f"}, + {file = "pytest_forked-1.6.0-py3-none-any.whl", hash = "sha256:810958f66a91afb1a1e2ae83089d8dc1cd2437ac96b12963042fbb9fb4d16af0"}, +] [package.dependencies] py = "*" pytest = ">=3.10" +[[package]] +name = "pytest-timeout" +version = "2.2.0" +description = "pytest plugin to abort hanging tests" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-timeout-2.2.0.tar.gz", hash = "sha256:3b0b95dabf3cb50bac9ef5ca912fa0cfc286526af17afc806824df20c2f72c90"}, + {file = "pytest_timeout-2.2.0-py3-none-any.whl", hash = "sha256:bde531e096466f49398a59f2dde76fa78429a09a12411466f88a07213e220de2"}, +] + +[package.dependencies] +pytest = ">=5.0.0" + [[package]] name = "pytest-xdist" -version = "2.3.0" +version = "2.5.0" description = "pytest xdist plugin for distributed testing and loop-on-failing modes" -category = "dev" optional = false python-versions = ">=3.6" +files = [ + {file = "pytest-xdist-2.5.0.tar.gz", hash = "sha256:4580deca3ff04ddb2ac53eba39d76cb5dd5edeac050cb6fbc768b0dd712b4edf"}, + {file = "pytest_xdist-2.5.0-py3-none-any.whl", hash = "sha256:6fe5c74fec98906deb8f2d2b616b5c782022744978e7bd4695d39c8f42d0ce65"}, +] [package.dependencies] execnet = ">=1.1" -pytest = ">=6.0.0" +pytest = ">=6.2.0" pytest-forked = "*" [package.extras] psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] testing = ["filelock"] [[package]] name = "pywin32" -version = "301" +version = "306" description = "Python for Window Extensions" -category = "main" optional = false python-versions = "*" +files = [ + {file = "pywin32-306-cp310-cp310-win32.whl", hash = "sha256:06d3420a5155ba65f0b72f2699b5bacf3109f36acbe8923765c22938a69dfc8d"}, + {file = "pywin32-306-cp310-cp310-win_amd64.whl", hash = "sha256:84f4471dbca1887ea3803d8848a1616429ac94a4a8d05f4bc9c5dcfd42ca99c8"}, + {file = "pywin32-306-cp311-cp311-win32.whl", hash = "sha256:e65028133d15b64d2ed8f06dd9fbc268352478d4f9289e69c190ecd6818b6407"}, + {file = "pywin32-306-cp311-cp311-win_amd64.whl", hash = "sha256:a7639f51c184c0272e93f244eb24dafca9b1855707d94c192d4a0b4c01e1100e"}, + {file = "pywin32-306-cp311-cp311-win_arm64.whl", hash = "sha256:70dba0c913d19f942a2db25217d9a1b726c278f483a919f1abfed79c9cf64d3a"}, + {file = "pywin32-306-cp312-cp312-win32.whl", hash = "sha256:383229d515657f4e3ed1343da8be101000562bf514591ff383ae940cad65458b"}, + {file = "pywin32-306-cp312-cp312-win_amd64.whl", hash = "sha256:37257794c1ad39ee9be652da0462dc2e394c8159dfd913a8a4e8eb6fd346da0e"}, + {file = "pywin32-306-cp312-cp312-win_arm64.whl", hash = "sha256:5821ec52f6d321aa59e2db7e0a35b997de60c201943557d108af9d4ae1ec7040"}, + {file = "pywin32-306-cp37-cp37m-win32.whl", hash = "sha256:1c73ea9a0d2283d889001998059f5eaaba3b6238f767c9cf2833b13e6a685f65"}, + {file = "pywin32-306-cp37-cp37m-win_amd64.whl", hash = "sha256:72c5f621542d7bdd4fdb716227be0dd3f8565c11b280be6315b06ace35487d36"}, + {file = "pywin32-306-cp38-cp38-win32.whl", hash = "sha256:e4c092e2589b5cf0d365849e73e02c391c1349958c5ac3e9d5ccb9a28e017b3a"}, + {file = "pywin32-306-cp38-cp38-win_amd64.whl", hash = "sha256:e8ac1ae3601bee6ca9f7cb4b5363bf1c0badb935ef243c4733ff9a393b1690c0"}, + {file = "pywin32-306-cp39-cp39-win32.whl", hash = "sha256:e25fd5b485b55ac9c057f67d94bc203f3f6595078d1fb3b458c9c28b7153a802"}, + {file = "pywin32-306-cp39-cp39-win_amd64.whl", hash = "sha256:39b61c15272833b5c329a2989999dcae836b1eed650252ab1b7bfbe1d59f30f4"}, +] [[package]] name = "regex" -version = "2021.7.6" +version = "2023.12.25" description = "Alternative regular expression module, to replace re." -category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.7" +files = [ + {file = "regex-2023.12.25-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0694219a1d54336fd0445ea382d49d36882415c0134ee1e8332afd1529f0baa5"}, + {file = "regex-2023.12.25-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b014333bd0217ad3d54c143de9d4b9a3ca1c5a29a6d0d554952ea071cff0f1f8"}, + {file = "regex-2023.12.25-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d865984b3f71f6d0af64d0d88f5733521698f6c16f445bb09ce746c92c97c586"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e0eabac536b4cc7f57a5f3d095bfa557860ab912f25965e08fe1545e2ed8b4c"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c25a8ad70e716f96e13a637802813f65d8a6760ef48672aa3502f4c24ea8b400"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a9b6d73353f777630626f403b0652055ebfe8ff142a44ec2cf18ae470395766e"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9cc99d6946d750eb75827cb53c4371b8b0fe89c733a94b1573c9dd16ea6c9e4"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88d1f7bef20c721359d8675f7d9f8e414ec5003d8f642fdfd8087777ff7f94b5"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cb3fe77aec8f1995611f966d0c656fdce398317f850d0e6e7aebdfe61f40e1cd"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7aa47c2e9ea33a4a2a05f40fcd3ea36d73853a2aae7b4feab6fc85f8bf2c9704"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:df26481f0c7a3f8739fecb3e81bc9da3fcfae34d6c094563b9d4670b047312e1"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:c40281f7d70baf6e0db0c2f7472b31609f5bc2748fe7275ea65a0b4601d9b392"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:d94a1db462d5690ebf6ae86d11c5e420042b9898af5dcf278bd97d6bda065423"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ba1b30765a55acf15dce3f364e4928b80858fa8f979ad41f862358939bdd1f2f"}, + {file = "regex-2023.12.25-cp310-cp310-win32.whl", hash = "sha256:150c39f5b964e4d7dba46a7962a088fbc91f06e606f023ce57bb347a3b2d4630"}, + {file = "regex-2023.12.25-cp310-cp310-win_amd64.whl", hash = "sha256:09da66917262d9481c719599116c7dc0c321ffcec4b1f510c4f8a066f8768105"}, + {file = "regex-2023.12.25-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:1b9d811f72210fa9306aeb88385b8f8bcef0dfbf3873410413c00aa94c56c2b6"}, + {file = "regex-2023.12.25-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d902a43085a308cef32c0d3aea962524b725403fd9373dea18110904003bac97"}, + {file = "regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d166eafc19f4718df38887b2bbe1467a4f74a9830e8605089ea7a30dd4da8887"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7ad32824b7f02bb3c9f80306d405a1d9b7bb89362d68b3c5a9be53836caebdb"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:636ba0a77de609d6510235b7f0e77ec494d2657108f777e8765efc060094c98c"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fda75704357805eb953a3ee15a2b240694a9a514548cd49b3c5124b4e2ad01b"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f72cbae7f6b01591f90814250e636065850c5926751af02bb48da94dfced7baa"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:db2a0b1857f18b11e3b0e54ddfefc96af46b0896fb678c85f63fb8c37518b3e7"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:7502534e55c7c36c0978c91ba6f61703faf7ce733715ca48f499d3dbbd7657e0"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:e8c7e08bb566de4faaf11984af13f6bcf6a08f327b13631d41d62592681d24fe"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:283fc8eed679758de38fe493b7d7d84a198b558942b03f017b1f94dda8efae80"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:f44dd4d68697559d007462b0a3a1d9acd61d97072b71f6d1968daef26bc744bd"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:67d3ccfc590e5e7197750fcb3a2915b416a53e2de847a728cfa60141054123d4"}, + {file = "regex-2023.12.25-cp311-cp311-win32.whl", hash = "sha256:68191f80a9bad283432385961d9efe09d783bcd36ed35a60fb1ff3f1ec2efe87"}, + {file = "regex-2023.12.25-cp311-cp311-win_amd64.whl", hash = "sha256:7d2af3f6b8419661a0c421584cfe8aaec1c0e435ce7e47ee2a97e344b98f794f"}, + {file = "regex-2023.12.25-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:8a0ccf52bb37d1a700375a6b395bff5dd15c50acb745f7db30415bae3c2b0715"}, + {file = "regex-2023.12.25-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c3c4a78615b7762740531c27cf46e2f388d8d727d0c0c739e72048beb26c8a9d"}, + {file = "regex-2023.12.25-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ad83e7545b4ab69216cef4cc47e344d19622e28aabec61574b20257c65466d6a"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7a635871143661feccce3979e1727c4e094f2bdfd3ec4b90dfd4f16f571a87a"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d498eea3f581fbe1b34b59c697512a8baef88212f92e4c7830fcc1499f5b45a5"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:43f7cd5754d02a56ae4ebb91b33461dc67be8e3e0153f593c509e21d219c5060"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:51f4b32f793812714fd5307222a7f77e739b9bc566dc94a18126aba3b92b98a3"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba99d8077424501b9616b43a2d208095746fb1284fc5ba490139651f971d39d9"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:4bfc2b16e3ba8850e0e262467275dd4d62f0d045e0e9eda2bc65078c0110a11f"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8c2c19dae8a3eb0ea45a8448356ed561be843b13cbc34b840922ddf565498c1c"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:60080bb3d8617d96f0fb7e19796384cc2467447ef1c491694850ebd3670bc457"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b77e27b79448e34c2c51c09836033056a0547aa360c45eeeb67803da7b0eedaf"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:518440c991f514331f4850a63560321f833979d145d7d81186dbe2f19e27ae3d"}, + {file = "regex-2023.12.25-cp312-cp312-win32.whl", hash = "sha256:e2610e9406d3b0073636a3a2e80db05a02f0c3169b5632022b4e81c0364bcda5"}, + {file = "regex-2023.12.25-cp312-cp312-win_amd64.whl", hash = "sha256:cc37b9aeebab425f11f27e5e9e6cf580be7206c6582a64467a14dda211abc232"}, + {file = "regex-2023.12.25-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:da695d75ac97cb1cd725adac136d25ca687da4536154cdc2815f576e4da11c69"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d126361607b33c4eb7b36debc173bf25d7805847346dd4d99b5499e1fef52bc7"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4719bb05094d7d8563a450cf8738d2e1061420f79cfcc1fa7f0a44744c4d8f73"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5dd58946bce44b53b06d94aa95560d0b243eb2fe64227cba50017a8d8b3cd3e2"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22a86d9fff2009302c440b9d799ef2fe322416d2d58fc124b926aa89365ec482"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2aae8101919e8aa05ecfe6322b278f41ce2994c4a430303c4cd163fef746e04f"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e692296c4cc2873967771345a876bcfc1c547e8dd695c6b89342488b0ea55cd8"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:263ef5cc10979837f243950637fffb06e8daed7f1ac1e39d5910fd29929e489a"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:d6f7e255e5fa94642a0724e35406e6cb7001c09d476ab5fce002f652b36d0c39"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:88ad44e220e22b63b0f8f81f007e8abbb92874d8ced66f32571ef8beb0643b2b"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:3a17d3ede18f9cedcbe23d2daa8a2cd6f59fe2bf082c567e43083bba3fb00347"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d15b274f9e15b1a0b7a45d2ac86d1f634d983ca40d6b886721626c47a400bf39"}, + {file = "regex-2023.12.25-cp37-cp37m-win32.whl", hash = "sha256:ed19b3a05ae0c97dd8f75a5d8f21f7723a8c33bbc555da6bbe1f96c470139d3c"}, + {file = "regex-2023.12.25-cp37-cp37m-win_amd64.whl", hash = "sha256:a6d1047952c0b8104a1d371f88f4ab62e6275567d4458c1e26e9627ad489b445"}, + {file = "regex-2023.12.25-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b43523d7bc2abd757119dbfb38af91b5735eea45537ec6ec3a5ec3f9562a1c53"}, + {file = "regex-2023.12.25-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:efb2d82f33b2212898f1659fb1c2e9ac30493ac41e4d53123da374c3b5541e64"}, + {file = "regex-2023.12.25-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b7fca9205b59c1a3d5031f7e64ed627a1074730a51c2a80e97653e3e9fa0d415"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:086dd15e9435b393ae06f96ab69ab2d333f5d65cbe65ca5a3ef0ec9564dfe770"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e81469f7d01efed9b53740aedd26085f20d49da65f9c1f41e822a33992cb1590"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:34e4af5b27232f68042aa40a91c3b9bb4da0eeb31b7632e0091afc4310afe6cb"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9852b76ab558e45b20bf1893b59af64a28bd3820b0c2efc80e0a70a4a3ea51c1"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ff100b203092af77d1a5a7abe085b3506b7eaaf9abf65b73b7d6905b6cb76988"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cc038b2d8b1470364b1888a98fd22d616fba2b6309c5b5f181ad4483e0017861"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:094ba386bb5c01e54e14434d4caabf6583334090865b23ef58e0424a6286d3dc"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:5cd05d0f57846d8ba4b71d9c00f6f37d6b97d5e5ef8b3c3840426a475c8f70f4"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:9aa1a67bbf0f957bbe096375887b2505f5d8ae16bf04488e8b0f334c36e31360"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:98a2636994f943b871786c9e82bfe7883ecdaba2ef5df54e1450fa9869d1f756"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:37f8e93a81fc5e5bd8db7e10e62dc64261bcd88f8d7e6640aaebe9bc180d9ce2"}, + {file = "regex-2023.12.25-cp38-cp38-win32.whl", hash = "sha256:d78bd484930c1da2b9679290a41cdb25cc127d783768a0369d6b449e72f88beb"}, + {file = "regex-2023.12.25-cp38-cp38-win_amd64.whl", hash = "sha256:b521dcecebc5b978b447f0f69b5b7f3840eac454862270406a39837ffae4e697"}, + {file = "regex-2023.12.25-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f7bc09bc9c29ebead055bcba136a67378f03d66bf359e87d0f7c759d6d4ffa31"}, + {file = "regex-2023.12.25-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e14b73607d6231f3cc4622809c196b540a6a44e903bcfad940779c80dffa7be7"}, + {file = "regex-2023.12.25-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9eda5f7a50141291beda3edd00abc2d4a5b16c29c92daf8d5bd76934150f3edc"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc6bb9aa69aacf0f6032c307da718f61a40cf970849e471254e0e91c56ffca95"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:298dc6354d414bc921581be85695d18912bea163a8b23cac9a2562bbcd5088b1"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2f4e475a80ecbd15896a976aa0b386c5525d0ed34d5c600b6d3ebac0a67c7ddf"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:531ac6cf22b53e0696f8e1d56ce2396311254eb806111ddd3922c9d937151dae"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22f3470f7524b6da61e2020672df2f3063676aff444db1daa283c2ea4ed259d6"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:89723d2112697feaa320c9d351e5f5e7b841e83f8b143dba8e2d2b5f04e10923"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0ecf44ddf9171cd7566ef1768047f6e66975788258b1c6c6ca78098b95cf9a3d"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:905466ad1702ed4acfd67a902af50b8db1feeb9781436372261808df7a2a7bca"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:4558410b7a5607a645e9804a3e9dd509af12fb72b9825b13791a37cd417d73a5"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:7e316026cc1095f2a3e8cc012822c99f413b702eaa2ca5408a513609488cb62f"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3b1de218d5375cd6ac4b5493e0b9f3df2be331e86520f23382f216c137913d20"}, + {file = "regex-2023.12.25-cp39-cp39-win32.whl", hash = "sha256:11a963f8e25ab5c61348d090bf1b07f1953929c13bd2309a0662e9ff680763c9"}, + {file = "regex-2023.12.25-cp39-cp39-win_amd64.whl", hash = "sha256:e693e233ac92ba83a87024e1d32b5f9ab15ca55ddd916d878146f4e3406b5c91"}, + {file = "regex-2023.12.25.tar.gz", hash = "sha256:29171aa128da69afdf4bde412d5bedc335f2ca8fcfe4489038577d05f16181e5"}, +] [[package]] name = "toml" version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" -category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, + {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] [[package]] name = "typed-ast" -version = "1.4.3" +version = "1.5.5" description = "a fork of Python 2 and 3 ast modules with type comment support" -category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.6" +files = [ + {file = "typed_ast-1.5.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4bc1efe0ce3ffb74784e06460f01a223ac1f6ab31c6bc0376a21184bf5aabe3b"}, + {file = "typed_ast-1.5.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5f7a8c46a8b333f71abd61d7ab9255440d4a588f34a21f126bbfc95f6049e686"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:597fc66b4162f959ee6a96b978c0435bd63791e31e4f410622d19f1686d5e769"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d41b7a686ce653e06c2609075d397ebd5b969d821b9797d029fccd71fdec8e04"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5fe83a9a44c4ce67c796a1b466c270c1272e176603d5e06f6afbc101a572859d"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d5c0c112a74c0e5db2c75882a0adf3133adedcdbfd8cf7c9d6ed77365ab90a1d"}, + {file = "typed_ast-1.5.5-cp310-cp310-win_amd64.whl", hash = "sha256:e1a976ed4cc2d71bb073e1b2a250892a6e968ff02aa14c1f40eba4f365ffec02"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c631da9710271cb67b08bd3f3813b7af7f4c69c319b75475436fcab8c3d21bee"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b445c2abfecab89a932b20bd8261488d574591173d07827c1eda32c457358b18"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc95ffaaab2be3b25eb938779e43f513e0e538a84dd14a5d844b8f2932593d88"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61443214d9b4c660dcf4b5307f15c12cb30bdfe9588ce6158f4a005baeb167b2"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6eb936d107e4d474940469e8ec5b380c9b329b5f08b78282d46baeebd3692dc9"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e48bf27022897577d8479eaed64701ecaf0467182448bd95759883300ca818c8"}, + {file = "typed_ast-1.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:83509f9324011c9a39faaef0922c6f720f9623afe3fe220b6d0b15638247206b"}, + {file = "typed_ast-1.5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44f214394fc1af23ca6d4e9e744804d890045d1643dd7e8229951e0ef39429b5"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:118c1ce46ce58fda78503eae14b7664163aa735b620b64b5b725453696f2a35c"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be4919b808efa61101456e87f2d4c75b228f4e52618621c77f1ddcaae15904fa"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fc2b8c4e1bc5cd96c1a823a885e6b158f8451cf6f5530e1829390b4d27d0807f"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:16f7313e0a08c7de57f2998c85e2a69a642e97cb32f87eb65fbfe88381a5e44d"}, + {file = "typed_ast-1.5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:2b946ef8c04f77230489f75b4b5a4a6f24c078be4aed241cfabe9cbf4156e7e5"}, + {file = "typed_ast-1.5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2188bc33d85951ea4ddad55d2b35598b2709d122c11c75cffd529fbc9965508e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0635900d16ae133cab3b26c607586131269f88266954eb04ec31535c9a12ef1e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57bfc3cf35a0f2fdf0a88a3044aafaec1d2f24d8ae8cd87c4f58d615fb5b6311"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:fe58ef6a764de7b4b36edfc8592641f56e69b7163bba9f9c8089838ee596bfb2"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d09d930c2d1d621f717bb217bf1fe2584616febb5138d9b3e8cdd26506c3f6d4"}, + {file = "typed_ast-1.5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d40c10326893ecab8a80a53039164a224984339b2c32a6baf55ecbd5b1df6431"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fd946abf3c31fb50eee07451a6aedbfff912fcd13cf357363f5b4e834cc5e71a"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ed4a1a42df8a3dfb6b40c3d2de109e935949f2f66b19703eafade03173f8f437"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:045f9930a1550d9352464e5149710d56a2aed23a2ffe78946478f7b5416f1ede"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:381eed9c95484ceef5ced626355fdc0765ab51d8553fec08661dce654a935db4"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:bfd39a41c0ef6f31684daff53befddae608f9daf6957140228a08e51f312d7e6"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8c524eb3024edcc04e288db9541fe1f438f82d281e591c548903d5b77ad1ddd4"}, + {file = "typed_ast-1.5.5-cp38-cp38-win_amd64.whl", hash = "sha256:7f58fabdde8dcbe764cef5e1a7fcb440f2463c1bbbec1cf2a86ca7bc1f95184b"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:042eb665ff6bf020dd2243307d11ed626306b82812aba21836096d229fdc6a10"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:622e4a006472b05cf6ef7f9f2636edc51bda670b7bbffa18d26b255269d3d814"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efebbbf4604ad1283e963e8915daa240cb4bf5067053cf2f0baadc4d4fb51b8"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0aefdd66f1784c58f65b502b6cf8b121544680456d1cebbd300c2c813899274"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:48074261a842acf825af1968cd912f6f21357316080ebaca5f19abbb11690c8a"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:429ae404f69dc94b9361bb62291885894b7c6fb4640d561179548c849f8492ba"}, + {file = "typed_ast-1.5.5-cp39-cp39-win_amd64.whl", hash = "sha256:335f22ccb244da2b5c296e6f96b06ee9bed46526db0de38d2f0e5a6597b81155"}, + {file = "typed_ast-1.5.5.tar.gz", hash = "sha256:94282f7a354f36ef5dbce0ef3467ebf6a258e370ab33d5b40c249fa996e590dd"}, +] [[package]] name = "typing-extensions" -version = "3.10.0.0" -description = "Backported and Experimental Type Hints for Python 3.5+" -category = "dev" +version = "4.9.0" +description = "Backported and Experimental Type Hints for Python 3.8+" optional = false -python-versions = "*" +python-versions = ">=3.8" +files = [ + {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, + {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, +] [metadata] -lock-version = "1.1" +lock-version = "2.0" python-versions = "^3.9" -content-hash = "66b89e0da0e1b44e859a5e03ef20e3be8ce883e223d39be6180ae45bf74533c9" - -[metadata.files] -appdirs = [ - {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, - {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, -] -atomicwrites = [ - {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, - {file = "atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, -] -attrs = [ - {file = "attrs-21.2.0-py2.py3-none-any.whl", hash = "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1"}, - {file = "attrs-21.2.0.tar.gz", hash = "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"}, -] -black = [ - {file = "black-20.8b1.tar.gz", hash = "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"}, -] -click = [ - {file = "click-8.0.1-py3-none-any.whl", hash = "sha256:fba402a4a47334742d782209a7c79bc448911afe1149d07bdabdf480b3e2f4b6"}, - {file = "click-8.0.1.tar.gz", hash = "sha256:8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a"}, -] -colorama = [ - {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, - {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, -] -execnet = [ - {file = "execnet-1.9.0-py2.py3-none-any.whl", hash = "sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142"}, - {file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"}, -] -flake8 = [ - {file = "flake8-3.9.2-py2.py3-none-any.whl", hash = "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907"}, - {file = "flake8-3.9.2.tar.gz", hash = "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b"}, -] -iniconfig = [ - {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, - {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, -] -mccabe = [ - {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, - {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, -] -mypy-extensions = [ - {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, - {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, -] -packaging = [ - {file = "packaging-21.0-py3-none-any.whl", hash = "sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14"}, - {file = "packaging-21.0.tar.gz", hash = "sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7"}, -] -pathspec = [ - {file = "pathspec-0.8.1-py2.py3-none-any.whl", hash = "sha256:aa0cb481c4041bf52ffa7b0d8fa6cd3e88a2ca4879c533c9153882ee2556790d"}, - {file = "pathspec-0.8.1.tar.gz", hash = "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd"}, -] -pluggy = [ - {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, - {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, -] -plumbum = [ - {file = "plumbum-1.7.0-py2.py3-none-any.whl", hash = "sha256:139bbe08ee065b522a8a07d4f7e9f8eddffd78cc218b65b11cca2b33683e6b57"}, - {file = "plumbum-1.7.0.tar.gz", hash = "sha256:317744342c755319907c773cc87c3a30adaa3a41b0d34c0ce02d9d1904922dce"}, -] -py = [ - {file = "py-1.10.0-py2.py3-none-any.whl", hash = "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a"}, - {file = "py-1.10.0.tar.gz", hash = "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3"}, -] -pycodestyle = [ - {file = "pycodestyle-2.7.0-py2.py3-none-any.whl", hash = "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068"}, - {file = "pycodestyle-2.7.0.tar.gz", hash = "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef"}, -] -pyflakes = [ - {file = "pyflakes-2.3.1-py2.py3-none-any.whl", hash = "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3"}, - {file = "pyflakes-2.3.1.tar.gz", hash = "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db"}, -] -pyparsing = [ - {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, - {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, -] -pypiwin32 = [ - {file = "pypiwin32-223-py3-none-any.whl", hash = "sha256:67adf399debc1d5d14dffc1ab5acacb800da569754fafdc576b2a039485aa775"}, - {file = "pypiwin32-223.tar.gz", hash = "sha256:71be40c1fbd28594214ecaecb58e7aa8b708eabfa0125c8a109ebd51edbd776a"}, -] -pytest = [ - {file = "pytest-6.2.4-py3-none-any.whl", hash = "sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890"}, - {file = "pytest-6.2.4.tar.gz", hash = "sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b"}, -] -pytest-forked = [ - {file = "pytest-forked-1.3.0.tar.gz", hash = "sha256:6aa9ac7e00ad1a539c41bec6d21011332de671e938c7637378ec9710204e37ca"}, - {file = "pytest_forked-1.3.0-py2.py3-none-any.whl", hash = "sha256:dc4147784048e70ef5d437951728825a131b81714b398d5d52f17c7c144d8815"}, -] -pytest-xdist = [ - {file = "pytest-xdist-2.3.0.tar.gz", hash = "sha256:e8ecde2f85d88fbcadb7d28cb33da0fa29bca5cf7d5967fa89fc0e97e5299ea5"}, - {file = "pytest_xdist-2.3.0-py3-none-any.whl", hash = "sha256:ed3d7da961070fce2a01818b51f6888327fb88df4379edeb6b9d990e789d9c8d"}, -] -pywin32 = [ - {file = "pywin32-301-cp35-cp35m-win32.whl", hash = "sha256:93367c96e3a76dfe5003d8291ae16454ca7d84bb24d721e0b74a07610b7be4a7"}, - {file = "pywin32-301-cp35-cp35m-win_amd64.whl", hash = "sha256:9635df6998a70282bd36e7ac2a5cef9ead1627b0a63b17c731312c7a0daebb72"}, - {file = "pywin32-301-cp36-cp36m-win32.whl", hash = "sha256:c866f04a182a8cb9b7855de065113bbd2e40524f570db73ef1ee99ff0a5cc2f0"}, - {file = "pywin32-301-cp36-cp36m-win_amd64.whl", hash = "sha256:dafa18e95bf2a92f298fe9c582b0e205aca45c55f989937c52c454ce65b93c78"}, - {file = "pywin32-301-cp37-cp37m-win32.whl", hash = "sha256:98f62a3f60aa64894a290fb7494bfa0bfa0a199e9e052e1ac293b2ad3cd2818b"}, - {file = "pywin32-301-cp37-cp37m-win_amd64.whl", hash = "sha256:fb3b4933e0382ba49305cc6cd3fb18525df7fd96aa434de19ce0878133bf8e4a"}, - {file = "pywin32-301-cp38-cp38-win32.whl", hash = "sha256:88981dd3cfb07432625b180f49bf4e179fb8cbb5704cd512e38dd63636af7a17"}, - {file = "pywin32-301-cp38-cp38-win_amd64.whl", hash = "sha256:8c9d33968aa7fcddf44e47750e18f3d034c3e443a707688a008a2e52bbef7e96"}, - {file = "pywin32-301-cp39-cp39-win32.whl", hash = "sha256:595d397df65f1b2e0beaca63a883ae6d8b6df1cdea85c16ae85f6d2e648133fe"}, - {file = "pywin32-301-cp39-cp39-win_amd64.whl", hash = "sha256:87604a4087434cd814ad8973bd47d6524bd1fa9e971ce428e76b62a5e0860fdf"}, -] -regex = [ - {file = "regex-2021.7.6-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:e6a1e5ca97d411a461041d057348e578dc344ecd2add3555aedba3b408c9f874"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:6afe6a627888c9a6cfbb603d1d017ce204cebd589d66e0703309b8048c3b0854"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:ccb3d2190476d00414aab36cca453e4596e8f70a206e2aa8db3d495a109153d2"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:ed693137a9187052fc46eedfafdcb74e09917166362af4cc4fddc3b31560e93d"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:99d8ab206a5270c1002bfcf25c51bf329ca951e5a169f3b43214fdda1f0b5f0d"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:b85ac458354165405c8a84725de7bbd07b00d9f72c31a60ffbf96bb38d3e25fa"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:3f5716923d3d0bfb27048242a6e0f14eecdb2e2a7fac47eda1d055288595f222"}, - {file = "regex-2021.7.6-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e5983c19d0beb6af88cb4d47afb92d96751fb3fa1784d8785b1cdf14c6519407"}, - {file = "regex-2021.7.6-cp36-cp36m-win32.whl", hash = "sha256:c92831dac113a6e0ab28bc98f33781383fe294df1a2c3dfd1e850114da35fd5b"}, - {file = "regex-2021.7.6-cp36-cp36m-win_amd64.whl", hash = "sha256:791aa1b300e5b6e5d597c37c346fb4d66422178566bbb426dd87eaae475053fb"}, - {file = "regex-2021.7.6-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:59506c6e8bd9306cd8a41511e32d16d5d1194110b8cfe5a11d102d8b63cf945d"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:564a4c8a29435d1f2256ba247a0315325ea63335508ad8ed938a4f14c4116a5d"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:59c00bb8dd8775473cbfb967925ad2c3ecc8886b3b2d0c90a8e2707e06c743f0"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:9a854b916806c7e3b40e6616ac9e85d3cdb7649d9e6590653deb5b341a736cec"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:db2b7df831c3187a37f3bb80ec095f249fa276dbe09abd3d35297fc250385694"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:173bc44ff95bc1e96398c38f3629d86fa72e539c79900283afa895694229fe6a"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:15dddb19823f5147e7517bb12635b3c82e6f2a3a6b696cc3e321522e8b9308ad"}, - {file = "regex-2021.7.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2ddeabc7652024803666ea09f32dd1ed40a0579b6fbb2a213eba590683025895"}, - {file = "regex-2021.7.6-cp37-cp37m-win32.whl", hash = "sha256:f080248b3e029d052bf74a897b9d74cfb7643537fbde97fe8225a6467fb559b5"}, - {file = "regex-2021.7.6-cp37-cp37m-win_amd64.whl", hash = "sha256:d8bbce0c96462dbceaa7ac4a7dfbbee92745b801b24bce10a98d2f2b1ea9432f"}, - {file = "regex-2021.7.6-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:edd1a68f79b89b0c57339bce297ad5d5ffcc6ae7e1afdb10f1947706ed066c9c"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux1_i686.whl", hash = "sha256:422dec1e7cbb2efbbe50e3f1de36b82906def93ed48da12d1714cabcd993d7f0"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:cbe23b323988a04c3e5b0c387fe3f8f363bf06c0680daf775875d979e376bd26"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:0eb2c6e0fcec5e0f1d3bcc1133556563222a2ffd2211945d7b1480c1b1a42a6f"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:1c78780bf46d620ff4fff40728f98b8afd8b8e35c3efd638c7df67be2d5cddbf"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:bc84fb254a875a9f66616ed4538542fb7965db6356f3df571d783f7c8d256edd"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:598c0a79b4b851b922f504f9f39a863d83ebdfff787261a5ed061c21e67dd761"}, - {file = "regex-2021.7.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:875c355360d0f8d3d827e462b29ea7682bf52327d500a4f837e934e9e4656068"}, - {file = "regex-2021.7.6-cp38-cp38-win32.whl", hash = "sha256:e586f448df2bbc37dfadccdb7ccd125c62b4348cb90c10840d695592aa1b29e0"}, - {file = "regex-2021.7.6-cp38-cp38-win_amd64.whl", hash = "sha256:2fe5e71e11a54e3355fa272137d521a40aace5d937d08b494bed4529964c19c4"}, - {file = "regex-2021.7.6-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6110bab7eab6566492618540c70edd4d2a18f40ca1d51d704f1d81c52d245026"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux1_i686.whl", hash = "sha256:4f64fc59fd5b10557f6cd0937e1597af022ad9b27d454e182485f1db3008f417"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:89e5528803566af4df368df2d6f503c84fbfb8249e6631c7b025fe23e6bd0cde"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:2366fe0479ca0e9afa534174faa2beae87847d208d457d200183f28c74eaea59"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:f9392a4555f3e4cb45310a65b403d86b589adc773898c25a39184b1ba4db8985"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:2bceeb491b38225b1fee4517107b8491ba54fba77cf22a12e996d96a3c55613d"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:f98dc35ab9a749276f1a4a38ab3e0e2ba1662ce710f6530f5b0a6656f1c32b58"}, - {file = "regex-2021.7.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:319eb2a8d0888fa6f1d9177705f341bc9455a2c8aca130016e52c7fe8d6c37a3"}, - {file = "regex-2021.7.6-cp39-cp39-win32.whl", hash = "sha256:eaf58b9e30e0e546cdc3ac06cf9165a1ca5b3de8221e9df679416ca667972035"}, - {file = "regex-2021.7.6-cp39-cp39-win_amd64.whl", hash = "sha256:4c9c3155fe74269f61e27617529b7f09552fbb12e44b1189cebbdb24294e6e1c"}, - {file = "regex-2021.7.6.tar.gz", hash = "sha256:8394e266005f2d8c6f0bc6780001f7afa3ef81a7a2111fa35058ded6fce79e4d"}, -] -toml = [ - {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, - {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, -] -typed-ast = [ - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, - {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, - {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, - {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, - {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, - {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, - {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, - {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, - {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, - {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, - {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, - {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, - {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, - {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, - {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, - {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, - {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, - {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, - {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, - {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, - {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, -] -typing-extensions = [ - {file = "typing_extensions-3.10.0.0-py2-none-any.whl", hash = "sha256:0ac0f89795dd19de6b97debb0c6af1c70987fd80a2d62d1958f7e56fcc31b497"}, - {file = "typing_extensions-3.10.0.0-py3-none-any.whl", hash = "sha256:779383f6086d90c99ae41cf0ff39aac8a7937a9283ce0a414e5dd782f4c94a84"}, - {file = "typing_extensions-3.10.0.0.tar.gz", hash = "sha256:50b6f157849174217d0656f99dc82fe932884fb250826c18350e159ec6cdf342"}, -] +content-hash = "6e591608c61cc1fdacaeb8706b7050eb0da623b92946ee6af86c1a23a8a4ef35" diff --git a/pyproject.toml b/pyproject.toml index a3ed521..588cc1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ black = {version = "^20.8b1", allow-prereleases = true} flake8 = "^3.8.4" plumbum = "^1.6.9" pytest-xdist = "^2.1.0" +pytest-timeout = "^2.2.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/tests/healthcheck.yaml b/tests/healthcheck.yaml index 0552a6c..b87d60a 100644 --- a/tests/healthcheck.yaml +++ b/tests/healthcheck.yaml @@ -29,6 +29,7 @@ services: PRE_RESOLVE: 1 NAMESERVERS: "127.0.0.11" #use local docker nameserver HTTP_HEALTHCHECK: 1 + HTTP_HEALTHCHECK_TIMEOUT_MS: 200 healthcheck: test: ["CMD", "healthcheck"] interval: 1s @@ -57,6 +58,7 @@ services: PRE_RESOLVE: 0 NAMESERVERS: "127.0.0.11" #use local docker nameserver HTTP_HEALTHCHECK: 1 + HTTP_HEALTHCHECK_TIMEOUT_MS: 200 healthcheck: test: ["CMD", "healthcheck"] interval: 1s @@ -88,6 +90,7 @@ services: SMTP_HEALTHCHECK_URL: "smtp://$$TARGET:1025/" # mailhog doesn't support HELP command SMTP_HEALTHCHECK_COMMAND: "QUIT" + SMTP_HEALTHCHECK_TIMEOUT_MS: 200 healthcheck: test: ["CMD", "healthcheck"] interval: 1s @@ -110,6 +113,26 @@ services: aliases: - smtp.example.com + target_firewalled_not_responding: + image: python:3.9 + volumes: + - ./not_responding_tcp_port.py:/bin/not_responding_tcp_port + command: ["not_responding_tcp_port", "0.0.0.0", "80"] + networks: + simulated_outside: + aliases: + - target.example.com + + target_smtp_firewalled_not_responding: + image: python:3.9 + volumes: + - ./not_responding_tcp_port.py:/bin/not_responding_tcp_port + command: ["not_responding_tcp_port", "0.0.0.0", "25"] + networks: + simulated_outside: + aliases: + - smtp.example.com + networks: # we do not allow communication to the outside simulated_outside: diff --git a/tests/not_responding_tcp_port.py b/tests/not_responding_tcp_port.py new file mode 100755 index 0000000..14a6720 --- /dev/null +++ b/tests/not_responding_tcp_port.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +""" +this is a server that accepts TCP connections but doesn't send any response. it just closes the connection after an hour +has passed. this is intended for testing timeouts only. +""" + +import socket +import sys +import time + + +def keep_client_waiting(server_socket): + client, address = server_socket.accept() + print("connected") + server_socket.setblocking(0) + time.sleep(3600) + print("waited for an hour") + server_socket.close() + + +def start_server(): + listen_address = sys.argv[1] if len(sys.argv) > 1 else "" + listen_port = int(sys.argv[2]) if len(sys.argv) > 2 else 80 + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.bind((listen_address, listen_port)) + server_socket.listen() + keep_client_waiting(server_socket) + + +if __name__ == "__main__": + start_server() diff --git a/tests/test_healtcheck.py b/tests/test_healtcheck.py index 57d3ad7..c0bfd2c 100644 --- a/tests/test_healtcheck.py +++ b/tests/test_healtcheck.py @@ -2,6 +2,7 @@ import json import logging import os.path +from datetime import datetime from time import sleep import plumbum.commands.processes @@ -112,6 +113,8 @@ def test_healthcheck_ok(proxy, target): def test_healthcheck_failing(proxy, target): # given a started proxy with healthcheck _healthcheck("up", "-d", proxy) + # and autoheal not interfering + _healthcheck("stop", "autoheal") # when target is not reachable _healthcheck("stop", target) @@ -125,6 +128,38 @@ def test_healthcheck_failing(proxy, target): _healthcheck("exec", "-T", proxy, "healthcheck") +@pytest.mark.parametrize("proxy,target", PROXY_TARGET_PAIRS) +@pytest.mark.timeout(30) +def test_healthcheck_failing_firewalled(proxy, target): + # given a started proxy with healthcheck + _healthcheck("up", "-d", proxy) + # and autoheal not interfering + _healthcheck("stop", "autoheal") + + # when target stops responding + _healthcheck("stop", target) + assert " Exit " in _healthcheck("ps", target) + _healthcheck( + "up", "-d", "{target:s}_firewalled_not_responding".format(target=target) + ) + assert "Up" in _healthcheck( + "ps", "{target:s}_firewalled_not_responding".format(target=target) + ) + + # then healthcheck should return an error (non zero exit code) + with pytest.raises( + plumbum.commands.processes.ProcessExecutionError, + match=r"Unexpected exit code: (1|137)", + ): + start = datetime.now() + _healthcheck("exec", "-T", proxy, "healthcheck") + end = datetime.now() + # timeout is set to 200ms for tests, so the exception should be raised at earliest after 0.2s + # and at most 2s after starting considering overhead + # if it happens outside that timeframe (especially before 0.2s) the exception might hint to another error type + assert 0.2 < (end - start).total_seconds() < 2 + + @pytest.mark.parametrize( "proxy,target", (p for p in PROXY_TARGET_PAIRS if p[0] != "proxy_without_preresolve"), From 15f5d7031c74c9aade75241038e1332c832f2886 Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Thu, 9 Jun 2022 16:07:42 +0200 Subject: [PATCH 5/6] [IMP] healthcheck: add check if target still resolves to pre resolved ip --- healthcheck.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/healthcheck.py b/healthcheck.py index 69e0e7e..299d932 100755 --- a/healthcheck.py +++ b/healthcheck.py @@ -123,7 +123,34 @@ def process_healthcheck(): ) +def preresolve_healthcheck(): + """ + Check that the preresolved ip is still valid now for target + :return: + """ + import subprocess + from dns.resolver import Resolver + pre_resolved_ips = { + line.split(":")[2] + for line in subprocess.check_output( + ["sh", "-c", "grep -R '\\(udp\\|tcp\\)-connect:' /proc/[0-9]*/cmdline"] + ) + .decode("utf-8") + .split("\n") + if line + } + resolver = Resolver() + resolver.nameservers = os.environ["NAMESERVERS"].split() + target = os.environ["TARGET"] + resolved_ips = [answer.address for answer in resolver.resolve(target)] + for ip in pre_resolved_ips: + if ip not in resolved_ips: + error(f"{target} no longer resolves to {ip}") + + process_healthcheck() +if os.environ["PRE_RESOLVE"] == "1": + preresolve_healthcheck() if os.environ.get("HTTP_HEALTHCHECK", "0") == "1": http_healthcheck() if os.environ.get("SMTP_HEALTHCHECK", "0") == "1": From 4627f261e6c527f5a2c0c22d88d3bfbae9278693 Mon Sep 17 00:00:00 2001 From: Andreas Perhab Date: Tue, 14 Jun 2022 08:26:45 +0200 Subject: [PATCH 6/6] [IMP] pre_resolve: skip pre-resolve healthcheck on load-balancing dns when we detect a load balancing dns (responding with different ips on almost every request) we deactivate the resolver healthcheck to not restart those containers all the time --- healthcheck.py | 65 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/healthcheck.py b/healthcheck.py index 299d932..e90e10e 100755 --- a/healthcheck.py +++ b/healthcheck.py @@ -125,27 +125,54 @@ def process_healthcheck(): def preresolve_healthcheck(): """ - Check that the preresolved ip is still valid now for target + Check that the pre-resolved ip is still valid now for target :return: """ - import subprocess - from dns.resolver import Resolver - pre_resolved_ips = { - line.split(":")[2] - for line in subprocess.check_output( - ["sh", "-c", "grep -R '\\(udp\\|tcp\\)-connect:' /proc/[0-9]*/cmdline"] - ) - .decode("utf-8") - .split("\n") - if line - } - resolver = Resolver() - resolver.nameservers = os.environ["NAMESERVERS"].split() - target = os.environ["TARGET"] - resolved_ips = [answer.address for answer in resolver.resolve(target)] - for ip in pre_resolved_ips: - if ip not in resolved_ips: - error(f"{target} no longer resolves to {ip}") + from tempfile import gettempdir + + load_balancing_dns_fs_flag = os.path.join( + gettempdir(), "load_balancing_dns_detected" + ) + if not os.path.exists(load_balancing_dns_fs_flag): + # only run the resolver check if a previous run didn't flag the target as being dns load-balanced + import subprocess + + from dns.resolver import Resolver + + pre_resolved_ips = { + line.split(":")[2] + for line in subprocess.check_output( + ["sh", "-c", "grep -R '\\(udp\\|tcp\\)-connect:' /proc/[0-9]*/cmdline"] + ) + .decode("utf-8") + .split("\n") + if line + } + resolver = Resolver() + resolver.nameservers = os.environ["NAMESERVERS"].split() + target = os.environ["TARGET"] + resolved_ips = [answer.address for answer in resolver.resolve(target)] + for ip in pre_resolved_ips: + logger.info(f"checking {target} resolves to {ip}") + if ip not in resolved_ips: + resolved_ips_2 = [answer.address for answer in resolver.resolve(target)] + if resolved_ips_2 == resolved_ips: + error( + f"{target} no longer resolves to {ip}, {resolved_ips}, {resolved_ips_2}" + ) + else: + resolved_ips_3 = [ + answer.address for answer in resolver.resolve(target) + ] + # to make sure we didn't just hit the server switch in dns, we check again before deactivating + # the healthcheck permanently (until the container restarts) + if resolved_ips_3 != resolved_ips_2: + logger.info( + f"{target} seems to be load-balancing with dns ({resolved_ips} != {resolved_ips_2}), " + f"deactivating the resolver healthcheck" + ) + with open(f"{load_balancing_dns_fs_flag}", "w") as fp: + fp.write(target) process_healthcheck()