Back to Field Notes
Deep dive

Coded from the docs, fixed against the live API: one Thursday in June

Our Backup and DR integration merged at 07:57 having never touched a real backup vault. By 12:49 we had fixed seven defects that turning it on exposed. That afternoon we found out why Update now had only ever skipped.

Covers
Written
Repositories
infinary.io, infinary_agent
Status
Shipped
Reading time
5 min
#control-plane#google-cloud#golden-image#erpnext
Contents
from merge to the last live fix
07:57 → 12:49
defects found by turning it on
7
were guesses about Google Cloud
5 of 7
for the site to answer after the first real image swap
~55 s

What we shipped that morning

At 07:57 on Thursday, June 25, a large pull request merged into the control plane. It carried two others with it: backups through Google Cloud Backup and DR, and a kill switch plus an auto-update policy.

The backup design was sound. The agent on each instance only makes outbound calls and can’t reach Google Cloud’s APIs, so the control plane triggers the backup itself, against a backup plan attached to the instance’s VM, and polls the long-running operation until it finishes. Where Backup and DR isn’t configured, it falls back to asking the agent for a bench backup.

What the live API said

Over the next five hours, in the order we hit them:

  1. 08:30. The VM was never named. The fields that tell the control plane which VM and zone to back up had been added with the feature, but nothing filled them in, so protection was skipped on every instance’s first heartbeat. The provisioner now records them after a successful Terraform apply.
  2. 09:09. A role that doesn’t exist. The setup instructions named two IAM roles we had guessed. IAM rejected one of them: it isn’t a real role. We replaced both with the real ones and added a one-line command to list the valid roles on a project.
  3. 09:13. Case matters. The command line rejected the backup plan’s recurrence written in lowercase; it wants DAILY. Creating the plan’s association with the VM also needed an explicit resource type.
  4. 09:18. Underscores. We built the association’s ID from our instance ID, and our instance IDs contain underscores, which Google Cloud resource IDs don’t allow. Every call failed with “Malformed name”. The ID is now sanitized the same way everywhere, so the one-time manual setup and every later call name the same resource.
  5. 09:40. The vault and the disk disagreed about keys. Our disks are encrypted with our own key ( (Customer-managed encryption keys: Google Cloud encrypts the data with a key you create and control in Cloud KMS, instead of a key Google manages for you.)). A vault created with Google-managed encryption can’t hold their backups: “vault is not CMEK enabled”. The control plane now creates the vault with our key when one is configured. Granting Backup and DR’s service agent access to that key stays a manual step.
  6. 11:27. The wrong host. Exercising the live portal produced a short report: “none of the actions work”. Our calls went to a regional hostname for the API, and it answered 404. Backup and DR is served from a single global host, with the location in the request path. With that fixed, listing data sources worked and we triggered a real on-demand backup.
  7. 12:49. An undefined that blocked everything. Actions that finish without a result, like clearing the cache or restarting, wrote result: undefined to Firestore, which rejects it. The request failed with a 500, the action stayed “running”, and because only one action may run at a time per instance, every action after it was refused. We turned on Firestore’s ignoreUndefinedProperties, and a stuck action older than three hours no longer blocks new ones.

The same round of live testing also found the admin customer list crashing on an organization record with no members field, and our own site’s record still holding placeholder VM coordinates from before any of this existed, which needed a way for an admin to correct them.

Update now only ever skipped

With backups working, we turned to the “Update now” button, which had never once applied an update on our site. It always skipped.

At 13:28 we changed the model: an update is a move to a curated image, not to a version. The agent reports the image it is running, the control plane says which image is approved, and the portal shows the difference.

Widening the pattern to *-database*.sql.gz fixed it, and by 13:48 the agent had done the whole sequence live: backup, swap from v16-2.6.2 to v16-2.6.3, migrate, verify. The site answered again after about 55 seconds.

That was a swap between two builds of our image. Before attempting a real ERPNext upgrade on our site, from 16.23.1 to 16.25.0, a review of the rollback path found three problems that only a real migration would trigger: a single failed health check could roll back a migration that had succeeded, the wait for a cold container to boot was about 150 seconds and too short (now about five minutes), and nothing put the site into maintenance mode during the migration, so anything a user saved in that window would be lost on rollback. All three were fixed at 14:10. A pull request on August 24 still described our site as running 16.23.1, so that upgrade didn’t happen in June.

What we’d tell someone else

And when a safety check refuses every time, it isn’t being careful: it’s telling you your model of the thing it checks is wrong.