Pilot migration UI and sandbox: scenario check for v1.0.0-beta
Pilot has a new update and migration UI, and a new workload sandbox. Before the v1.0.0-beta release, this page checks two things:
- Does the migration workflow handle every case that a user can reach, and does the UI give the right action in each case?
- Do the main apps work when the sandbox is on?
Each problem that I found has a pull request. A few problems need a decision first. They are in Open items.
Summary
Live pass means that I ran the case on the test server. Unit test means that a test in the Pilot suite covers the case. Fixed means that the case was broken and a pull request fixes it. Gap means that the case is not handled yet.
How the migration workflow works
An update or a site migration is a migration operation. The operation is a JSON record in <bench>/migrations/. It holds the state, the sites, the app revisions and the recovery data. Small tasks do the work, one step at a time. After each step, the operation selects the next task.
The normal path is: preparing → backing_up (one task per site) → updating (one task) → migrating (one task per site) → completed. When a step fails, the operation stops in needs_attention. The user can then choose Retry, Skip patch, Restore or Dismiss. While the backups run, the user can also choose Stop.
Sources: docs/migration.md, pilot/core/bench/migration/, and the UI in admin/frontend/dashboard/src/pages/updates/.
Migration scenarios
Normal path
| # | Scenario | What Pilot does | Status |
|---|---|---|---|
| 1 | Update apps that change the schema | Backs up each affected site, updates the apps, migrates each site, restarts the services. | Unit test |
| 2 | Update apps with no migrate changes | Skips backup and migrate. Updates the apps, rebuilds assets, restarts. The dialog hides the backup option. | Unit test |
| 3 | Update some apps on a bench with many sites | Backs up and migrates only the sites that have a selected app. A site whose apps are unknown is included. | Unit test |
| 4 | Migrate one site with safeguards | Backup, migrate, complete. The site leaves maintenance mode. | Live pass (sandboxed v16, CRM) |
| 5 | Migrate one site in place (no safeguards) | No backup, so no Restore later. | Unit test |
| 6 | Switch an app's branch on a bench with sites | Switches the code, then queues a site migration with backups. The migration takes over the switch task's locks. | Unit test |
| 7 | The disk cannot hold the backups | Refuses before any site enters maintenance (HTTP 507). | Unit test |
| 8 | Backups go to S3 | Streams the MariaDB table dumps to the bucket. The disk check counts only local backups. | Unit test |
| 9 | Background jobs are still running | Waits up to 300 s before each step. If the jobs do not finish, it pauses before the step starts. | Unit test |
| 10 | Web restart around maintenance mode | Restarts web once after maintenance turns on and once after it turns off. A failed restart pauses the operation. | Unit test |
| 11 | A second update while one is unresolved | Refuses the second update (409). | Unit test |
Failures
| # | Scenario | What Pilot does | Status |
|---|---|---|---|
| 12 | A backup fails | Pauses in needs_attention and returns every site to its old maintenance settings. Retry takes all backups again. | Unit test |
| 13 | App fetch, validation, install or build fails | No site data has changed, so Pilot reverts the apps by itself and ends in reverted. | Unit test |
| 14 | A site migrate fails on a patch | Pauses in needs_attention. The site stays in maintenance. The UI shows the failing patch and the output. | Live pass (v16 and nightly, LMS, test patch) |
| 15 | The final service restart fails | Pauses. Retry restarts the services again and does not migrate the sites again. | Unit test |
| 16 | A task is killed, or its process dies | The task's callback pauses the operation with "The task stopped before it finished". | Unit test |
| 17 | A killed migrate had changed some tables | Keeps the list of touched tables, so Restore puts them back. | Unit test |
| 18 | The operation fails to start (for example, a branch switch with too little disk space) | Before the fix: the record stayed in preparing. That blocked every new update and every backup of its sites. No UI action could close it. The app also stayed on the new branch. | Fixed: #859 |
| 19 | A backup fails after a branch switch | Before the fix: Pilot took the sites out of maintenance. They then served the new code on a database that was not migrated. | Fixed: #860 |
Recovery actions
| # | Scenario | What Pilot does | Status |
|---|---|---|---|
| 20 | Retry | Runs the failed step again. Sites that already succeeded are not migrated again. | Unit test |
| 21 | Skip patch | Only for the diagnosed patch. Marks the patch as done, and the migration continues by itself. | Live pass (nightly, LMS) |
| 22 | Skip patch with an old patch name | Refuses (409). The name must match the current diagnosis. | Unit test |
| 23 | Restore | Reverts the apps, restores the touched tables, drops the tables that the migration made, then restarts. The site leaves maintenance. | Live pass (v16, LMS: the table that the test patch made was removed) |
| 24 | Restore with a missing or bad backup file | Checks every dump before it imports any. | Unit test |
| 25 | Restore fails part way | Goes to revert_failed. Restore again resumes from the last checkpoint. | Unit test |
| 26 | Restore when the list of touched tables is not trusted | Restores every table in the backup. | Unit test |
| 27 | Restore after a site was dropped or an app was removed | Skips them. Nothing is left to restore. | Unit test |
| 28 | Dismiss | Restarts on the code that is on disk, lifts maintenance, deletes the backups, and keeps the record as history. | Unit test |
| 29 | Dismiss while the update runs, or when the restart fails | Refuses while it runs. A failed restart keeps the operation open. | Unit test |
| 30 | Stop during backups | Cancels the backup task, deletes the backups taken so far, lifts maintenance and ends in stopped. | Live pass (nightly, ERPNext) |
| 31 | Stop after the update started, or after a branch switch | Refuses (409). The code has changed. | Unit test |
| 32 | Stop while the chain queues its next task | Cancels the queued task too, or withdraws the stop if that task already runs. | Unit test |
| 33 | A stopped update's detail page | Shows the interrupted backup as stopped, not as running. | Code check (UpdateFlow.vue) |
| 34 | Buttons shown in each state | Retry only in needs_attention. Skip patch only with a diagnosed patch. Restore only when every site has a backup. Stop only while backing up. Dismiss from the alert. | Code check |
| 35 | Restore after a branch-switch backup failure | Restore needs a backup of every site, so it is not offered. The user can only Retry or Dismiss. They cannot return the app to its old branch from the UI. | Gap |
| 36 | Docs for the UI | docs/migration.md pointed to the removed pages/migrations/, and its Closed tab did not include stopped. | Fixed: #862 |
Sandbox
The sandbox runs each workload process (web, workers, redis) with an empty home folder, without the other benches, and with a read-only system. A new systemd bench has the sandbox on by default. Before Pilot writes the units, it starts a trial unit. If the trial fails, Pilot runs the bench without the sandbox and only logs a warning.
Finding: the sandbox never runs on Ubuntu 24.04 and later
Ubuntu 24.04 and 26.04 set kernel.apparmor_restrict_unprivileged_userns = 1. systemd then cannot make the user namespace that the sandbox needs, and the trial fails with exit code 226. On the test server both benches ran without the sandbox, and no one saw a warning.
An AppArmor profile that lets systemd-executor make user namespaces fixes this. With that profile, both benches started in the sandbox. #861 adds the profile to install.sh. It is a draft, because the profile applies to the whole host. See Open items.
Apps with the sandbox on
Both benches are in production mode (systemd, nginx, lite mode) with sandbox = true. Each check ran on each site:
- Pages:
/api/method/ping,/login, the app page, and the first JS or CSS asset on that page, served by nginx. - Logged in: the app page as Administrator, and the installed apps from
get_versions. - Background job: a database backup queued from outside. In lite mode it runs in the sandboxed web process and writes to
sites/<site>/private/backups. - Migrate:
pilot -b <bench> frappe --site <site> migrate. It runs outside the sandbox, throughunsandboxed_entry.py.
| App | Bench | Pages | Logged in | Job | Migrate | Apps on the site |
|---|---|---|---|---|---|---|
| ERPNext | v16 | pass | pass | pass | pass | frappe, erpnext |
| ERPNext | nightly | pass | pass | pass | pass | frappe, erpnext |
| CRM | v16 | pass | pass | pass | pass | frappe, crm |
| CRM | nightly | pass | pass | pass | pass | frappe, crm, whatsapp |
| Helpdesk | v16 | pass | pass | pass | pass | frappe, helpdesk, telephony |
| Helpdesk | nightly | pass | pass | pass | pass | frappe, helpdesk, telephony |
| Learning (LMS) | v16 | pass | pass | pass | pass | frappe, lms, payments |
| Learning (LMS) | nightly | pass | pass | pass | pass | frappe, lms, payments |
| Gameplan | v16 | pass | pass | pass | pass | frappe, gameplan |
| Gameplan | nightly | pass | pass | pass | pass | frappe, gameplan |
| Builder | v16 | pass | pass | pass | pass | frappe, builder |
| Builder | nightly | pass | pass | pass | pass | frappe, builder |
CRM's /crm gives 403 and ERPNext's /app gives 301 to a guest. These are the normal login redirects. As Administrator, all pages load. ERPNext v16 sends /app to /desk.
The migration workflow also works with the sandbox on: rows 4, 14, 21, 23 and 30 above ran on the sandboxed benches.
Finding: Helpdesk article search fails on Pilot
Helpdesk's knowledge-base search uses the RediSearch module (FT.SEARCH, FT.CREATE). Ubuntu 26.04 ships Redis 8.0.5 without that module, so helpdesk.api.article.search gives HTTP 500, and the search index job fails. The sandbox does not cause this. Article saves still work, because Helpdesk checks for the index first. To fix it, Pilot must run a Redis build that has the search module, for example from packages.redis.io. That choice affects licensing, so this page lists it as an open item.
Pull requests
| PR | What it fixes | Found by |
|---|---|---|
| #850 | Ubuntu's mariadbd AppArmor profile blocks Pilot's MariaDB, so pilot init fails (issue #844). Keeps admin rules in local/mariadbd. | Issue |
| #851 | The stdlib-only CLI has no PyMySQL, so every site-database read returned nothing (clone-site, install-app, restore, backups; issue #845). Queries now run with the bench's own driver. No new CLI dependency. | Issue |
| #852 | clone-site writes no db_socket, so a clone can reach a system MariaDB (issue #846). | Issue |
| #853 | Admin SQL batches time out after 5 s under load (issue #847). | Issue |
| #854 | The prebuilt asset build does not check out required apps, so CRM develop has no prebuilt assets. | App tests |
| #855 | get-app takes dependency ranges from an old marketplace entry, so nightly CRM installs whatsapp 1.1.1 and fails. | App tests |
| #856 | Two benches that initialise at once race on MariaDB setup. | App tests |
| #857 | Two benches that initialise at once race on the Admin frontend build (dev installs). | App tests |
| #858 | get-app clones the whole app before it finds that the bench is not initialised. | App tests |
| #859 | A migration that fails to start stays in preparing and blocks all updates (row 18). | This check |
| #860 | A branch switch's sites leave maintenance when a backup fails (row 19). | This check |
| #861 (draft) | The sandbox never runs on Ubuntu 24.04 and later. | This check |
| #862 | Migration docs point to the old UI files (row 36). | This check |
#853 and #856 both add a test at the end of tests/pilot/managers/test_mariadb_manager.py. The PR that merges second gets a small conflict.
Open items
| Item | Why it needs a decision |
|---|---|
| Decide Sandbox on Ubuntu (#861) | The profile lets every service that systemd starts on the host make user namespaces again. That reopens part of what Ubuntu's restriction closes. The other options: leave the sandbox off on Ubuntu and document it, or make the installer step opt-in. |
| Decide Redis search module | Helpdesk article search needs it. Ubuntu's Redis does not have it. A Redis build with the module comes with different license terms. |
| Gap Restore after a branch-switch backup failure | Row 35. Restore could revert the app when no site has been migrated, without site backups. This needs a small change to can_revert and the restore chain. |
| Gap No CLI key for the sandbox | pilot set-bench-config has no production.sandbox key, so the only way to turn the sandbox on or off is to edit bench.toml. |