skip to content

Three open-source distribution registry nodes share storage behind a load balancer; pulls work but pushes fail intermittently. What is the likely cause, and what must every node share?

level: seniorimportance: should knowfreq 30%

answer

  1. pushes are multi-request, pulls are not
  2. state the client carries between calls
  3. signed by one node, checked by another
  4. a secret generated at startup

basics

~20 s

Each node generated its own HTTP secret because http.secret was unset, so an upload begun on one node fails when its next request reaches another. Nodes need the same storage and http.secret, and should share any configured cache.

solid answer

~50 s

A push is a sequence of requests: the client opens a blob upload, sends data, then completes it, carrying upload state between calls. The open-source distribution registry signs that state with `http.secret`, and if the setting is omitted each node **generates its own secret at startup**. When the load balancer sends the next request of an upload to a different node, that node cannot verify the state and the push fails; pulls are plain reads of shared storage, so they keep working. The configuration reference says a load-balanced cluster **must** use one secret on every node; the deployment guide adds the same storage driver configuration, plus a shared cache if one is configured, since separate caches work but load the backend more. Configure the load balancer's health check to treat a `401` from `/v2/` as healthy on a registry that requires authentication.

code

yaml · 8 lines
yaml
# identical on every node behind the load balancer
version: 0.1
http:
  addr: :5000
  secret: <one random value shared by all nodes>
storage:
  filesystem:
    rootdirectory: /var/lib/registry   # the same shared filesystem root on every node

go deeper

for a junior

Remember that a push is several requests while a pull is simple reads, and that registry nodes behind a load balancer must share storage and configuration.

for a middle

Explain the upload sequence and the state the client carries between calls, and how http.secret signs that state so another node can verify it.

for a senior

Diagnose from the asymmetry: pushes fail, pulls work, so look for per-node state. Name the shared set (storage and secret, plus any cache) and set health checks to expect 401.

for a principal

Turn the incident into a design rule: every node's state is shared or absent, secrets come from one store, and the repository service is treated as tier-0 because every build depends on it.

## The symptom and why it splits pushes from pulls The **open-source distribution registry** is an implementation of the OCI distribution specification, often run as a self-hosted private registry. Running several instances behind a load balancer is the usual way to make it highly available. The scenario has a classic signature: **pulls always work, pushes fail at random**. The difference is state. A pull fetches a manifest and blobs by name or digest from storage that every node can read; any node can answer any request. A push is a **sequence**: the client starts a blob upload with a `POST` to `/v2/<name>/blobs/uploads/`, receives an upload location, sends the data, and completes the upload with a `PUT` to that location carrying `?digest=`. Between those requests the client carries **upload state** that the registry handed it. If a later request in the sequence reaches a node that cannot verify that state, the upload fails. ## The cause: one secret per node The registry's configuration has an `http` section with a `secret` field. The configuration reference describes it as random data used to sign state that may be stored with the client, to protect against tampering, and adds two lines that explain the incident: - if the secret is omitted, **the registry generates one automatically when it starts**; - if you build a cluster of registries behind a load balancer, you **must** ensure the secret is the same for all registries. So three nodes started without `http.secret` hold three different secrets. Node A signs the upload state; the load balancer sends the next request to node B; node B's signature check fails and the push is rejected. Whether a push fails depends on how the load balancer spreads that push's requests, which is why the failures look intermittent. Sticky sessions can hide the problem without fixing it. ## What every node must share The deployment guide's section on load balancing says a load-balanced cluster of registries must share the same resources, and lists them, with one nuance for the cache: | Shared item | Why | |---|---| | Storage driver | every node must read and write the same blobs and manifests; with the filesystem driver, all instances must see the same filesystem root, and with an object-storage driver they must point at the same resource with an identical configuration | | HTTP secret | it coordinates uploads across nodes | | Cache (if configured) | separate caches work at the time of writing but are not optimal, because more requests reach the storage backend | The fix for the scenario: 1. Generate one random secret with a cryptographically secure generator. 2. Put the same value in `http.secret` on every node, through the same secret store rather than a hand-edited file per node. 3. Confirm every node has an identical storage configuration. 4. Restart the nodes and retry a multi-layer push several times through the load balancer. ## Health checks and headers Two more points from the deployment guide matter for a cluster: - **Health checks.** A properly secured registry returns `401` from `/v2/` without credentials, with a `WWW-Authenticate` challenge. The guide recommends configuring the load balancer to treat `401` as healthy and anything else as down, so a node whose authentication broke, and might serve content unprotected, is taken out of rotation. If the load balancer cannot change the expected code, `/` always returns `200 OK`. - **Forwarded headers.** The proxy must pass `X-Forwarded-Proto`, `X-Forwarded-For` and `Host` with their client-side values; otherwise the registry issues redirects to internal hostnames or downgrades https to http. ## The same rule for repository managers The lesson generalises to any clustered repository manager: **nodes must not keep state that only they can read**. A clustered repository manager follows the same rule: every node works against the same binary storage and the same backing database rather than private local copies, because a node writing to its own disk would serve a different view from its neighbours. When you design high availability, list the state each node holds (signing secrets, caches, local files, queues) and make each item either shared or stateless. ## What breaks when the whole service is down High availability matters because a repository manager sits in the path of every build. Clients are configured with its URL only, so if it is down, builds fail even for public dependencies the manager merely proxies, and deployments that pull images from it stall. That is why a cluster, shared storage and a tested restore path belong to the design from the start.

  • Why not just enable sticky sessions on the load balancer instead of sharing the secret?
    Stickiness only lowers the chance that one push's requests reach two nodes; a node restart, a scale-out or a client on a new connection still splits an upload. And with no configured secret, every restart gives that node a new secret, invalidating its own uploads in flight. The documented requirement is a shared `http.secret`, which makes any node able to continue any upload.
  • Why should the health check expect 401 from /v2/ rather than 200?
    On a registry that requires authentication, `/v2/` without credentials must answer `401` with a `WWW-Authenticate` challenge. A node returning `200` there has lost its authentication configuration and may be serving content to anyone. Treating only `401` as healthy pulls such a node out of rotation instead of sending users to it.

  • Pulls work, so the storage and every node's configuration must be fine.
  • Each registry node can keep its own auto-generated secret behind a balancer.
  • Sticky sessions are the documented fix for failing pushes in a cluster.
  • On a secured registry, a 401 from /v2/ means the node is broken.
  • Each node can use its own local disk if they all mount the same path name.