Skip to content

fix(cargo-target-broker): retain DB row when cache eviction fails #11417

Closed

Description

@dezren39

Finding

infra/cargo-target-broker/bin/cargo_target_broker.py:265-282 chooses an idle LRU directory, calls shutil.rmtree(victim.path, ignore_errors=True), and then unconditionally deletes its dirs row and increments evictions. If removal fails (for example permissions or a filesystem error), the directory remains on disk but is no longer accounted for. The size cap can then be exceeded indefinitely; the orphan may later be re-adopted by adopt_strays (lines 236-255), repeating the accounting failure. The path is reachable through checkout() when the cache is over cap (line 320).

There are no tests for this broker module in the repository.

Suggested fix

Make eviction conditional on successful removal (surface/report failures and preserve the DB row), and add a test that injects a failed removal and verifies both the row and byte accounting remain intact.

Not enqueued in this pass: the dispatch explicitly prohibits creating/dispatching further tasks for findings.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    on Nov 17, 2026
  2. developing-today commented on Nov 17, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Queue disposition: deliberately not enqueued because this dispatched suggestions pass explicitly prohibits creating or dispatching further tasks. The finding and proposed direction are captured above.

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

    app/infrakind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)status:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions