Skip to content

perf(k8s): use tag_digest HEAD for image pins #2610

Closed

Description

@dan-petty

Problem or Motivation

devops k8s image-pins (#1994) resolves each image pin with docker buildx imagetools inspect, which reads the manifest with a GET. Docker Hub counts that read as an anonymous pull of the caller's public address.

Measured on 2026-10-29 with buildx v0.38.1 and an empty Docker configuration: three inspects took Docker Hub's ratelimit-remaining from 100 to 97 (ratelimit-limit: 100;w=3600). 13 of the 31 pins under k8s/ are on Docker Hub, so each run spends 13 pulls. On the home network the cluster's nodes share that allowance: the measurements of #1994 spent it to 0, and a run then failed with toomanyrequests on portkeyai/gateway:1.15.0. On a GitHub runner, the address is shared with other tenants.

Proposed Solution & Architectural Design

  • Resolve each pin with a HEAD request of the manifest, which Docker Hub does not count ("HEAD requests aren't counted", Docker Hub usage and limits). crane digest <image> (go-containerregistry) sends a HEAD and falls back to a GET only when the HEAD fails.
  • Pin crane in src/devops_cli/tools_lock/tools.lock (go-containerregistry v0.22.1: the release assets carry a digest, and checksums.txt lists the same sha256 for the Linux and Darwin tarballs), install it in the image-pins job with uv run devops install-tools --tool crane --only-missing, and record its runs for the fake that replaces ImagetoolsFake.
  • Measure first that crane digest leaves ratelimit-remaining unchanged for an anonymous client.

Target Subsystem

src/devops_cli/k8s/image_pins.py, tools.lock, the image-pins job of ci.yml, the image resolver's fake and recording.

Existing Tool Considered

crane (go-containerregistry, Apache-2.0, maintained by Google). regctl image digest and oras manifest fetch --descriptor also send a HEAD. skopeo inspect and docker manifest inspect read the manifest with a GET, as imagetools does. The change deletes the imagetools resolver and its record.

Acceptance criteria

  • An anonymous crane digest of three Docker Hub images leaves ratelimit-remaining unchanged (measured and recorded in the proposal).
  • devops k8s image-pins resolves with crane digest, and the contract suite holds the record to the command and to the lock's version.
  • The image-pins job installs the pinned crane.

Proposed design

Problem statement

devops k8s image-pins resolves each image pin with a GET request. Docker Hub counts that read as an anonymous pull. Thirteen of the 31 pins are on Docker Hub. Each run spends 13 pulls from the shared allowance. The cluster's nodes share that allowance. A run can fail with toomanyrequests.

Acceptance criteria

Requirement: HEAD resolution

devops k8s image-pins SHALL resolve each pinned image with a HEAD request of the manifest via tag_digest, not a GET.

Scenario: Anonymous HEAD to Docker Hub

  • WHEN An anonymous client resolves a Docker Hub image pin through tag_digest
  • THEN ratelimit-remaining is unchanged after the resolution

Requirement: No new binary pin

The image-pins CI job SHALL NOT require a new tool pin in tools.lock for image resolution.

Scenario: CI job resolves without crane

  • WHEN The image-pins job runs on a pull request that changes k8s/
  • THEN The job resolves images using tag_digest with no crane or buildx binary

Requirement: Remove imagetools fake

The ImagetoolsFake, its contract suite, and its recordings SHALL be removed from the codebase.

Scenario: ImagetoolsFake is absent

  • WHEN The codebase is searched for ImagetoolsFake
  • THEN No file references ImagetoolsFake

Requirement: HTTP edge tests

Tests of image pin resolution SHALL double the registry at the HTTP edge, not at the process level.

Scenario: Registry double at HTTP edge

  • WHEN A test resolves an image pin
  • THEN The registry is replaced by an HTTP-level double

Requirement: No local reference split

k8s/image_pins.py SHALL NOT contain its own reference split function.

Scenario: image_reference is absent

  • WHEN The codebase is searched for image_reference in k8s/image_pins.py
  • THEN The function is not present in that file

Existing Tool Considered

No alternatives check has run. The project's own tag_digest in src/devops_cli/docker/registry.py (added in #1997) covers the need. It sends a HEAD request of the manifest and handles the 401 Bearer token challenge. No new binary pin is needed. The code is already built, tested, and used by devops argo cd apps status.

Key questions

  • Which resolver should devops k8s image-pins use?: tag_digest from src/devops_cli/docker/registry.py, which sends a HEAD request and handles the 401 Bearer token challenge. No new binary pin is needed. (best practice) [sources: openspec/changes/archive/2026-10-29-1997-argo-image-pin-drift/design.md]
    • Chosen: tag_digest (project code). Already in src, tested, used by devops argo cd apps status. No new binary pin, fake, or contract suite needed.
    • Rejected: crane (go-containerregistry). Needs a new pin in tools.lock, a new fake, and a new contract suite. Duplicates what tag_digest already does.
    • Rejected: docker buildx imagetools inspect (current). Uses a GET request, which Docker Hub counts as an anonymous pull. This is the defect being fixed.
  • Does tag_digest handle Docker Hub's 401 challenge?: Yes. When the registry answers 401, it gets an anonymous Bearer token from the realm of the challenge and sends the HEAD again. [sources: openspec/changes/archive/2026-10-29-1997-argo-image-pin-drift/design.md]
  • What happens to the ImagetoolsFake and its contract suite?: They are removed. The resolver no longer calls a subprocess. Tests double the registry at the HTTP edge. (best practice) [sources: src/devops_cli/k8s/image_pins.py]
    • Chosen: Remove ImagetoolsFake and contract suite. The resolver uses tag_digest over HTTP, not a subprocess. A process-level fake is no longer needed.
    • Rejected: Keep ImagetoolsFake. Would require a new fake for tag_digest's HTTP calls, which is more complex than an HTTP-level double.
  • Does k8s/image_pins.py keep its own reference split?: No. One split stays in docker/registry.py. k8s/image_pins.py keeps no reference split of its own. (best practice) [sources: src/devops_cli/k8s/image_pins.py]
    • Chosen: Remove image_reference from k8s/image_pins.py. The split stays in docker/registry.py, avoiding duplication of the reference grammar.
    • Rejected: Keep image_reference in k8s/image_pins.py. Duplicates the split logic that already exists in docker/registry.py.
  • Does the CI job need a new tool pin for image resolution?: No. tag_digest is in src, so no new entry in tools.lock is needed. The image-pins job needs no crane and no buildx for resolution. (best practice) [sources: src/devops_cli/tools_lock/tools.lock]
    • Chosen: No new pin. tag_digest is in src. No binary is needed for image resolution.
    • Rejected: Pin crane in tools.lock. Adds a new binary, a new fake, and a new contract suite for what tag_digest already does.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/infra
    status/new
    value/medium
    effort/medium
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/infra. The title prefix perf maps to type/infra.
    • Priority: P2-Medium. It causes intermittent CI failures from shared rate-limit exhaustion but the feature still works most of the time.
    • Value: Medium. It prevents shared rate-limit exhaustion that blocks other tenants and CI runs on the same address.
    • Effort: Medium. It requires pinning crane, changing the resolver, updating the CI job, and updating test fakes and recordings.
    • Related: test(k8s): every image pin under k8s/ resolves in its registry before the merge #1994, which asks for a different change. Both work on the image-pins resolver under k8s/, but #1994 adds the check while the candidate replaces its GET-based resolver with a HEAD-based one to avoid rate-limit consumption.
  3. added
    priority/p2-medium
    on Oct 29, 2026
  4. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

    A HEAD resolver is already in src, so this item needs no new binary.

    devops_cli.docker.registry.tag_digest (#1997, PR #2605, merged before #2614) reads the digest of a tag with a HEAD request of the manifest. When the registry answers 401, it gets an anonymous Bearer token from the realm of the challenge and sends the HEAD again. devops argo cd apps status uses it through devops_cli.argo.image_pins.check_pins.

    Proposed scope instead of crane:

    • devops k8s image-pins resolves each pin with tag_digest through the shared HTTP client. The image-pins job then needs no crane and no buildx, and tools.lock gets no new entry.
    • tagged_image accepts the forms that k8s/image_pins.py reads now: a name with no registry (Docker Hub: API host registry-1.docker.io, and the library/ prefix for a one-component name) and a reference with a digest.
    • k8s/image_pins.py keeps no reference split of its own (image_reference). One split stays, in docker/registry.py, and build(deps): Type docker-py with types-docker #2603 moves it to docker-py's parser.
    • The imagetools fake, its contract suite and its recordings go. The tests double the registry at the HTTP edge.

    Check first: an anonymous HEAD from tag_digest to a Docker Hub manifest leaves ratelimit-remaining unchanged. The token request to auth.docker.io is not a pull.

  5. added
    scope/k8s
    on Oct 30, 2026
  6. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  7. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 07fb4c2 (see proposed design in issue body).

  8. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Staged: branch perf/2610-devops-k8s-image-pins-resolves-with, draft pull request #3096. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Resolve image pins with tag_digest HEAD: 4573 tokens
    2. Replace image_reference with tagged_image: 4457 tokens
    3. Remove ImagetoolsFake and contract suite: 4386 tokens
  9. added a commit that references this issue on Nov 1, 2026
  10. 8 remaining items

  11. changed the title [-]perf(k8s): devops k8s image-pins resolves with a HEAD request that Docker Hub does not count[/-] [+]perf(k8s): use tag_digest HEAD for image pins[/+] on Nov 6, 2026
  12. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 81 characters, and the limit is 60. The type and the scope stay.

  13. added
    owner/agent
    on Nov 6, 2026
  14. added
    status/in-review
    and removed
    status/planned
    on Nov 6, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 6, 2026
  16. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 22:09 UTC

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

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions