Skip to content

feat(tes/routing/distance): add distance routing #8

Closed

Description

@uniqueg

Problem

proTES's TaskDistributionDistance resolves the hosts of the TES backends and of the task's inputs and sends their IP addresses, per task, to db-ip.com, and the resulting places to Nominatim. That is slow (one remote lookup per host and task, elixir-cloud-aai/protes#130) and a privacy issue: the locations of users' data go to third parties for every task. It should become an opt-in plugin with an offline default.

This issue absorbs elixir-cloud-aai/protes#130 (store geolocations of TES instances), which is closed with a pointer here once this is done.

Proposal

  • Plugin tes.routing.distance: distribution foca-plugin-tes-routing-distance, apis = {"tes"}, on_route only.
    • Ranks the candidates by the summed great-circle distance to the locations of the task's inputs (inputs[].url, as the client submitted them: ctx.original).
    • Ties keep the candidates' order. Candidates without a location follow the located ones, in their order. No candidate is dropped.
    • NotApplicable if the task has no input URLs, or if no input or no candidate could be located, so the next alternative (e.g., generic.routing.random, feat(generic/routing/random): add random routing #7, or foca.routing.ordered) routes instead.
  • Backend locations: from the backend list first (Backend.location, FOCA 0.18.0); otherwise, looked up from the host's address. The admin can turn that off (locate_backends: false).
  • Hosts are resolved with the system resolver, within the deadline. Only public addresses are looked up.
  • Providers (provider):
    • offline, the default: a local GeoIP database in MaxMind DB format, path in the config (database). The docs recommend DB-IP's free "IP to City Lite" database (CC BY 4.0, with the attribution it requires in the README and docs). Any database with GeoIP2-City-style location fields works, too.
    • dbip, an explicit opt-in: DB-IP's free API for the place of an address, then Nominatim for its coordinates, as in proTES. The URLs are configurable (e.g., a self-hosted Nominatim). Nominatim requests are throttled per process (usage policy: at most 1 per second, with an identifying user agent).
  • No database file in the repository or the package. The docs show how to add one to a derived image (download step), and that it must be updated monthly.
  • Cache: lookups (address to location, also misses) are cached per process, with a TTL and a size limit, so backends are looked up once per process until expiry, not per task (proTES#130).
    • FOCA 0.18.0 gives plugins no database access, so a shared cache in the plugin's own MongoDB collection (as planned) would need its own MongoDB client and credentials in the plugin. That is left for a follow-up, once FOCA offers plugin storage.
  • Metadata:
    • data_transfers declares db-ip.com and Nominatim (with provider: dbip only);
    • capabilities: routing-by-data-locality.
  • Outbound lookups go through ctx.http only (public addresses, https, deadline).
  • Annotations: counts only (inputs, located inputs and backends, lookups, cache hits). No hosts, addresses or places, which could be personal data.

Acceptance criteria

  • The offline provider works without network.
  • Online providers are mocked in tests (FOCA's FakeHttp).
  • Tests cover cache hits, misses and expiry; the NotApplicable paths; and the contract checks.
  • 100% coverage.
  • perf: store geolocations of TES instances protes#130 is closed with a pointer.

Surviving the Connexion 3 migration

Neutral model and ctx.http only; an async variant can follow FOCA's async hooks.

Dependencies

Activity

  1. added
    priority: medium
    status: blocked
    type: feature
    type: security
    workload: days
    on Oct 27, 2026
  2. removed
    status: blocked
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtype: featuretype: securityworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions