Skip to content

Consul_srv refactor#14

Open
ingcsmoreno wants to merge 6 commits intomasterfrom
smoreno/asyncdns_3
Open

Consul_srv refactor#14
ingcsmoreno wants to merge 6 commits intomasterfrom
smoreno/asyncdns_3

Conversation

@ingcsmoreno
Copy link

@ingcsmoreno ingcsmoreno commented Oct 6, 2021

What does this PR do?

The following features/changes were introduce:

  • DNS queries are now made using C-Ares and asyncIO libraries, to be able to execute them in parallel and so improving performance (which went from ~35 requests/sec to ~110 request/sec).
  • Randomize the IP returned when a service has more than one endpoint available. This actually was achieved by picking the first one returned, since CONSUL return the IPs in deferent order on each call.
  • The default setting of the AGENT address now accepts the host "host.docker.internal" as valid now, to add compatibility with local environments.

How can I test it?

  1. Get the mksp-compose repo, and set up the services:

    make resources_start
    make consul_import
  2. Checkout this branch

  3. Build the image:

    ./build_helper/image_build.sh
  4. Run the image. You get logged in into a Python 3 shell.

    ./build_helper/image_run.sh
  5. Run the following commands to install dependencies and prepare to run the consul_srv:

    python setup.py bdist_wheel --universal
    pip install .
    python
  6. You can now check the DNS request returned the right data by running this commands:

    import consul_srv
    consul_srv.AGENT_URI = "host.docker.internal"
    heimdall = consul_srv.service("heimdall-staging", "https")
    heimdall._path("/status/data.json")

    You should get an output like 'https://35.169.11.217:443/status/data.json'.

Any relevant Ticket?

🎫 Consul Srv refactor of resolver class as [sc-69590]

Any extra or background information?

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #69590: Consul-Srv refactor of resolver class as a POC.

@ingcsmoreno ingcsmoreno marked this pull request as ready for review October 7, 2021 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants