Skip to content

Add Ansible deployment for DingoCache (etcd, dfkv_mds, dfkv_server) - #1

Merged
zghstart merged 10 commits into
mainfrom
feat/dfkv-ansible-deployment
Sep 22, 2026
Merged

zghstart merged 10 commits into
mainfrom
feat/dfkv-ansible-deployment

Conversation

@zghstart

Copy link
Copy Markdown
Contributor

Adds the deployment automation for DingoCache (dfkv): the etcd quorum,
dfkv_mds, dfkv_server, the per-region telemetry stack, and client
publication.

This replaces a hand-rolled fleet tooling (dfkv_fleet.sh and friends) with
playbooks and roles in the shape of the sibling ansible-dingofs.

What is here

Phase Playbook Target
preflight 00_check_config.yml the region inventory is complete
0 01_prepare.yml packages, directories, RDMA and disk preflight
1 03_release.yml fetch, verify, stage a release (never restarts)
2 04_etcd.yml bootstrap the quorum
3 05_mds.yml dfkv_mds
4 06_server.yml dfkv_server
5 09_verify.yml assert against the ring
6 07_observability.yml OTel + Prometheus + Tempo + Grafana
— 10_upgrade.yml rolling upgrade, and the rollback path

dfkv_site.yml sequences them for a greenfield cluster; every phase is also a
standalone playbook.

Three things worth reading before review

Capacity is a fraction of each disk, not a number in config. Both dfkv and
dingo-cache size themselves from the same NVMes, so both now use a ratio. The
disk selection is ported from roles/dingo_cache here, and keeping the
largest same-size group is load-bearing rather than tidiness: dfkv splits
--cap evenly and applies one --disk-hash-weight to every disk, so mixing
disk sizes gives the small disk a budget it cannot hold.

A release directory is immutable once staged, because the launcher inside
it is what a rollback would run.

A capacity change on a running node discards its cache. slab will not
reopen a directory laid out for a different capacity, so --cap cannot be
edited in place. The flag is named for what it does
(dfkv_server_wipe_on_capacity_change).

Verified

Run end to end against a live bj09 canary (bj09-gpu-300x-0088, and a
capacity migration on bj09-gpu-200b-0022): deploy, re-run idempotency
(changed=0), ring membership, and the production ring left untouched while a
second, isolated group was used.

Co-Authored-By: Claude Code noreply@anthropic.com

zghstart and others added 10 commits September 22, 2026 20:06
ansible.cfg, the collection list, and a CI job that does exactly two things:
parse every YAML file and --syntax-check every playbook. There is no
ansible-lint here on purpose -- see the sibling ansible-dingofs for why.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Six structural groups. Roles are selected by group, never by a node-name
pattern: the rollout this replaces inferred "is this an MDS?" from `*-cpu-*`
in the hostname, which was wrong on bj11 where the MDS nodes are named
`bj11-dingofs-00NN`.

Capacity is deliberately not a per-node variable -- it is derived from the
disks the node actually has. What remains per-node are the values that differ
by hardware: the advertise interface, the RDMA rails, the RAM tier budget.

Co-Authored-By: Claude Code <noreply@anthropic.com>
A release is fetched once on the control node and pushed from there, so a
70-node region downloads it once. Two independent gates: the download is
checked against the release published SHA256SUMS, and the unpacked tree is
checked again on the target.

The launcher scripts are copied into each release directory and never
rewritten, which is what makes a rollback safe: flipping `current` back to an
older release also restores its launcher, so an older binary is never handed a
flag it does not understand.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Three checks that fail at phase 0 rather than part-way through a deploy:

  * every device named in dfkv_rdma_dev exists on the node. Measured on bj09:
    the 200b nodes have ib7s400p0-7 while the 300x node has only p0-3, and
    naming a device that is not there narrows the usable rails silently.
  * a cache node has at least one mounted /mnt/disk*, so a node with no data
    disk fails before the release is pushed to it.
  * the RDMA userspace providers are installed. Exposing a device does not make
    it discoverable -- ibverbs-providers is the package that does.

Only real mount points count. statvfs on a plain directory reports the
filesystem behind it, so an unmounted /mnt/diskN would measure as the root disk.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Capacity is a fraction of each disk, not a number written into region config,
matching how dingo-cache sizes itself -- both systems run over the same NVMes.

The disk selection is ported from roles/dingo_cache in ansible-dingofs: drop
disks below a floor, keep only the largest same-size group, take a fraction of
the smallest one, round down to a whole 1 GiB extent.

Keeping the same-size group is doing more work than it looks like. dfkv splits
--cap evenly across its directories and applies ONE --disk-hash-weight to every
disk, and its CLI has no per-disk form for either. Both are only correct when
the disks are the same size, so homogeneity is established before dfkv sees
them and its uniform weight becomes capacity-proportional by construction.
Without it a mixed node is actively broken: the small disk gets the same cap/n
budget as the large ones and slab fails laying down extents it cannot fit.

Co-Authored-By: Claude Code <noreply@anthropic.com>
etcd is pinned independently of the dfkv release -- it ships in neither the
tarball nor this repo. The unit carries an 8 GiB quota and periodic compaction,
which are not optional: client registration and lease keepalives rewrite keys
continuously, so the revision counter climbs even though the key count is
stable. At etcd 2 GiB default that ends in ALARM NOSPACE, where the ring
reports members=0 and every dfkv_server keeps serving perfectly.

Member names must be the OS hostname, not the inventory name, and --etcd takes
host:port with no scheme: dfkv_mds adds the scheme itself, so a scheme there
produces http://http:// and every etcd call fails.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The upstream compose file is already DFKV_* variable driven, so a region
lives in a rendered .env rather than a re-rendered compose. Only prometheus.yml
is rendered, because its scrape targets are this region nodes -- deliberately
the declared set, not the live ring, so a node that falls out of the ring does
not also vanish from monitoring.

Client artifacts are published under an explicit version directory and never
behind a `current` symlink: a symlink flip on a lazily-consistent network
filesystem resolves differently on different nodes for a window of seconds, and
engines in one ring that load different builds derive different cache
identities and quietly miss each other.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The previous tooling walked nodes.txt and reported a healthy cluster for 13
days while a node that had been removed from that list -- but never disabled --
came back on reboot, re-registered, and served 2.7% of the keyspace.

So the ring is asked what it contains and that is compared against what the
region declares: every member on the target version, RDMA depth and RAM arena,
and an etcd registration count that matches the ring. A mismatch is reported as
a mismatch and never narrowed to make the output green.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Each phase is a standalone playbook and dfkv_site.yml sequences them. The
order is load-bearing: etcd is the only authoritative state and must be healthy
before any MDS starts, because an MDS that cannot reach etcd exits rather than
degrading; the MDS must be up before any server, because a server first
registration has a hard 60s deadline and it exits 1 on expiry.

10_upgrade.yml rolls MDS before servers, following the upstream deployment
guide -- an older MDS does not recognise kListTopology, so a modern server
polling it fails the call and keeps its last-good ring, which freezes the ring
silently. Activation per node is RAM gate, flip, restart, wait for the version
to report itself, RAM gate again. Rollback is the same playbook pointed at the
previous version.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Includes the parts that are only learnable by running it: why there is no host
tuning phase, why the capacity is a ratio, why an already-staged release is
immutable, and what a capacity change on a running node actually costs.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@zghstart
zghstart merged commit 92aac92 into main Sep 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant