Skip to content

fix(k8s): the grafana token mint creates the new token before it revokes the old ones, so a failed create leaves a working token #2208

Closed

Description

@dan-petty

What happened

src/devops_cli/k8s/credentials.py mints a Grafana service-account token by first revoking every token of the devops-cli service account and then creating the new one. If the create fails (a network error, a 5xx, a refused request), the account is left with no token, and every caller that used a stored token loses access until a later sync succeeds. Found by #2156 (2026-10-25).

What should happen

The mint creates the new token first, stores it, and only then revokes the other tokens of the account. A failed create changes nothing; a failed revoke is reported with its cause and leaves the old token, which a later sync revokes.

Acceptance criteria

  • A test on the HTTP fake shows that a failed create sends no revoke and keeps the stored token.
  • A test shows the order create, store, revoke on success.

Source: #2156

Activity

  1. added
    type/bug
    source/agent
    on Oct 25, 2026
  2. dan-petty commented on Oct 25, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/bug. The candidate describes a bug in the Grafana token minting process that leads to access loss during failures.
    • Priority: P2-Medium. This issue affects access control and reliability of the devops-cli tool, but is not critical for system stability or security.
    • Value: Medium. The fix improves reliability of token management, affecting all users of the devops-cli tool who interact with Grafana.
    • Effort: Low. The change only requires reordering operations in one function and adding tests, which is a small code modification.
    • Related: fix(k8s): workloads that never call the kubernetes api mount no service account token #1652, which asks for a different change. Both items relate to Kubernetes service account tokens, but the candidate focuses on the order of token creation and revocation while item 1652 addresses mounting unused tokens.
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

    source/agenttype/bug

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions