|
| 1 | +# User Factory |
| 2 | + |
| 3 | +The user factory creates unprivileged users on a shared illumos machine to run |
| 4 | +jobs. The factory ensures each job runs in an ephemeral system user with no |
| 5 | +privileges and no ability to write files outside of allowlisted directories, and |
| 6 | +cleans up any leftover files at the end of the job. |
| 7 | + |
| 8 | +It currently only supports running on illumos, and requires that the factory |
| 9 | +runs with the `Primary Administrator` profile. |
| 10 | + |
| 11 | +## Slots |
| 12 | + |
| 13 | +The factory configuration has to define one or more named "slots". Each slot |
| 14 | +has a buildomat target it supports, plus optional configuration to define its |
| 15 | +execution environment. When the a job comes in from the buildomat core server, |
| 16 | +the factory will only accept it if there is a free slot for that job's target. |
| 17 | +This means the number of slots is also the concurrency limit on that system. |
| 18 | + |
| 19 | +The minimal slot configuration requires only a slot name and the ID of the |
| 20 | +buildomat target the slot supports: |
| 21 | + |
| 22 | +```toml |
| 23 | +[slots.NAME] |
| 24 | +target = "TARGET_ID" |
| 25 | +``` |
| 26 | + |
| 27 | +Additional configuration options are available: |
| 28 | + |
| 29 | +* **`add_to_groups = ["GROUP", "GROUP"]`**: add the ephemeral system user to |
| 30 | + these groups in addition to the primary (ephemeral) group. This can be useful |
| 31 | + to allow jobs running in the slot to access system capabilities guarded by |
| 32 | + group membership. |
| 33 | + |
| 34 | +* **`env.KEY = "VALUE"`**: set arbitrary environment variables in jobs executed |
| 35 | + inside of this slot. |
| 36 | + |
| 37 | +An example of a full slot configuration: |
| 38 | + |
| 39 | +```toml |
| 40 | +[slots.hubris-1] |
| 41 | +target = "..." |
| 42 | +env.HUMILITY_ENVIRONMENT = "/opt/ci/humility/1.json" |
| 43 | +add_to_groups = ["usb"] |
| 44 | +``` |
| 45 | + |
| 46 | +## Isolation |
| 47 | + |
| 48 | +Each job runs as an ephemeral user, with randomly generated UID and GID, |
| 49 | +guaranteed not to collide with any UID and GID currently in use on the system. |
| 50 | +The name of the user is the worker ID prefixed by `bmat-`. |
| 51 | + |
| 52 | +The whole filesystem is enforced to be read-only, except for a few allowlisted |
| 53 | +directories. All writeable directories are empty at the time the job starts, and |
| 54 | +are purged at the end of the job. The following directiories are writeable: |
| 55 | + |
| 56 | +* `/home/$USER` |
| 57 | +* `/input` |
| 58 | +* `/opt/buildomat` (used by the buildomat agent) |
| 59 | +* `/tmp` |
| 60 | +* `/var/run` (used by the buildomat agent) |
| 61 | +* `/var/tmp` |
| 62 | +* `/work` |
0 commit comments