Skip to content

Vault secret read makes two Vault API calls per secret (KV version preflight + secret read) #9514

Closed

Description

@IvanChalukov

Summary

Concourse currently performs a KV version preflight request for every secret read, followed by the actual secret read. This results in two Vault API calls per secret lookup.

In large Concourse deployments - especially those with many pipelines and resources using Vault as a credential manager - this behavior can significantly increase request volume and may lead to Vault rate limiting (requests-per-second limits being exceeded).

Code evidence:

Impact

Because the KV engine version is a static property of the mount, performing this preflight request on every read is redundant. At scale, this effectively doubles the number of Vault API calls, increasing latency and putting unnecessary pressure on Vault.

Steps to Reproduce

  1. Start Concourse configured with Vault credential manager.
  2. Ensure a pipeline/task references one or more Vault-backed vars.
  3. Enable Vault audit logs. Or build Concourse version with logs.
  4. Trigger a build that resolves secrets.
  5. Observe that each secret resolution produces:
    • one preflight call to /v1/sys/internal/ui/mounts/
    • one data read call to the secret endpoint.

Expected Results

KV engine version should be determined once per mount and reused for subsequent reads under the same mount.

Actual Results

KV version is revalidated for each secret read, resulting in two calls per secret.

Web Node(s) configuration

I've used vault.yml to setup local environment

Worker(s) configuration

No response

Concourse Version

8.1.1(but it is not applicable)

Browser (if applicable)

No response

Did this use to work?

No

Activity

  1. IvanChalukov commented on Apr 8, 2026

    @IvanChalukov
    ContributorAuthor

    I’d be happy to take this on.

    I was thinking of following solution:

    • Introduce a lightweight in-memory cache to store the KV engine version per mount path:
    • On the first read for a given mount, perform the preflight request and cache the result.
    • For subsequent reads under the same mount, skip the preflight and read the secret directly.
    • Preserve the existing KV v1/v2 read logic to maintain backward compatibility.
    • Maybe introduce an env var that enable/disable cache behaviour. For example CONCOURSE_VAULT_ENABLE_KV_MOUNT_CACHE - true/false

    Expected impact:

    • Fewer Vault calls - Reduce Vault API calls from 2N → N + 1 for N secrets under the same mount.
    • Lower overall Vault load - reduces unnecessary traffic, helping avoid rate limits in busy environments.
    • Faster secret lookups - improves overall performance, especially in larger Concourse deployments with many pipelines.
  2. taylorsilva commented on Apr 9, 2026

    @taylorsilva
    Member

    I think your approach makes sense Ivan. I was looking at the code:

    // Read must be called after a successful login has occurred or an
    // un-authorized client will be used.
    func (ac *APIClient) Read(path string) (*vaultapi.Secret, error) {
    // Check if path is kv1 or kv2
    path = sanitizePath(path)
    mountPath, kv2, err := isKVv2(path, ac.client())

    My initial thought was that we could do the do the lookup once since the root mount path is usually /something, but I then realized it is possible for someone to set CONCOURSE_VAULT_PATH_PREFIX to /, so someone could do vault lookups under all available mounts. Would be kind of crazy, but is technically possible.

    I also just realized that secret engine mount paths can contain / in them. So a user could have a vault kv engine at /my/kv/engine1 and my/kv/engine2. Again, kinda wild, but technically possible.

    Your plan sounds good, looking forward to your PR.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions