Putting SIM OTA data under git, and the assumption that broke it
A deployment pipeline that diffs one commit back cannot retry a failed run, which is the first thing CW-1648 (November 2024) had to unlearn.
The SIM OTA data lived on one server and nowhere else. Field definitions, the provisioning
database, and the SMS scripts that write PLMN lists and clear LOCIs on a live SIM — edited in
place, by whoever was on the ticket, with no history. The first commit of CW-1648 (November
2024) imported 114 files into ota-data/: fields.xml at 1,156 lines, twenty-odd text files
under db/, and about seventy binary smsscripts/*.script files, most of them exactly 65,800
bytes. Nothing was transformed, renamed or regenerated. The point was that the files now had a commit behind them (and a reviewer in front of them).
The first workflow looked back exactly one commit
- uses: actions/checkout@v3
with:
fetch-depth: 2
Then git diff --name-only HEAD~1 HEAD -- ota-data/, and an scp per changed file
after an ssh mkdir -p for its directory. That holds on a repository where every push is one commit and
every run succeeds. Neither is true here. A push can carry three commits, and a run that
dies on SSH authentication deploys nothing — but the next push still diffs one commit back, so
the files the failed run skipped are never retried. The pipeline held no model of the server at all; it knew one thing (what changed since the
previous commit) and inferred the rest.
Recording what was deployed instead of guessing
The replacement (December 2024) stopped inferring state and started storing it. Each run
uploads a deployment-metadata artifact naming the commit it deployed, the next run downloads
it with continue-on-error: true, and the diff runs from that commit to HEAD with
fetch-depth: 0. No metadata means a first deployment, so everything in the watched list goes.
Per-file scp became one make call, and rsync decides what to copy.
That version carried a defect worth naming, because it is the kind that reads correctly:
echo "${WATCHED_FILES_FOLDERS}" | while IFS= read -r ITEM; do
CHANGED_FILES="$CHANGED_FILES $ITEM_CHANGES"
done
The right-hand side of a pipe runs in a subshell, so every assignment to CHANGED_FILES is
discarded when the loop ends — the test after it (if [ -z "$CHANGED_FILES" ]) sees an empty
string every time. The exit 0 in that branch does not help either, since exiting a step with
zero ends the step and not the job. Both bugs are invisible in review and silent at runtime:
the log says "No changes detected" and the run goes green.
What the rsync side ended up looking like
Two filters and a recursive dry run (fifteen lines in all) carry most of the useful surface:
OTA_RSYNC_COMMAND=rsync -avz --progress -e 'ssh -p 2222 -o StrictHostKeyChecking=accept-new' \
--filter '-/ **/simota/db/*.bin' \
--filter '-/ **/simota/smsscripts/*-backup'
dry-run-deploy-ota-files:
$(MAKE) deploy-ota-files EXTRA_RSYNC_ARGS="--dry-run"
The dry run is the same target with one argument added, so there is one code path and not two that drift
apart. The filters drop the script bytecode caches (db/*.bin) and the server's own
automated backups (smsscripts/*-backup) — files the server owns and git has no business
overwriting. The deploy list is also deliberately narrower than the pull list: push
fields.xml and db/, pull those plus bindata/ and smsscripts/.
The assumption that was still wrong
Colleagues fixed the SSH authentication and moved the target to the production directory, and to the
service account, inside the same week (three commits, 3 December). The deeper problem took a year to surface, and it was
mine: the design assumed a single writer (git). There are two. Operators edit the OTA data on the
server directly, so a one-way rsync --delete from main can discard work that was never
committed.
The fix, added by a colleague in December 2025, is a guard, not a sync. Before
deploying, the job checks out HEAD~1, runs make dry-run-pull-from-server, and greps the
itemised rsync output for ^>f[^ ]*[+sc] — the marker for a file the server has and the
previous commit did not. If anything matches, the deploy aborts with exit 1 and a
workflow_dispatch fires a pull workflow that opens a PR with the server's version. Commits
whose message contains sync: Pull changes from <the OTA server> skip the check, otherwise the
guard would block its own output.
That is the part I would keep from this ticket. Getting files into git is a day's work; deciding which side is authoritative when both can write is the actual design, and a pipeline that assumes the answer will be wrong quietly instead of loudly.