Skip to content

vortex-fetch-db: VORTEX_DB_DIR is ignored for indexed DB fetches (VORTEX_DB_INDEX) #2767

Description

@AlexSkrypnyk

Summary

vortex-fetch-db resolves its output directory differently for the primary DB and for indexed DBs (VORTEX_DB_INDEX=N), and the difference silently drops a plain VORTEX_DB_DIR for indexed fetches.

  • Primary (VORTEX_DB_INDEX unset): dir resolves VORTEX_FETCH_DB_DIRVORTEX_DB_DIR./.data.
  • Indexed (VORTEX_DB_INDEX=2): dir resolves VORTEX_FETCH_DB2_DIRVORTEX_DB2_DIR./.data.

Because the index is interpolated into the variable name (VORTEX_DB${index}_DIR), a plain VORTEX_DB_DIR that a caller exports as a base directory is honoured for the primary DB but silently ignored for indexed DBs. The same applies to the -url (and other source) resolvers.

Impact

A multi-DB setup that fetches a second database and exports VORTEX_DB_DIR (reasonably expecting it to apply to all fetches) gets the indexed DB written to ./.data instead of the requested directory. If a later step reads the indexed DB from VORTEX_DB_DIR, the file is "not found".

Concrete case - a consumer .lagoon.yml fetches the migration DB and then provisions:

- run:
    name: Fetch migration database
    command: |
      export VORTEX_DB_DIR=/tmp/data
      VORTEX_DB_INDEX=2 ./vendor/bin/vortex-fetch-db   # writes db2.sql to ./.data, not /tmp/data
- run:
    name: Provision site
    command: |
      export VORTEX_DB_DIR=/tmp/data
      ./vendor/bin/vortex-provision                    # reads db2 from /tmp/data -> not found

The deploy fails with a missing migration DB file. It only surfaces on environments that override VORTEX_DB_DIR (e.g. Lagoon, which uses /tmp/data); CI defaults everything to ./.data, so both the fetch and the read agree there and the bug is masked. Current workaround: also export VORTEX_DB2_DIR=/tmp/data.

Suggested fix

Let the non-indexed base variable act as a global fallback for indexed fetches, so VORTEX_DB_DIR applies to every index unless a per-index VORTEX_DB<N>_DIR (or VORTEX_FETCH_DB<N>_DIR) overrides it. In src/vortex-fetch-db:

_v="VORTEX_FETCH_DB${_db_index}_DIR"
_vs="VORTEX_DB${_db_index}_DIR"
VORTEX_FETCH_DB_DIR="${!_v:-${!_vs:-${VORTEX_DB_DIR:-./.data}}}"

and the equivalent in the source-specific resolvers (vortex-fetch-db-url, etc.). This keeps per-index overrides working while making a plain VORTEX_DB_DIR a predictable base directory for all fetches, which is what the primary-DB behaviour already implies.

Version: drevops/vortex-tooling 1.3.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A3Board worker 3

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Release queue

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions