Back to Field Notes
Log

One Sunday, 31 pull requests, and Kremio Connect on every site

After nearly six weeks without a commit, all of this week's work happened on Sunday, October 11. We started the Kremio mobile app, put Kremio Connect into every v16 site's image, and fixed several gaps in how a site is updated and how its health is reported.

Covers
Written
Repositories
kremio, kremio-connect, infinary_controls, infinary_agent, infinary.io
Pull requests
31
Reading time
3 min
#kremio-connect#golden-image#sidecar#control-plane#portal
Contents

Six quiet weeks, then one Sunday

Between August 31 and October 11 there wasn’t a commit in any of our repositories. Nothing we wrote down says why the work paused, or why it started again when it did, so this note doesn’t guess. It restarted with something new: at 03:12 on Sunday, October 11, Nikolas created an empty repository for Kremio, our mobile app for ERPNext. By midnight, 31 pull requests had merged across five repositories.

Kremio and its companion Frappe app, Kremio Connect, have their own note. This one covers getting Kremio Connect onto every site, and what that taught us about how our sites get updated.

Putting an app on every site

Every Infinary site runs our (The server image every Infinary site runs: Frappe, ERPNext and our own apps, pinned to exact versions and tested together.), a prebuilt ERPNext image, and is updated by swapping to a newer one. In the afternoon we moved the image to ERPNext 16.50.0 (its own note), then baked Kremio Connect into the v16 image. Each component’s version is part of the image tag (-kc<version> for Kremio Connect), because the fleet compares tag strings to decide whether an image is new.

Baking it in was the easy half. An app in an image does nothing on a site until it’s installed: sites/apps.txt lives on the sites volume and hides the image’s copy, and bench migrate only touches apps the site already has. So the (The small Infinary agent that runs next to ERPNext on each server. It runs updates, app installs and rollbacks, and only ever connects outward.), the agent on each box that applies updates, now installs listed apps during an image update (sidecar 0.10.0), inside the same snapshot and maintenance window. If an install fails, it rolls back in a fixed order: restore the database, remove the apps.txt line, then revert the image. An apps.txt that names code the image doesn’t carry makes every request fail with a 500.

A rehearsal on a box-shaped Docker stack updated in 56 seconds and installed Kremio Connect on the way. That evening we found the same gap in the v15-to-v16 upgrade path, which swapped onto the new image without installing the app (sidecar 0.10.3).

Fixes to updating and reporting

Several fixes to how a site is repaired and reported went in the same day:

  • Containers that stay stopped. frappe_docker’s pwd.yml sets restart_policy: on-failure. MariaDB and Redis exit 0 on SIGTERM, so after a Docker daemon restart Docker leaves them stopped. gunicorn exits non-zero, so it comes back and answers every request with a 500 and Unknown server host 'db'. Bring-up now rewrites the policy to any, and a test runs the rewrite against the current upstream file.
  • A report that could go stale. The sidecar read the site’s versions through the site itself. When that call raised, it aborted the whole cycle: no heartbeat and no job polling, and the control plane kept the last good report. Sidecar 0.10.1 heartbeats as “degraded”, reading versions from the code in the container, and keeps polling for jobs. The portal now flags any report older than 10 minutes.
  • Update now refused. On a site that wasn’t healthy it answered 409, “Instance must be healthy before updating”. That check exists to stop unattended migrations on a sick site, and it also refused the operator exactly when a repair was needed. Admins now have a Force update; a force flag from any other caller is dropped.

Two more update paths didn’t work as written. Sidecar self-update had never run on a box our bring-up script built: the variable that turns it on was never set, the service ran a fixed file instead of the link self-update flips, and the image refresh would have copied an older sidecar back over a newer one. So a box only got a sidecar fix by taking a whole image update. And when the crash-loop guard reverted a bad sidecar, the next update window offered the same version again; the guard now records what it backed out of (sidecar 0.10.2).

The rest of Sunday

  • Four Infinary Controls releases in about seven and a half hours (0.5.0 to 0.8.0), including a Desk page that shows the site’s address and a QR code for connecting the app. The QR code first rendered blank: in Frappe 16, get_qr_svg_code returns base64 bytes, which reached the browser as a list of integers. Running the page against a real v16.50 site caught it.
  • Agent drafts reached nobody. Kremio’s approvals inbox only saw drafts made through its own tools, while our agents and Aria drafted through Frappe Assistant Core. Controls 0.6.0 flags what the agent user creates.