Skip to content

test(lab): publish ticket changes through the data centre - #169

Merged
TN019 merged 9 commits into
mainfrom
test/data-centre-list-updates
Dec 1, 2026
Merged

TN019 merged 9 commits into
mainfrom
test/data-centre-list-updates

Conversation

@TN019

@TN019 TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Why

The hub now takes its season list from the data centre and serves the verified list from memory, so drills that rewrote the hub's start file and restarted it no longer exercised the path gates actually use.

What changed

  • lab/stub.py gains --season-extra FILE: it appends already signed, newline-terminated lines to the generated season list, checks the file every 0.5 seconds and republishes on change; a malformed file is rejected and the previous publication stays. dc and dc2 mount lab/dc-runtime/ read-only; the hub and gates do not see it. lab/keys.sh creates an empty lab/dc-runtime/season-extra.txt, which .gitignore excludes.
  • Add lab/season-extra.sh, shared by the drills: it replaces or appends the extra file atomically, reads the list and ETag served on 8444, and waits for the hub and gates to install a given list.
  • lab/ticket-trust.sh, lab/north-entrance.sh and lab/status-stall.sh publish their extra tickets through the data centre, wait for installation, and restore the previous extra file during cleanup. lab/device-tls.sh first checks that the hub's /tickets matches the data centre's /season.txt ETag. lab/README.md describes the new flow.

How to verify

From the repository root, with Docker Compose and a Linux container engine that supports the lab network capabilities; run each drill alone:

./scripts/dev.sh build-image
sh lab/keys.sh
docker compose -f lab/compose.yaml up -d --build
sh lab/ticket-trust.sh
sh lab/north-entrance.sh
sh lab/device-tls.sh

Each drill should pass with its tickets delivered through the data centre, and cleanup should report the restored list installed at the hub and the checked gates.


背景

hub 现在从数据中心取赛季票单,并从内存提供核验过的票单。那些改写 hub 启动文件再重启 hub 的演练,已经走不到闸机真正使用的这条路径了。

改动

  • lab/stub.py 新增 --season-extra FILE:把已经签好、以换行结尾的行追加到生成的赛季票单后面,每 0.5 秒检查一次文件,有变化就重新发布;文件格式不对就拒绝,继续提供上一版。dc 和 dc2 以只读方式挂载 lab/dc-runtime/,hub 和闸机都看不到它。lab/keys.sh 会建一个空的 lab/dc-runtime/season-extra.txt,.gitignore 忽略这个目录。
  • 新增各演练共用的 lab/season-extra.sh:以原子方式替换或追加这个文件,读取 8444 端口提供的票单和 ETag,并等待 hub 和闸机装上指定的票单。
  • lab/ticket-trust.sh、lab/north-entrance.sh 和 lab/status-stall.sh 改为经数据中心发布追加的门票,等待安装完成,清理时恢复原来的追加文件。lab/device-tls.sh 先确认 hub 的 /tickets 与数据中心 /season.txt 的 ETag 一致。lab/README.md 同步说明新的流程。

怎么验证

在仓库根目录运行;需要 Docker Compose,以及支持场馆网络权限的 Linux 容器环境。每个演练请单独运行:

./scripts/dev.sh build-image
sh lab/keys.sh
docker compose -f lab/compose.yaml up -d --build
sh lab/ticket-trust.sh
sh lab/north-entrance.sh
sh lab/device-tls.sh

每个演练都应在门票经数据中心送达的情况下通过;清理时应确认 hub 和受检闸机都装回了原来的票单。

Wang Hao and others added 9 commits October 28, 2026 15:00
On-call staff could only read raw /metrics. Provision a dashboard for
the existing hub series: incomplete ticket replies, TLS handshake
failures, and per-gate list status.

Use a separate Compose file so the venue lab and its drills need no
Grafana password. Pin both images by tag and digest.

Keep the earlier sync-metrics regression test for the existing sync
accounting fix, and check dashboard metrics against the hub.

Co-authored-by: Yuki Tanaka <yuki.tanaka@elsworne.example>
The hub recorded connections that had not identified themselves under
the name "unknown". Writing list status for every record made that
pseudo-gate look like a gate reporting no version.

Write list status only for gates that identified themselves and sent
a heartbeat. A CONFIG from an unidentified connection records nothing.
… the uplink watcher has stopped

Cut both data-centre exits, restore them, then kill the hub's uplink
watcher. Compare Mailpit message IDs across each separate fault.

Each case expects exactly one mail to manager@elsworne.example from
alerts@elsworne.example through the venue's own mail server, which
remains available without the data-centre link. The subjects are
"Data centre unreachable" and "Uplink watcher stopped". Allow 20 s:
5 s for the probe, 10 s for the alert threshold, 1 s for the alert
loop, and 4 s for mail submission; the watcher checks every second.

Today neither mail is sent, so both judgements fail. Exit 0 means both
pass, 1 means a judgement fails, and 2 means an environment or cleanup
failure.
…he uplink watcher stops

The hub logged data-centre failures, and the uplink watcher could exit
without notifying the venue.

Submit mail after the shared alert threshold, once per incident. Keep
sent incidents in the atomic state file across hub restarts, and re-arm
each alert when its condition recovers without sending recovery mail.

Have the watcher update a heartbeat file each loop. Its modification
time uses the clock shared with the hub, since a shell cannot portably
read a monotonic clock. Give restarted hubs a fresh threshold of grace.

Add a CI test for transient and repeated faults, recovery, mail headers,
restart persistence, and the watcher grace period.

Co-authored-by: Yuki Tanaka <yuki.tanaka@elsworne.example>
A signed barcode of about 159 characters does not fit the binary
list's 32-byte record. Publish a 20000-ticket signed text list at
/season.txt from both data-centre services at lab scale. Keep the
signing key in dc and dc2 only. Leave /tickets.gpb and the hub
unchanged. Test publication with the gates' signature verifier,
HTTP and TLS responses, caching, ranges, and tampering.
Move ticket marking out of add_entry. Startup journal loading still
marks each entry in order; after a new reports_record result, the hub
marks the ticket under store_lock before updating status and metrics
or replying.

The ticket store is read under store_lock during requests, and the
report lock is never held with it. Behaviour is unchanged: admission
was already thread-safe and the store does not change at run time
today. Document the lock order and startup journal marking.
The hub still rejects a signed ticket found only in the synced season list, although a successful sync should make that list available for decisions. After the start file changes in place, /tickets serves its new bytes while scans still use the loaded list; both should use the same snapshot. Growing or shrinking the file during a /tickets reply changes the bytes sent, and a short reply is counted as 200; the reply should contain the loaded list and be counted accurately.
The hub synced a list it never used for decisions, while /tickets reread the start file on every request. A header-time ETag could leave the hub on an old list behind repeated 304 replies.

The hub now syncs /season.txt, checks the installed body before conditional requests, and switches decisions and /tickets together using a reference-counted snapshot. It carries used admissions and recorded offline reports across a switch.

Here verified means the downloaded file SHA-256 matches the confirmed ETag, the whole list loads under the start-file rules, and the file and its directory have been synced.
After the hub fix, the hub takes its season list from the data centre and serves the verified in-memory list. Drills that rewrote the hub start file and restarted it now publish their extra tickets from the data centre. The drills wait for installation and restore the previous publication during cleanup.
@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Wang Hao · reviewer

Why keep the extra-ticket directory invisible to the hub and gates?


为什么不让 hub 和闸机直接看到追加门票的目录?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Noah Williams · author

They must receive changes through sync and download. Only dc and dc2 mount lab/dc-runtime/, so the drills exercise the real distribution path.


它们必须经过同步和下载拿到变更。只有 dc 和 dc2 挂载 lab/dc-runtime/,这样演练走的才是真实的分发路径。

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Yuki Tanaka · reviewer

north-entrance.sh no longer restarts the hub to load tickets. Does anything still clear the learned path MTU between runs?


north-entrance.sh 不再靠重启 hub 来加载门票了,那两次运行之间还有什么会清掉 hub 学到的路径 MTU?

@TN019

TN019 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Noah Williams · author

Cleanup still restarts the hub after the restored list is installed, and then checks that all four gates are seen again with the restored list and that both north routes are back.


清理时仍会在装回原票单后重启 hub,然后确认四台闸机都重新出现、都装上了原票单,两条北入口路由也已恢复。

@TN019
TN019 merged commit 1d3e569 into main Dec 1, 2026
5 checks passed
@TN019
TN019 deleted the test/data-centre-list-updates branch December 1, 2026 02:38
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