@crvouga/homelab 0.23.6 → 0.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -26
- package/ansible/macos/legacy-monitoring.yml +22 -0
- package/ansible/macos/manager.yml +1 -0
- package/ansible/macos/policy.json +4 -0
- package/ansible/macos/tasks/legacy-agent.yml +28 -3
- package/ansible/ubuntu/disk-gc.py +60 -10
- package/ansible/ubuntu/policy.json +42 -16
- package/ansible/ubuntu/pressure-guard.py +2 -5
- package/ansible/ubuntu/tasks/recovery.yml +4 -0
- package/ansible/ubuntu/tasks/resources.yml +58 -10
- package/cliproxy/docs/backup.md +15 -0
- package/cliproxy/scripts/backup +218 -182
- package/cliproxy/scripts/cli.py +1 -1
- package/cliproxy/scripts/retention.py +16 -12
- package/docs/convergence.md +3 -0
- package/docs/manager-recovery.md +7 -0
- package/docs/runbooks.md +14 -3
- package/docs/ubuntu-sync.md +27 -5
- package/mise.lock +82 -138
- package/mise.toml +16 -16
- package/package.json +4 -3
- package/src/cli/fleet-sync.ts +23 -4
- package/src/cli/legacy-monitoring.ts +41 -0
- package/src/cli/register-fleet.ts +1 -1
- package/src/manager-health.ts +1 -1
- package/src/node-converge-linux.ts +2 -17
- package/src/platform/resource-verify.ts +84 -12
- package/src/platform/ubuntu-baseline.ts +47 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# homelab
|
|
2
2
|
|
|
3
3
|
Keeps a set of development machines in sync: one **manager** and many
|
|
4
|
-
**workers**. One command, `
|
|
4
|
+
**workers**. One command, `converge`, brings every machine to the same
|
|
5
5
|
pinned tools, the same coding agents signed in through one proxy, the same
|
|
6
6
|
uptime policy and the same monitoring. Adding or removing a machine is one
|
|
7
7
|
entry in `fleet.json`.
|
|
@@ -30,7 +30,7 @@ storage bucket you own. Nothing else has to be kept:
|
|
|
30
30
|
| The version of homelab | The `@crvouga/homelab` dependency in your `package.json` |
|
|
31
31
|
| The fleet state: the enrolled workers, the approved revision, the configuration applied | Your bucket (any S3-compatible service) |
|
|
32
32
|
| Secrets | The provider `fleet.json` names (`vault`, `sops`, `file` or `env`) |
|
|
33
|
-
| The source, checkouts, tools and reports homelab puts on a machine | A cache: delete it and `
|
|
33
|
+
| The source, checkouts, tools and reports homelab puts on a machine | A cache: delete it and `converge` rebuilds it |
|
|
34
34
|
|
|
35
35
|
The CLI proxy and the monitoring hub on the manager still keep data of their
|
|
36
36
|
own; [known limits](#known-limits) says what is lost with the manager.
|
|
@@ -39,7 +39,7 @@ own; [known limits](#known-limits) says what is lost with the manager.
|
|
|
39
39
|
|
|
40
40
|
homelab is opinionated. These are part of it, not options:
|
|
41
41
|
|
|
42
|
-
- The **manager** is a macOS machine. You run `
|
|
42
|
+
- The **manager** is a macOS machine. You run `converge` on it, and it hosts
|
|
43
43
|
the shared services (the CLI proxy and the monitoring hub) in Docker Desktop.
|
|
44
44
|
- **Workers** are Ubuntu 26.04 or 24.04 machines reached over SSH. They are stateless:
|
|
45
45
|
everything on them is rebuilt from Git and your secrets.
|
|
@@ -95,7 +95,7 @@ out of Git: pass them from wherever you keep secrets (a password manager's
|
|
|
95
95
|
`run` command, a git-ignored `.env`, your shell). They are read from the
|
|
96
96
|
environment and never taken from arguments.
|
|
97
97
|
|
|
98
|
-
`
|
|
98
|
+
`converge` converges the manager first, then every worker over SSH. It
|
|
99
99
|
fetches the commit your `homelab` version was published from, sends it and
|
|
100
100
|
your configuration to each machine, installs the pinned toolchain, applies the
|
|
101
101
|
Ansible policy and verifies the result. It prints one table and writes a full
|
|
@@ -167,11 +167,11 @@ the fleet state records: after an upgrade whose canary failed, that is the
|
|
|
167
167
|
revision the fleet still runs. A rollback covers what a revision declares: the
|
|
168
168
|
checkout, the pinned tools and T3 Code. System packages roll forward only
|
|
169
169
|
(apt never downgrades them), so a release that moved one keeps it. Installing
|
|
170
|
-
an older version and running `
|
|
170
|
+
an older version and running `converge` does the same for any earlier
|
|
171
171
|
release.
|
|
172
172
|
|
|
173
173
|
The fleet moves only to a revision on the default branch of the source
|
|
174
|
-
repository, which every release is. `
|
|
174
|
+
repository, which every release is. `converge` asks the manager's own copy
|
|
175
175
|
of that repository, whatever selected the revision (the package, `--revision`,
|
|
176
176
|
`--rollback`, the schedule, a checkout, a hand-off from a worker), and refuses
|
|
177
177
|
any other with `FLEET_REVISION_UNMERGED` before anything changes.
|
|
@@ -184,7 +184,7 @@ every checkout on the machine whose pin is newer. `status` reports that
|
|
|
184
184
|
as the warning `TOOLCHAIN_DOWNGRADE` of `tool:mise`, and
|
|
185
185
|
`converge --allow-mise-downgrade` installs the older one on purpose, on
|
|
186
186
|
every machine it converges. Each revision runs its own bootstrap, and one from
|
|
187
|
-
before this rule installs exactly the mise it pins. So `
|
|
187
|
+
before this rule installs exactly the mise it pins. So `converge` reads the
|
|
188
188
|
pin from the revision's own files and measures the mise of the manager and of
|
|
189
189
|
each worker it is about to converge before that bootstrap runs anywhere: a
|
|
190
190
|
revision that would replace a newer mise is refused with
|
|
@@ -230,14 +230,14 @@ the T3 loopback service; a VS Code server installation remains a separate check.
|
|
|
230
230
|
## Your project's own tools
|
|
231
231
|
|
|
232
232
|
On a fleet machine the global mise configuration (`~/.config/mise/config.toml`
|
|
233
|
-
and its `mise.lock`) belongs to homelab: `
|
|
233
|
+
and its `mise.lock`) belongs to homelab: `converge` publishes it with the
|
|
234
234
|
fleet's pinned tools and the agent worktree roots mise must trust. A project
|
|
235
235
|
pins its own tools in its own `mise.toml` and installs them with
|
|
236
236
|
`mise install --locked` in its checkout. On a fleet machine mise installs a
|
|
237
237
|
project's tools only from the project's `mise.lock` (run `mise lock` after
|
|
238
238
|
changing a pin); a tool the lock does not name is refused. A project never
|
|
239
239
|
publishes a global configuration. If anything replaces homelab's, `status` fails the check
|
|
240
|
-
`tool:global-mise-config` until the next `
|
|
240
|
+
`tool:global-mise-config` until the next `converge`.
|
|
241
241
|
|
|
242
242
|
## Using it from code
|
|
243
243
|
|
|
@@ -252,7 +252,7 @@ an [issue](#bugs-and-feature-requests).
|
|
|
252
252
|
|
|
253
253
|
Your bucket is the source of truth for everything Git does not hold: the
|
|
254
254
|
roster of enrolled workers, the approved revision, and the configuration
|
|
255
|
-
`
|
|
255
|
+
`converge` last applied. It is one SQLite database that
|
|
256
256
|
[Litestream](https://litestream.io) replicates to the bucket. `fleet.json`
|
|
257
257
|
says where the bucket is and the command is passed its credentials:
|
|
258
258
|
|
|
@@ -274,7 +274,7 @@ come back from the bucket, and the machine is rebuilt from Git.
|
|
|
274
274
|
lost manager.
|
|
275
275
|
|
|
276
276
|
Some runs are started by a machine rather than by you: a worker that hands
|
|
277
|
-
`
|
|
277
|
+
`converge` to the manager, for example. They get no environment, so save the
|
|
278
278
|
credentials on the manager once (in `~/.config/homelab/bucket.json`,
|
|
279
279
|
readable by you alone):
|
|
280
280
|
|
|
@@ -282,7 +282,7 @@ readable by you alone):
|
|
|
282
282
|
npx @crvouga/homelab state --init
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
Without a bucket everything still works from the local copy, and `
|
|
285
|
+
Without a bucket everything still works from the local copy, and `converge`
|
|
286
286
|
warns that the manager holds the only one. [docs/state.md](docs/state.md)
|
|
287
287
|
explains how replication stays correct, how to move an existing fleet to a
|
|
288
288
|
project, and which state is not in the bucket yet.
|
|
@@ -334,7 +334,7 @@ commands stay the pinned CLIs with whatever sign-in you gave them.
|
|
|
334
334
|
refuse agent sessions above that number; without it nothing is refused
|
|
335
335
|
([a limit on agent sessions](docs/worker-contract.md#a-limit-on-agent-sessions)).
|
|
336
336
|
|
|
337
|
-
3. Run `
|
|
337
|
+
3. Run `converge`. A machine that has only an SSH server and an account
|
|
338
338
|
with sudo is enough: every pull request proves that against a bare
|
|
339
339
|
Ubuntu machine, over SSH
|
|
340
340
|
([`fresh-box.feature`](features/fresh-box/fresh-box.feature)).
|
|
@@ -345,7 +345,7 @@ autoinstall file with `--autoinstall`) holding the worker account with your
|
|
|
345
345
|
manager's key, the privilege rule, a host key the manager pins at once and the
|
|
346
346
|
pinned Tailscale with a short-lived single-use auth key from your secrets
|
|
347
347
|
provider (`tailnet-auth-key`). Boot a stock Ubuntu image with it, then add the
|
|
348
|
-
worker with `enroll` and run `
|
|
348
|
+
worker with `enroll` and run `converge`.
|
|
349
349
|
|
|
350
350
|
`npx @crvouga/homelab measure --id ID` measures what a worker is made of
|
|
351
351
|
(packages, active tools, always-on services) with a digest that is the same
|
|
@@ -356,12 +356,12 @@ names every difference from the declared pins and, with `--reference` (the
|
|
|
356
356
|
Remove a machine with `npx @crvouga/homelab retire --id ID --apply --yes`
|
|
357
357
|
(it revokes the worker's Vault token, forgets its host key and roster entry
|
|
358
358
|
and leaves a tombstone in the fleet state), then delete its entry and run
|
|
359
|
-
`
|
|
359
|
+
`converge`. To put a fresh machine in place of a worker under the same id,
|
|
360
360
|
run `npx @crvouga/homelab replace --id ID --host-key "TYPE BASE64" --apply
|
|
361
361
|
--yes` and then `converge --node ID`; the manager's T3 pairs with the new
|
|
362
362
|
machine's T3 by itself, with no code to copy. A run scoped with `--node` records only the
|
|
363
363
|
revision of the workers it covered; the fleet's applied revision moves with a
|
|
364
|
-
full `
|
|
364
|
+
full `converge`.
|
|
365
365
|
|
|
366
366
|
## Configuration
|
|
367
367
|
|
|
@@ -375,9 +375,9 @@ names the first field that breaks a rule (`{code, path, expected, actual}`);
|
|
|
375
375
|
`--ansible` also renders the Ansible inventory and syntax-checks every
|
|
376
376
|
playbook with the pinned Ansible.
|
|
377
377
|
|
|
378
|
-
Edit the `fleet.json` of your project, never the copy `
|
|
378
|
+
Edit the `fleet.json` of your project, never the copy `converge` installs
|
|
379
379
|
at `~/.config/homelab/fleet.json` for launchers and scheduled jobs:
|
|
380
|
-
`
|
|
380
|
+
`converge` replaces that copy, and refuses to run
|
|
381
381
|
(`FLEET_CONFIGURATION_COPY_CHANGED`) rather than lose an edit made to it by
|
|
382
382
|
hand, on the manager or on a worker it is about to converge, before anything
|
|
383
383
|
is changed. [docs/state.md](docs/state.md#day-to-day) says how to keep or discard
|
|
@@ -468,12 +468,12 @@ Retirement runs `paradev hosts remove`. The `paradev:*` checks only warn.
|
|
|
468
468
|
|
|
469
469
|
Under `t3.profile`, `fleet.json` names top-level T3 settings every machine
|
|
470
470
|
holds the same, such as tool servers. A setting not named there stays the
|
|
471
|
-
machine's own, and one edited on a machine since `
|
|
471
|
+
machine's own, and one edited on a machine since `converge` last wrote it
|
|
472
472
|
is reported as `T3_PROFILE_CONFLICT` by the check `t3:profile`, never
|
|
473
473
|
overwritten.
|
|
474
474
|
|
|
475
475
|
Accounts of one tool are not entitled to the same models. On each per-account
|
|
476
|
-
instance `
|
|
476
|
+
instance `converge` hides the models of T3's catalogue that its account does
|
|
477
477
|
not serve and lists the preferred default it serves first, so the instance
|
|
478
478
|
shows, and opens on, a model that works. Which catalogue models are hidden
|
|
479
479
|
there is the fleet's: one hidden by hand is shown again while its account
|
|
@@ -487,7 +487,7 @@ Secrets are asked for by purpose (`proxy-client-key`,
|
|
|
487
487
|
`monitoring-account-password`, `monitoring-tunnel-token`,
|
|
488
488
|
`proxy-tunnel-token`); see [`src/secrets.ts`](src/secrets.ts).
|
|
489
489
|
|
|
490
|
-
`
|
|
490
|
+
`converge` records the configuration it applies in the fleet state, so a
|
|
491
491
|
run started outside your project uses the one last applied.
|
|
492
492
|
`state --export` prints it.
|
|
493
493
|
|
|
@@ -499,8 +499,8 @@ under `source`: the commit a package names must be reachable there.
|
|
|
499
499
|
A defect in homelab, or something it cannot do yet, is raised as an
|
|
500
500
|
[issue](https://github.com/crvouga/homelab/issues). From your project that
|
|
501
501
|
is the only way to change homelab, for you and for the coding agents working
|
|
502
|
-
there. Do not patch the installed package, a checkout `
|
|
503
|
-
machine or a file it manages: the next install or `
|
|
502
|
+
there. Do not patch the installed package, a checkout `converge` put on a
|
|
503
|
+
machine or a file it manages: the next install or `converge` replaces them.
|
|
504
504
|
|
|
505
505
|
The tool says so itself: `homelab --help` names the issue tracker, and the
|
|
506
506
|
agent contract (`homelab commands --json`, under `agent.support`) carries the
|
|
@@ -526,7 +526,7 @@ fleet.json contents.
|
|
|
526
526
|
are not available yet.
|
|
527
527
|
- The bucket holds the fleet's own state. The CLI proxy keeps its separate
|
|
528
528
|
encrypted backup (`vault` only), and the monitoring hub's database is not
|
|
529
|
-
replicated: `
|
|
529
|
+
replicated: `converge` recreates its accounts and systems, but metric
|
|
530
530
|
history is lost with the manager. See
|
|
531
531
|
[what is not in the bucket yet](docs/state.md#what-is-not-in-the-bucket-yet).
|
|
532
532
|
- Caches and units on machines still use the historical `personal` prefix
|
|
@@ -534,7 +534,7 @@ fleet.json contents.
|
|
|
534
534
|
works, and renaming it needs a migration.
|
|
535
535
|
- The CLI proxy's installed code is a Git worktree of the manager's copy of
|
|
536
536
|
the source repository (`~/.local/share/personal/fleet/manager/source`).
|
|
537
|
-
`
|
|
537
|
+
`converge` fetches that copy again when it is deleted, but the proxy then
|
|
538
538
|
needs `homelab proxy install` once more.
|
|
539
539
|
- The manager is a Mac host. There is no container image of the manager.
|
|
540
540
|
- `converge --schedule enable --apply --yes` is installed by that command
|
|
@@ -579,7 +579,7 @@ bun run check
|
|
|
579
579
|
./homelab check --local # the CLI, from this checkout
|
|
580
580
|
```
|
|
581
581
|
|
|
582
|
-
Run from a checkout, `
|
|
582
|
+
Run from a checkout, `converge` converges the fleet to the checkout's `HEAD`
|
|
583
583
|
commit (never to uncommitted files). The checkout's `origin` must be the
|
|
584
584
|
repository `fleet.json` names under `source`, and a `HEAD` that is not on its
|
|
585
585
|
default branch needs `--allow-unmerged`. Every merge to `main` publishes a release;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
- name: Retire only the replaced manager monitoring job
|
|
3
|
+
hosts: localhost
|
|
4
|
+
connection: local
|
|
5
|
+
become: false
|
|
6
|
+
gather_facts: false
|
|
7
|
+
vars_files:
|
|
8
|
+
- policy.json
|
|
9
|
+
vars:
|
|
10
|
+
migration_home: "{{ lookup('ansible.builtin.env', 'HOME') }}"
|
|
11
|
+
tasks:
|
|
12
|
+
- name: Read the migration launchd user
|
|
13
|
+
ansible.builtin.command:
|
|
14
|
+
argv: [/usr/bin/id, -u]
|
|
15
|
+
changed_when: false
|
|
16
|
+
check_mode: false
|
|
17
|
+
register: migration_uid
|
|
18
|
+
- name: Reconcile the replaced monitoring label
|
|
19
|
+
ansible.builtin.include_tasks: tasks/legacy-agent.yml
|
|
20
|
+
loop: '{{ legacyAgents | selectattr("replacement", "equalto", beszelDaemon) | list }}'
|
|
21
|
+
loop_control:
|
|
22
|
+
loop_var: legacy_agent
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
ansible.builtin.command:
|
|
4
4
|
argv:
|
|
5
5
|
[
|
|
6
|
-
/bin/launchctl,
|
|
6
|
+
"{{ migration_launchctl | default('/bin/launchctl') }}",
|
|
7
7
|
print,
|
|
8
8
|
'gui/{{ migration_uid.stdout }}/{{ legacy_agent.replacement }}',
|
|
9
9
|
]
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
ansible.builtin.command:
|
|
16
16
|
argv:
|
|
17
17
|
[
|
|
18
|
-
/bin/launchctl,
|
|
18
|
+
"{{ migration_launchctl | default('/bin/launchctl') }}",
|
|
19
19
|
print,
|
|
20
20
|
'gui/{{ migration_uid.stdout }}/{{ legacy_agent.legacy }}',
|
|
21
21
|
]
|
|
@@ -23,11 +23,19 @@
|
|
|
23
23
|
check_mode: false
|
|
24
24
|
failed_when: false
|
|
25
25
|
register: legacy_loaded
|
|
26
|
+
- name: Require a running replacement monitoring process
|
|
27
|
+
ansible.builtin.assert:
|
|
28
|
+
that:
|
|
29
|
+
- replacement_loaded.rc == 0
|
|
30
|
+
- "'state = running' in replacement_loaded.stdout"
|
|
31
|
+
- "replacement_loaded.stdout is search('pid = [1-9][0-9]*')"
|
|
32
|
+
fail_msg: The replacement monitoring job must be running before retiring its predecessor.
|
|
33
|
+
when: legacy_agent.replacement == beszelDaemon
|
|
26
34
|
- name: Unload the replaced legacy job
|
|
27
35
|
ansible.builtin.command:
|
|
28
36
|
argv:
|
|
29
37
|
[
|
|
30
|
-
/bin/launchctl,
|
|
38
|
+
"{{ migration_launchctl | default('/bin/launchctl') }}",
|
|
31
39
|
bootout,
|
|
32
40
|
'gui/{{ migration_uid.stdout }}/{{ legacy_agent.legacy }}',
|
|
33
41
|
]
|
|
@@ -38,3 +46,20 @@
|
|
|
38
46
|
path: '{{ migration_home }}/Library/LaunchAgents/{{ legacy_agent.legacy }}.plist'
|
|
39
47
|
state: absent
|
|
40
48
|
when: replacement_loaded.rc == 0
|
|
49
|
+
- name: Verify the replacement monitoring process survived
|
|
50
|
+
ansible.builtin.command:
|
|
51
|
+
argv:
|
|
52
|
+
[
|
|
53
|
+
"{{ migration_launchctl | default('/bin/launchctl') }}",
|
|
54
|
+
print,
|
|
55
|
+
'gui/{{ migration_uid.stdout }}/{{ legacy_agent.replacement }}',
|
|
56
|
+
]
|
|
57
|
+
changed_when: false
|
|
58
|
+
check_mode: false
|
|
59
|
+
register: replacement_after
|
|
60
|
+
failed_when: >-
|
|
61
|
+
replacement_after.rc != 0 or
|
|
62
|
+
'state = running' not in replacement_after.stdout or
|
|
63
|
+
(replacement_after.stdout | regex_search('pid = [0-9]+')) !=
|
|
64
|
+
(replacement_loaded.stdout | regex_search('pid = [0-9]+'))
|
|
65
|
+
when: legacy_agent.replacement == beszelDaemon
|
|
@@ -74,6 +74,7 @@ import os
|
|
|
74
74
|
import re
|
|
75
75
|
import resource
|
|
76
76
|
import shutil
|
|
77
|
+
import signal
|
|
77
78
|
import socket
|
|
78
79
|
import stat
|
|
79
80
|
import subprocess
|
|
@@ -93,7 +94,11 @@ REGENERABLE = frozenset({
|
|
|
93
94
|
REGENERABLE_BESIDE = {'target': 'Cargo.toml'}
|
|
94
95
|
# Hidden directories under the home directory that still hold checkouts.
|
|
95
96
|
HIDDEN_ROOTS = frozenset({'.t3'})
|
|
96
|
-
|
|
97
|
+
# Command-scoped settings survive runuser and do not depend on either user's
|
|
98
|
+
# global Git config. A collector owns its maintenance until it completes.
|
|
99
|
+
GIT = ['git', '-c', 'safe.directory=*',
|
|
100
|
+
'-c', 'maintenance.autoDetach=false', '-c', 'gc.autoDetach=false',
|
|
101
|
+
'-c', 'pack.threads=1', '-c', 'pack.windowMemory=64m']
|
|
97
102
|
|
|
98
103
|
|
|
99
104
|
OPERATION_FAILURES = 0
|
|
@@ -198,10 +203,36 @@ def git_dir(checkout):
|
|
|
198
203
|
return target if is_real_dir(target) else None
|
|
199
204
|
|
|
200
205
|
|
|
206
|
+
def managed_git(argv, timeout, input=None, **kwargs):
|
|
207
|
+
"""Keep Git and its helpers together, including when a fetch times out."""
|
|
208
|
+
with subprocess.Popen(argv, stdin=subprocess.PIPE if input is not None else None,
|
|
209
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
210
|
+
start_new_session=True, **kwargs) as process:
|
|
211
|
+
try:
|
|
212
|
+
stdout, stderr = process.communicate(input=input, timeout=timeout)
|
|
213
|
+
return subprocess.CompletedProcess(argv, process.returncode, stdout, stderr)
|
|
214
|
+
finally:
|
|
215
|
+
# communicate() only kills the immediate process on timeout in
|
|
216
|
+
# subprocess.run; runuser, transports and pack writers can survive.
|
|
217
|
+
try:
|
|
218
|
+
os.killpg(process.pid, signal.SIGTERM)
|
|
219
|
+
except ProcessLookupError:
|
|
220
|
+
pass
|
|
221
|
+
try:
|
|
222
|
+
process.communicate(timeout=5)
|
|
223
|
+
except subprocess.TimeoutExpired:
|
|
224
|
+
pass
|
|
225
|
+
finally:
|
|
226
|
+
try:
|
|
227
|
+
os.killpg(process.pid, signal.SIGKILL)
|
|
228
|
+
except ProcessLookupError:
|
|
229
|
+
pass
|
|
230
|
+
process.wait()
|
|
231
|
+
|
|
232
|
+
|
|
201
233
|
def run_git(checkout, args, data=None):
|
|
202
234
|
try:
|
|
203
|
-
out =
|
|
204
|
-
capture_output=True, timeout=600)
|
|
235
|
+
out = managed_git(GIT + ['-C', checkout] + args, input=data, timeout=600)
|
|
205
236
|
except (OSError, subprocess.TimeoutExpired):
|
|
206
237
|
return None
|
|
207
238
|
return out
|
|
@@ -478,18 +509,37 @@ def refresh_remotes(worktrees, user, home, reserve=0, max_fetch_mib=None):
|
|
|
478
509
|
log(event='fetch_reserve_refused')
|
|
479
510
|
success = False
|
|
480
511
|
continue
|
|
512
|
+
stage = 'fetch'
|
|
481
513
|
try:
|
|
482
|
-
out =
|
|
483
|
-
as_user(GIT + ['--git-dir', common, 'fetch', '--all', '--prune',
|
|
484
|
-
|
|
514
|
+
out = managed_git(
|
|
515
|
+
as_user(GIT + ['--git-dir', common, 'fetch', '--all', '--prune',
|
|
516
|
+
'--quiet', '--no-auto-maintenance'], user, home),
|
|
517
|
+
timeout=300,
|
|
485
518
|
preexec_fn=(lambda: resource.setrlimit(resource.RLIMIT_FSIZE,
|
|
486
519
|
(max_fetch_mib * MIB, max_fetch_mib * MIB))) if max_fetch_mib else None,
|
|
487
520
|
env={**os.environ, 'GIT_TERMINAL_PROMPT': '0'})
|
|
521
|
+
if out.returncode == 0:
|
|
522
|
+
# The fetch's per-file write bound must not also cap a repack
|
|
523
|
+
# of existing history. Maintenance retains the service's
|
|
524
|
+
# memory budget and the disk guard, and is supervised here.
|
|
525
|
+
stage = 'maintenance'
|
|
526
|
+
out = managed_git(
|
|
527
|
+
as_user(GIT + ['--git-dir', common, 'maintenance', 'run',
|
|
528
|
+
'--auto', '--quiet', '--no-detach'], user, home),
|
|
529
|
+
timeout=600, env={**os.environ, 'GIT_TERMINAL_PROMPT': '0'})
|
|
488
530
|
ok = out.returncode == 0
|
|
489
|
-
|
|
531
|
+
failure = {'reason': 'signal' if out.returncode < 0 else 'exit',
|
|
532
|
+
'exit_code': out.returncode}
|
|
533
|
+
except subprocess.TimeoutExpired:
|
|
534
|
+
ok = False
|
|
535
|
+
failure = {'reason': 'timeout'}
|
|
536
|
+
except OSError as exc:
|
|
490
537
|
ok = False
|
|
538
|
+
failure = {'reason': 'os_error', 'errno': exc.errno}
|
|
491
539
|
if not ok:
|
|
492
|
-
|
|
540
|
+
# Do not serialize stderr: remotes can include credentials and
|
|
541
|
+
# arbitrary server output. Status fields are actionable and safe.
|
|
542
|
+
log(event='fetch_failed', stage=stage, **failure)
|
|
493
543
|
success = False
|
|
494
544
|
return success
|
|
495
545
|
|
|
@@ -572,9 +622,9 @@ def collect_worktrees(root, idle_seconds, busy, now, dry_run, disposable=False,
|
|
|
572
622
|
common = run_git(worktree, ['rev-parse', '--path-format=absolute', '--git-common-dir'])
|
|
573
623
|
if common is None or common.returncode != 0:
|
|
574
624
|
continue
|
|
575
|
-
out =
|
|
625
|
+
out = managed_git(
|
|
576
626
|
GIT + ['--git-dir', common.stdout.decode().strip(), 'worktree', 'remove', '--force', worktree],
|
|
577
|
-
|
|
627
|
+
timeout=600)
|
|
578
628
|
if out.returncode != 0 or os.path.lexists(worktree):
|
|
579
629
|
log(event='worktree_kept', worktree=worktree, reason='git_worktree_remove_failed')
|
|
580
630
|
continue
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"xz-utils": "5.6.1+really5.4.5-1ubuntu0.4",
|
|
32
32
|
"ansible-core": "2.16.3-0ubuntu2",
|
|
33
33
|
"systemd-zram-generator": "1.1.2-3",
|
|
34
|
-
"systemd-oomd": "255.4-1ubuntu8.
|
|
34
|
+
"systemd-oomd": "255.4-1ubuntu8.19",
|
|
35
35
|
"nftables": "1.0.9-1ubuntu0.1",
|
|
36
36
|
"fwupd": "2.0.20-1ubuntu2~24.04.2"
|
|
37
37
|
},
|
|
38
38
|
"browserPackages": {
|
|
39
39
|
"fonts-liberation": "1:2.1.5-3",
|
|
40
|
-
"libasound2t64": "1.2.11-1ubuntu0.
|
|
40
|
+
"libasound2t64": "1.2.11-1ubuntu0.5",
|
|
41
41
|
"libatk-bridge2.0-0t64": "2.52.0-1build1",
|
|
42
42
|
"libatk1.0-0t64": "2.52.0-1build1",
|
|
43
43
|
"libatspi2.0-0t64": "2.52.0-1build1",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"libcups2t64": "2.4.7-1.2ubuntu7.14",
|
|
46
46
|
"libdbus-1-3": "1.14.10-4ubuntu4.1",
|
|
47
47
|
"libdrm2": "2.4.125-1ubuntu0.1~24.04.2",
|
|
48
|
-
"libgbm1": "25.2.8-0ubuntu0.24.04.
|
|
48
|
+
"libgbm1": "25.2.8-0ubuntu0.24.04.5",
|
|
49
49
|
"libglib2.0-0t64": "2.80.0-6ubuntu3.10",
|
|
50
50
|
"libnspr4": "2:4.35-1.1build1",
|
|
51
51
|
"libnss3": "2:3.98-1ubuntu0.3",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
],
|
|
69
|
-
"snapshot": "
|
|
69
|
+
"snapshot": "20261129T000000Z",
|
|
70
70
|
"packages": {
|
|
71
71
|
"sudo": "1.9.17p2-1ubuntu3.2",
|
|
72
72
|
"openssh-server": "1:10.2p1-2ubuntu3.8",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"systemd-zram-generator": "1.2.1-2",
|
|
86
86
|
"systemd-oomd": "259.9-0ubuntu0.1",
|
|
87
87
|
"nftables": "1.1.6-1",
|
|
88
|
-
"fwupd": "2.1.
|
|
88
|
+
"fwupd": "2.1.6-3ubuntu4~26.04.1"
|
|
89
89
|
},
|
|
90
90
|
"tailscale": {
|
|
91
91
|
"version": "1.104.7",
|
|
@@ -139,7 +139,12 @@
|
|
|
139
139
|
"footprintMiB": {
|
|
140
140
|
"baseTools": 5120,
|
|
141
141
|
"checkouts": 1024,
|
|
142
|
-
"profiles": {
|
|
142
|
+
"profiles": {
|
|
143
|
+
"web": 256,
|
|
144
|
+
"go": 1024,
|
|
145
|
+
"rust": 2048,
|
|
146
|
+
"jvm": 640
|
|
147
|
+
}
|
|
143
148
|
},
|
|
144
149
|
"agentSessionMiB": 512,
|
|
145
150
|
"agentBuildMiB": 4096,
|
|
@@ -203,8 +208,7 @@
|
|
|
203
208
|
"threadMaxPercent": 55,
|
|
204
209
|
"swapMiB": 4096,
|
|
205
210
|
"tasks": 3000,
|
|
206
|
-
"weight": 50
|
|
207
|
-
"oomPressurePercent": 60
|
|
211
|
+
"weight": 50
|
|
208
212
|
},
|
|
209
213
|
"journalMaxUse": "1G",
|
|
210
214
|
"journalKeepFree": "4G",
|
|
@@ -223,6 +227,7 @@
|
|
|
223
227
|
"intervalSeconds": 2,
|
|
224
228
|
"refusedExitCode": 75
|
|
225
229
|
},
|
|
230
|
+
"diskGuardScript": "/usr/local/lib/personal-fleet-disk-guard.py",
|
|
226
231
|
"diskGuardWriteMiB": 32,
|
|
227
232
|
"diskGuardIntervalSeconds": 5,
|
|
228
233
|
"diskGcIdleDays": 7,
|
|
@@ -241,7 +246,9 @@
|
|
|
241
246
|
},
|
|
242
247
|
"diskGcWorktreeRoots": [".t3/worktrees"],
|
|
243
248
|
"diskGcWorktreeIdleDays": 30,
|
|
244
|
-
"diskGcCacheCapsMiB": {
|
|
249
|
+
"diskGcCacheCapsMiB": {
|
|
250
|
+
".cache/pip": 1024
|
|
251
|
+
},
|
|
245
252
|
"diskGcPackagesKept": 2,
|
|
246
253
|
"diskGcCheckoutsKept": 2,
|
|
247
254
|
"diskGcCheckoutRoots": [
|
|
@@ -249,7 +256,9 @@
|
|
|
249
256
|
".local/share/personal/fleet/manager-runs"
|
|
250
257
|
],
|
|
251
258
|
"diskGcCurrentCheckout": ".local/share/personal/fleet/current",
|
|
252
|
-
"diskGcExpireHours": {
|
|
259
|
+
"diskGcExpireHours": {
|
|
260
|
+
".t3/scratch": 24
|
|
261
|
+
},
|
|
253
262
|
"diskGcReport": "/var/lib/personal-fleet-disk-gc/report.json",
|
|
254
263
|
"diskGcIntervalMinutes": 60,
|
|
255
264
|
"diskGcDisposable": {
|
|
@@ -262,6 +271,8 @@
|
|
|
262
271
|
"dockerLogMaxFiles": "3",
|
|
263
272
|
"inodeWarnFreePercent": 10,
|
|
264
273
|
"inodeFailFreePercent": 2,
|
|
274
|
+
"diskGcScript": "/usr/local/lib/personal-fleet-disk-gc.py",
|
|
275
|
+
"diskGcMemoryMaxMiB": 2048,
|
|
265
276
|
"diskGcGitTempHours": 1,
|
|
266
277
|
"diskGcFetchMaxMiB": 256
|
|
267
278
|
},
|
|
@@ -275,11 +286,26 @@
|
|
|
275
286
|
"tailscalePort": 41641,
|
|
276
287
|
"containerInterfaces": ["docker0", "br-*"],
|
|
277
288
|
"systemListeners": [
|
|
278
|
-
{
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
{
|
|
289
|
+
{
|
|
290
|
+
"protocol": "udp",
|
|
291
|
+
"port": 68
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"protocol": "udp",
|
|
295
|
+
"port": 546
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"protocol": "udp",
|
|
299
|
+
"port": 5353
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"protocol": "udp",
|
|
303
|
+
"port": 5355
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"protocol": "tcp",
|
|
307
|
+
"port": 5355
|
|
308
|
+
}
|
|
283
309
|
]
|
|
284
310
|
},
|
|
285
311
|
"dockerSmokeTest": {
|
|
@@ -289,7 +315,7 @@
|
|
|
289
315
|
"browser": {
|
|
290
316
|
"packages": {
|
|
291
317
|
"fonts-liberation": "1:2.1.5-3build1",
|
|
292
|
-
"libasound2t64": "1.2.15.3-1ubuntu1.
|
|
318
|
+
"libasound2t64": "1.2.15.3-1ubuntu1.2",
|
|
293
319
|
"libatk-bridge2.0-0t64": "2.60.4-0ubuntu0.1",
|
|
294
320
|
"libatk1.0-0t64": "2.60.4-0ubuntu0.1",
|
|
295
321
|
"libatspi2.0-0t64": "2.60.4-0ubuntu0.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/python3
|
|
2
|
-
"""Shed
|
|
2
|
+
"""Shed an attributed CPU or I/O offender; report memory pressure without killing sessions."""
|
|
3
3
|
import argparse
|
|
4
4
|
import json
|
|
5
5
|
from pathlib import Path
|
|
@@ -88,16 +88,13 @@ class Guard:
|
|
|
88
88
|
except (OSError, ValueError, KeyError):
|
|
89
89
|
pass
|
|
90
90
|
host_delta = io_delta(self.previous.get('host', {}), counters.get('host', {}))
|
|
91
|
-
if
|
|
91
|
+
if io >= args.threshold or cpu >= args.cpu_threshold:
|
|
92
92
|
for scope in workloads(args):
|
|
93
93
|
try:
|
|
94
94
|
if any(child.is_dir() for child in scope.iterdir()):
|
|
95
95
|
continue
|
|
96
96
|
size = int((scope / 'memory.current').read_text())
|
|
97
97
|
size += int((scope / 'memory.swap.current').read_text())
|
|
98
|
-
if memory_due:
|
|
99
|
-
candidates.append((size, scope, dict(reason='memory', bytes=size)))
|
|
100
|
-
continue
|
|
101
98
|
if cpu >= args.cpu_threshold:
|
|
102
99
|
used = cpu_use(scope)
|
|
103
100
|
cpu_use_now[scope] = used
|
|
@@ -74,6 +74,10 @@
|
|
|
74
74
|
Description=Push work in progress of agent worktrees to recovery refs
|
|
75
75
|
[Service]
|
|
76
76
|
Type=oneshot
|
|
77
|
+
Nice=19
|
|
78
|
+
CPUWeight=1
|
|
79
|
+
IOWeight=1
|
|
80
|
+
IOSchedulingClass=idle
|
|
77
81
|
ExecStart=/usr/bin/python3 {{ development_source }}/ansible/ubuntu/wip-guard.py --root {{ development_home }}/.t3/worktrees --node %l
|
|
78
82
|
TimeoutStartSec=600
|
|
79
83
|
- name: Declare how often work in progress is saved
|