@crvouga/homelab 0.23.3 → 0.23.4

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.
@@ -295,6 +295,8 @@
295
295
  <string>--home</string><string>{{ gc_home }}</string>
296
296
  <string>--path</string><string>{{ gc_home }}</string>
297
297
  <string>--lsof</string>
298
+ <string>--git-temp-hours</string><string>{{ gc_policy.diskGcGitTempHours }}</string>
299
+ <string>--fetch-max-mib</string><string>{{ gc_policy.diskGcFetchMaxMiB }}</string>
298
300
  <string>--idle-days</string><string>{{ gc_idle_days }}</string>
299
301
  <string>--pressure-mib</string><string>{{ disk.warnFreeMiB }}</string>
300
302
  {% if gc_on_disposable %}
@@ -395,3 +397,125 @@
395
397
  - "network_time.stdout is search('Network Time:\\s*On')"
396
398
  fail_msg: MANAGER_CLOCK_NOT_SYNCHRONISED; turn on Set time and date automatically in System Settings > General > Date & Time.
397
399
  when: network_time.rc == 0
400
+
401
+ # User-owned rotation needs no administrator grant. Keep the existing root
402
+ # drop-in supported; both use newsyslog's size and archive policy.
403
+ - name: Rotate manager job logs without a privileged grant
404
+ hosts: localhost
405
+ connection: local
406
+ become: false
407
+ gather_facts: false
408
+ vars_files:
409
+ - policy.json
410
+ vars:
411
+ logs_home: "{{ lookup('ansible.builtin.env', 'HOME') }}"
412
+ logs_directory: '{{ logs_home }}/{{ jobLogs.directory }}'
413
+ logs_config: '{{ logs_directory }}/newsyslog.conf'
414
+ logs_plist: '{{ logs_home }}/Library/LaunchAgents/{{ jobLogs.label }}.plist'
415
+ tasks:
416
+ - name: Read the rotation launchd user
417
+ ansible.builtin.command:
418
+ argv: [/usr/bin/id, -u]
419
+ changed_when: false
420
+ check_mode: false
421
+ register: logs_uid
422
+ - name: Create the rotation directories
423
+ ansible.builtin.file:
424
+ path: '{{ item }}'
425
+ state: directory
426
+ mode: '0700'
427
+ loop:
428
+ - '{{ logs_directory }}'
429
+ - '{{ logs_home }}/Library/LaunchAgents'
430
+ - name: Declare the user rotation configuration
431
+ ansible.builtin.copy:
432
+ dest: '{{ logs_config }}'
433
+ mode: '0600'
434
+ content: |
435
+ # Managed by homelab: manager job logs
436
+ {% for label in [fleetSync.label, fleetWatch.label, diskGc.label] %}
437
+ {% for stream in ['out', 'err'] %}
438
+ {{ logs_directory }}/{{ label }}.{{ stream }}.log 600 {{ jobLogs.keep }} {{ jobLogs.maxKiB }} * NZ
439
+ {% endfor %}
440
+ {% endfor %}
441
+ validate: /usr/sbin/newsyslog -r -n -f %s
442
+ - name: Declare the rotation launch agent
443
+ ansible.builtin.copy:
444
+ dest: '{{ logs_plist }}'
445
+ mode: '0644'
446
+ content: |
447
+ <?xml version="1.0" encoding="UTF-8"?>
448
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
449
+ <!-- Managed by homelab: manager job logs -->
450
+ <plist version="1.0"><dict>
451
+ <key>Label</key><string>{{ jobLogs.label }}</string>
452
+ <key>ProgramArguments</key><array>
453
+ <string>/usr/sbin/newsyslog</string><string>-r</string>
454
+ <string>-f</string><string>{{ logs_config }}</string>
455
+ </array>
456
+ <key>StartInterval</key><integer>{{ jobLogs.intervalSeconds }}</integer>
457
+ <key>RunAtLoad</key><true/>
458
+ <key>ProcessType</key><string>Background</string>
459
+ <key>LowPriorityIO</key><true/>
460
+ <key>Nice</key><integer>10</integer>
461
+ <key>StandardOutPath</key><string>/dev/null</string>
462
+ <key>StandardErrorPath</key><string>/dev/null</string>
463
+ </dict></plist>
464
+ register: logs_agent
465
+ - name: Inspect the rotation job
466
+ ansible.builtin.command:
467
+ argv:
468
+ [
469
+ /bin/launchctl,
470
+ print,
471
+ 'gui/{{ logs_uid.stdout }}/{{ jobLogs.label }}',
472
+ ]
473
+ changed_when: false
474
+ check_mode: false
475
+ failed_when: false
476
+ register: logs_loaded
477
+ - name: Unload the stale rotation job
478
+ ansible.builtin.command:
479
+ argv:
480
+ [
481
+ /bin/launchctl,
482
+ bootout,
483
+ 'gui/{{ logs_uid.stdout }}/{{ jobLogs.label }}',
484
+ ]
485
+ when: logs_agent.changed and logs_loaded.rc == 0
486
+ changed_when: true
487
+ - name: Load the rotation job
488
+ ansible.builtin.command:
489
+ argv:
490
+ [
491
+ /bin/launchctl,
492
+ bootstrap,
493
+ 'gui/{{ logs_uid.stdout }}',
494
+ '{{ logs_plist }}',
495
+ ]
496
+ when: logs_agent.changed or logs_loaded.rc != 0
497
+ changed_when: true
498
+
499
+ # A label migration is complete only once its replacement is loaded. Exact
500
+ # historical labels are deliberately enumerated; never remove a wildcard.
501
+ - name: Retire replaced legacy manager launch agents
502
+ hosts: localhost
503
+ connection: local
504
+ become: false
505
+ gather_facts: false
506
+ vars_files:
507
+ - policy.json
508
+ vars:
509
+ migration_home: "{{ lookup('ansible.builtin.env', 'HOME') }}"
510
+ tasks:
511
+ - name: Read the migration launchd user
512
+ ansible.builtin.command:
513
+ argv: [/usr/bin/id, -u]
514
+ changed_when: false
515
+ check_mode: false
516
+ register: migration_uid
517
+ - name: Reconcile each replaced label
518
+ ansible.builtin.include_tasks: tasks/legacy-agent.yml
519
+ loop: '{{ legacyAgents }}'
520
+ loop_control:
521
+ loop_var: legacy_agent
@@ -44,6 +44,57 @@
44
44
  "jobLogs": {
45
45
  "directory": ".local/share/personal/fleet/manager/logs",
46
46
  "maxKiB": 1024,
47
- "keep": 3
47
+ "keep": 3,
48
+ "label": "dev.homelab.job-logs",
49
+ "intervalSeconds": 60
50
+ },
51
+ "legacyAgents": [
52
+ {
53
+ "legacy": "dev.devfleet.cliproxy-fleet",
54
+ "replacement": "dev.homelab.cliproxy-fleet"
55
+ },
56
+ {
57
+ "legacy": "dev.devfleet.cliproxy-vault-renew",
58
+ "replacement": "dev.homelab.cliproxy-vault-renew"
59
+ },
60
+ {
61
+ "legacy": "dev.devfleet.cliproxy-backup",
62
+ "replacement": "dev.homelab.cliproxy-backup"
63
+ },
64
+ {
65
+ "legacy": "dev.devfleet.cliproxy-monitor",
66
+ "replacement": "dev.homelab.cliproxy-monitor"
67
+ },
68
+ {
69
+ "legacy": "dev.devfleet.cliproxy-gc",
70
+ "replacement": "dev.homelab.cliproxy-gc"
71
+ },
72
+ {
73
+ "legacy": "dev.devfleet.cliproxy-backup-check",
74
+ "replacement": "dev.homelab.cliproxy-backup-check"
75
+ },
76
+ {
77
+ "legacy": "dev.devfleet.disk-gc",
78
+ "replacement": "dev.homelab.disk-gc"
79
+ },
80
+ {
81
+ "legacy": "dev.devfleet.vault-renew",
82
+ "replacement": "dev.homelab.vault-renew"
83
+ },
84
+ {
85
+ "legacy": "dev.devfleet.container-watchdog",
86
+ "replacement": "dev.homelab.container-watchdog"
87
+ },
88
+ {
89
+ "legacy": "dev.devfleet.fleet-watch",
90
+ "replacement": "dev.homelab.notify"
91
+ }
92
+ ],
93
+ "resourceCoverage": {
94
+ "cpuAdmission": false,
95
+ "memoryAdmission": false,
96
+ "ioAdmission": false,
97
+ "pressureGuard": false,
98
+ "diskWriterGuard": false
48
99
  }
49
100
  }
@@ -0,0 +1,40 @@
1
+ ---
2
+ - name: Inspect the replacement job
3
+ ansible.builtin.command:
4
+ argv:
5
+ [
6
+ /bin/launchctl,
7
+ print,
8
+ 'gui/{{ migration_uid.stdout }}/{{ legacy_agent.replacement }}',
9
+ ]
10
+ changed_when: false
11
+ check_mode: false
12
+ failed_when: false
13
+ register: replacement_loaded
14
+ - name: Inspect the legacy job
15
+ ansible.builtin.command:
16
+ argv:
17
+ [
18
+ /bin/launchctl,
19
+ print,
20
+ 'gui/{{ migration_uid.stdout }}/{{ legacy_agent.legacy }}',
21
+ ]
22
+ changed_when: false
23
+ check_mode: false
24
+ failed_when: false
25
+ register: legacy_loaded
26
+ - name: Unload the replaced legacy job
27
+ ansible.builtin.command:
28
+ argv:
29
+ [
30
+ /bin/launchctl,
31
+ bootout,
32
+ 'gui/{{ migration_uid.stdout }}/{{ legacy_agent.legacy }}',
33
+ ]
34
+ when: replacement_loaded.rc == 0 and legacy_loaded.rc == 0
35
+ changed_when: true
36
+ - name: Remove the replaced legacy definition
37
+ ansible.builtin.file:
38
+ path: '{{ migration_home }}/Library/LaunchAgents/{{ legacy_agent.legacy }}.plist'
39
+ state: absent
40
+ when: replacement_loaded.rc == 0
@@ -72,6 +72,7 @@ import argparse
72
72
  import json
73
73
  import os
74
74
  import re
75
+ import resource
75
76
  import shutil
76
77
  import socket
77
78
  import stat
@@ -95,7 +96,13 @@ HIDDEN_ROOTS = frozenset({'.t3'})
95
96
  GIT = ['git', '-c', 'safe.directory=*']
96
97
 
97
98
 
99
+ OPERATION_FAILURES = 0
100
+
101
+
98
102
  def log(**event):
103
+ global OPERATION_FAILURES
104
+ if event.get('ok') is False or event.get('event') in ('fetch_failed', 'fetch_reserve_refused', 'git_temp_unobserved'):
105
+ OPERATION_FAILURES += 1
99
106
  print(json.dumps(event, sort_keys=True), flush=True)
100
107
 
101
108
 
@@ -453,7 +460,7 @@ def as_user(argv, user, home):
453
460
  return argv
454
461
 
455
462
 
456
- def refresh_remotes(worktrees, user, home):
463
+ def refresh_remotes(worktrees, user, home, reserve=0, max_fetch_mib=None):
457
464
  """Fetches each repository's remotes once, pruning deleted branches.
458
465
 
459
466
  Run as the development user: the objects it writes belong to that user,
@@ -461,21 +468,30 @@ def refresh_remotes(worktrees, user, home):
461
468
  remote-tracking refs as they were.
462
469
  """
463
470
  done = set()
471
+ success = True
464
472
  for worktree in worktrees:
465
473
  common = git_line(worktree, ['rev-parse', '--path-format=absolute', '--git-common-dir'])
466
474
  if not common or common in done:
467
475
  continue
468
476
  done.add(common)
477
+ if free_bytes(common) < reserve:
478
+ log(event='fetch_reserve_refused')
479
+ success = False
480
+ continue
469
481
  try:
470
482
  out = subprocess.run(
471
483
  as_user(GIT + ['--git-dir', common, 'fetch', '--all', '--prune', '--quiet'], user, home),
472
484
  capture_output=True, timeout=300,
485
+ preexec_fn=(lambda: resource.setrlimit(resource.RLIMIT_FSIZE,
486
+ (max_fetch_mib * MIB, max_fetch_mib * MIB))) if max_fetch_mib else None,
473
487
  env={**os.environ, 'GIT_TERMINAL_PROMPT': '0'})
474
488
  ok = out.returncode == 0
475
489
  except (OSError, subprocess.TimeoutExpired):
476
490
  ok = False
477
491
  if not ok:
478
492
  log(event='fetch_failed', repository=common)
493
+ success = False
494
+ return success
479
495
 
480
496
 
481
497
  def retired(worktree):
@@ -510,7 +526,7 @@ def retired(worktree):
510
526
 
511
527
 
512
528
  def collect_worktrees(root, idle_seconds, busy, now, dry_run, disposable=False,
513
- node=None, user=None, home=None):
529
+ node=None, user=None, home=None, reserve=0, max_fetch_mib=None):
514
530
  worktrees = linked_worktrees(root)
515
531
  # What each branch's remote branch held before the fetch: once it is
516
532
  # deleted, that is the only proof every commit of the worktree was pushed.
@@ -518,7 +534,8 @@ def collect_worktrees(root, idle_seconds, busy, now, dry_run, disposable=False,
518
534
  if disposable and worktrees:
519
535
  pushed = {w: git_line(w, ['rev-parse', '--verify', '--quiet', '@{upstream}'])
520
536
  for w in worktrees}
521
- refresh_remotes(worktrees, user, home)
537
+ if not refresh_remotes(worktrees, user, home, reserve, max_fetch_mib):
538
+ return 0
522
539
  roots = busy()
523
540
  if roots is None:
524
541
  if worktrees:
@@ -1079,9 +1096,78 @@ def base36(value):
1079
1096
  return result or '0'
1080
1097
 
1081
1098
 
1099
+ def open_files(proc, lsof=False):
1100
+ """Fail closed when the process/open-file inventory is incomplete."""
1101
+ if lsof:
1102
+ try:
1103
+ out = subprocess.run(['lsof', '-n', '-w', '-F', 'n'], capture_output=True, timeout=300)
1104
+ if out.returncode != 0:
1105
+ return None
1106
+ return {os.path.realpath(line[1:]) for line in out.stdout.decode().splitlines() if line.startswith('n/')}
1107
+ except (OSError, subprocess.TimeoutExpired, UnicodeError):
1108
+ return None
1109
+ opened = set()
1110
+ try:
1111
+ for pid in os.listdir(proc):
1112
+ if not pid.isdigit():
1113
+ continue
1114
+ try:
1115
+ for fd in os.scandir(os.path.join(proc, pid, 'fd')):
1116
+ try:
1117
+ opened.add(os.path.realpath(os.readlink(fd.path)))
1118
+ except FileNotFoundError:
1119
+ continue
1120
+ except FileNotFoundError:
1121
+ continue
1122
+ except OSError:
1123
+ return None
1124
+ return opened
1125
+
1126
+
1127
+ def collect_git_temps(checkouts, opened, cutoff, dry_run):
1128
+ """Only stale, unopened regular tmp_pack files in real Git object stores.
1129
+
1130
+ A repository with an open temporary pack or a Git lock is active: keep
1131
+ all its packs. Never follow a symlink or touch completed packs/metadata.
1132
+ """
1133
+ if opened is None:
1134
+ log(event='git_temp_unobserved')
1135
+ return 0
1136
+ freed = 0
1137
+ seen = set()
1138
+ for checkout in checkouts:
1139
+ common = git_line(checkout, ['rev-parse', '--path-format=absolute', '--git-common-dir'])
1140
+ if not common or common in seen or not is_real_dir(common):
1141
+ continue
1142
+ seen.add(common)
1143
+ directory = os.path.join(common, 'objects', 'pack')
1144
+ if not is_real_dir(os.path.join(common, 'objects')) or not is_real_dir(directory):
1145
+ continue
1146
+ try:
1147
+ entries = list(os.scandir(directory))
1148
+ if any(Path(common).glob('*.lock')):
1149
+ continue
1150
+ if any(p.startswith(os.path.realpath(directory) + '/') for p in opened):
1151
+ continue
1152
+ for entry in entries:
1153
+ if not entry.name.startswith('tmp_pack_') or not entry.is_file(follow_symlinks=False):
1154
+ continue
1155
+ info = entry.stat(follow_symlinks=False)
1156
+ if info.st_mtime >= cutoff:
1157
+ continue
1158
+ freed += info.st_size
1159
+ if not dry_run:
1160
+ os.unlink(entry.path)
1161
+ except OSError:
1162
+ log(event='git_temp_unobserved')
1163
+ return freed
1164
+
1165
+
1082
1166
  def main(argv):
1083
1167
  parser = argparse.ArgumentParser()
1084
1168
  parser.add_argument('--home', required=True)
1169
+ parser.add_argument('--git-temp-hours', type=float)
1170
+ parser.add_argument('--fetch-max-mib', type=int)
1085
1171
  parser.add_argument('--path', action='append', default=[])
1086
1172
  parser.add_argument('--idle-days', type=float, default=7)
1087
1173
  parser.add_argument('--pressure-mib', type=int, default=15360)
@@ -1176,6 +1262,16 @@ def main(argv):
1176
1262
  mise_cache_bytes=mise_bytes)
1177
1263
  return
1178
1264
  categories = {}
1265
+ if args.git_temp_hours is not None:
1266
+ checkouts = find_checkouts(home, args.max_depth)
1267
+ for root in args.worktree_root:
1268
+ checkouts.extend(linked_worktrees(os.path.join(home, root)))
1269
+ for root, _ in args.keep_checkouts:
1270
+ checkouts.extend(find_checkouts(os.path.join(home, root), args.max_depth))
1271
+ for current in args.current:
1272
+ checkouts.extend(find_checkouts(os.path.realpath(os.path.join(home, current)), args.max_depth))
1273
+ categories['git_temps'] = collect_git_temps(checkouts, open_files(args.proc, args.lsof),
1274
+ now - args.git_temp_hours * HOUR, args.dry_run)
1179
1275
  generations = {}
1180
1276
  freed = collect_checkouts(home, idle, args.max_depth, busy, now, args.dry_run)
1181
1277
  categories['checkouts'] = freed
@@ -1190,7 +1286,7 @@ def main(argv):
1190
1286
  min(idle, args.worktree_idle_days * 24 * HOUR)
1191
1287
  if pressure else args.worktree_idle_days * 24 * HOUR,
1192
1288
  busy, now, args.dry_run, args.disposable,
1193
- args.recovery_node, args.user, home)
1289
+ args.recovery_node, args.user, home, args.pressure_mib * MIB, args.fetch_max_mib)
1194
1290
  categories['worktrees'] = reclaimed
1195
1291
  reclaimed = 0
1196
1292
  protected = {os.path.realpath(os.path.join(home, link)) for link in args.current}
@@ -1269,6 +1365,7 @@ def main(argv):
1269
1365
  final_used = max(used_percent(p) for p in paths) if target else None
1270
1366
  write_report(os.path.join(home, args.report), {
1271
1367
  'version': 1,
1368
+ 'operationFailures': OPERATION_FAILURES,
1272
1369
  'finished': int(time.time()),
1273
1370
  'pressure': pressure,
1274
1371
  'disposable': args.disposable,
@@ -3,12 +3,14 @@
3
3
 
4
4
  Managed by personal converge (tasks/resources.yml) as
5
5
  personal-fleet-disk-guard.service. Every interval it measures free space on the
6
- watched filesystems (bytes and inodes) and the bytes each leaf cgroup under user.slice wrote. When
7
- any watched filesystem is below the floor of free bytes or of free inodes, it
8
- kills only the single cgroup that
9
- wrote the most during the last interval, and only if that is at least the write
10
- threshold. It never deletes files, never touches system services and never
11
- kills idle work. Free space must be recovered by a person.
6
+ watched filesystems (bytes and inodes) and the bytes each leaf cgroup under
7
+ user.slice wrote. Below either free-space floor, it stops the single live
8
+ cgroup that wrote the most since the last sample, even a slow writer or a
9
+ new cgroup. Explicitly named managed cgroups are included; unrelated system
10
+ services are excluded. It never deletes files or kills idle work. Free space
11
+ must be recovered by the collector or a person. Short-lived groups that exit
12
+ between samples cannot be stopped; managed fetches also have admission and
13
+ per-file limits.
12
14
 
13
15
  Usage: disk-guard.py --path / --path /home/me [--floor-mib N]
14
16
  [--inode-floor-percent N] [--write-mib N] [--interval S] [--cgroup-root DIR] [--dry-run]
@@ -44,15 +46,15 @@ def leaf_writes(root):
44
46
 
45
47
 
46
48
  def choose_victim(previous, current, low, threshold):
47
- """The leaf that wrote the most since the previous sample, if it is a runaway."""
48
- if not low:
49
+ """The top active writer below the reserve; threshold is a legacy argument."""
50
+ if not low or not previous:
49
51
  return None
50
52
  best, best_delta = None, 0
51
53
  for path, total in current.items():
52
- delta = total - previous.get(path, total)
54
+ delta = total - previous.get(path, 0)
53
55
  if delta > best_delta:
54
56
  best, best_delta = path, delta
55
- if best is None or best_delta < threshold:
57
+ if best is None or best_delta <= 0:
56
58
  return None
57
59
  return best, best_delta
58
60
 
@@ -89,17 +91,24 @@ def main(argv):
89
91
  parser.add_argument('--write-mib', type=int, default=32)
90
92
  parser.add_argument('--interval', type=float, default=5.0)
91
93
  parser.add_argument('--cgroup-root', default='/sys/fs/cgroup/user.slice')
94
+ parser.add_argument('--managed-cgroup', action='append', default=[])
92
95
  parser.add_argument('--dry-run', action='store_true')
93
96
  args = parser.parse_args(argv)
94
97
  floor, threshold = args.floor_mib * MIB, args.write_mib * MIB
95
98
  log(event='started', paths=args.path, floor_mib=args.floor_mib,
96
99
  inode_floor_percent=args.inode_floor_percent,
97
100
  write_mib=args.write_mib, interval=args.interval, dry_run=args.dry_run)
98
- previous = leaf_writes(args.cgroup_root)
101
+ def writes():
102
+ current = leaf_writes(args.cgroup_root)
103
+ for managed in args.managed_cgroup:
104
+ current.update(leaf_writes(managed))
105
+ return current
106
+
107
+ previous = writes()
99
108
  while True:
100
109
  time.sleep(args.interval)
101
110
  try:
102
- current = leaf_writes(args.cgroup_root)
111
+ current = writes()
103
112
  free = {path: free_bytes(path) for path in args.path}
104
113
  inodes = {path: free_inodes_percent(path) for path in args.path}
105
114
  low = low_paths(free, inodes, floor, args.inode_floor_percent)
@@ -261,7 +261,9 @@
261
261
  "dockerLogMaxSize": "50m",
262
262
  "dockerLogMaxFiles": "3",
263
263
  "inodeWarnFreePercent": 10,
264
- "inodeFailFreePercent": 2
264
+ "inodeFailFreePercent": 2,
265
+ "diskGcGitTempHours": 1,
266
+ "diskGcFetchMaxMiB": 256
265
267
  },
266
268
  "clock": {
267
269
  "warnOffsetSeconds": 2,
@@ -327,7 +327,7 @@
327
327
  StartLimitIntervalSec=0
328
328
  [Service]
329
329
  Type=simple
330
- ExecStart=/usr/bin/python3 -I -B {{ disk_guard_source.stat.path }} --path / --path {{ development_home }} --floor-mib {{ worker_disk_guard_floor_mib }} --inode-floor-percent {{ resourceSafety.inodeFailFreePercent }} --write-mib {{ resourceSafety.diskGuardWriteMiB }} --interval {{ resourceSafety.diskGuardIntervalSeconds }}
330
+ ExecStart=/usr/bin/python3 -I -B {{ disk_guard_source.stat.path }} --path / --path {{ development_home }} --floor-mib {{ worker_disk_guard_floor_mib }} --inode-floor-percent {{ resourceSafety.inodeFailFreePercent }} --managed-cgroup /sys/fs/cgroup/system.slice/personal-fleet-disk-gc.service --write-mib {{ resourceSafety.diskGuardWriteMiB }} --interval {{ resourceSafety.diskGuardIntervalSeconds }}
331
331
  Restart=always
332
332
  RestartSec=5
333
333
  OOMScoreAdjust=-1000
@@ -392,7 +392,7 @@
392
392
  After=docker.service
393
393
  [Service]
394
394
  Type=oneshot
395
- ExecStart=/usr/bin/python3 -I -B {{ disk_gc_source.stat.path }} --home {{ development_home }} --path / --path {{ development_home }} --idle-days {{ gc_idle_days }} --pressure-mib {{ worker_disk_gc_pressure_mib }}{{ (' --target-used-percent ' ~ (fleet_storage_target_used_percent | default(gc_disposable.targetUsedPercent))) if disposable else '' }} --pressure-inode-percent {{ resourceSafety.inodeWarnFreePercent }} --pressure-idle-hours {{ resourceSafety.diskGcPressureIdleHours }} --docker-age-hours {{ resourceSafety.diskGcDockerAgeHours }} --pressure-docker-age-hours {{ resourceSafety.diskGcPressureDockerAgeHours }} --docker-cap-percent {{ resourceSafety.diskGcBuildCachePercent }} --host-var-tmp /run/homelab-host-var-tmp --host-tmp /run/homelab-host-tmp --mise-cache-mib {{ resourceSafety.diskGcMiseCacheMiB }} --home-cache-mib {{ resourceSafety.diskGcHomeCacheMiB }}{% for cache in resourceSafety.diskGcExcludedCaches %} --exclude-cache {{ cache }}{% endfor %}{% for store, mib in resourceSafety.diskGcStoreCapsMiB.items() %} --store-cap {{ store }}={{ mib }}{% endfor %}{% for root in resourceSafety.diskGcWorktreeRoots %} --worktree-root {{ root }}{% endfor %} --worktree-idle-days {{ gc_worktree_idle_days }}{{ ' --disposable' if disposable else '' }}{% for cache, mib in resourceSafety.diskGcCacheCapsMiB.items() %} --cache-cap {{ cache }}={{ mib }}{% endfor %} --keep-newest /var/cache/personal-fleet={{ resourceSafety.diskGcPackagesKept }}{% for root in resourceSafety.diskGcCheckoutRoots %} --keep-checkouts {{ root }}={{ resourceSafety.diskGcCheckoutsKept }}{% endfor %} --current {{ resourceSafety.diskGcCurrentCheckout }}{% for directory, hours in resourceSafety.diskGcExpireHours.items() %} --expire {{ directory }}={{ hours }}{% endfor %} --report {{ resourceSafety.diskGcReport }} --mise {{ development_home }}/.local/bin/mise --user {{ development_user }}{{ '' if worker_containers_on | default(true) | bool else ' --no-docker' }}
395
+ ExecStart=/usr/bin/python3 -I -B {{ disk_gc_source.stat.path }} --home {{ development_home }} --git-temp-hours {{ resourceSafety.diskGcGitTempHours }} --fetch-max-mib {{ resourceSafety.diskGcFetchMaxMiB }} --path / --path {{ development_home }} --idle-days {{ gc_idle_days }} --pressure-mib {{ worker_disk_gc_pressure_mib }}{{ (' --target-used-percent ' ~ (fleet_storage_target_used_percent | default(gc_disposable.targetUsedPercent))) if disposable else '' }} --pressure-inode-percent {{ resourceSafety.inodeWarnFreePercent }} --pressure-idle-hours {{ resourceSafety.diskGcPressureIdleHours }} --docker-age-hours {{ resourceSafety.diskGcDockerAgeHours }} --pressure-docker-age-hours {{ resourceSafety.diskGcPressureDockerAgeHours }} --docker-cap-percent {{ resourceSafety.diskGcBuildCachePercent }} --host-var-tmp /run/homelab-host-var-tmp --host-tmp /run/homelab-host-tmp --mise-cache-mib {{ resourceSafety.diskGcMiseCacheMiB }} --home-cache-mib {{ resourceSafety.diskGcHomeCacheMiB }}{% for cache in resourceSafety.diskGcExcludedCaches %} --exclude-cache {{ cache }}{% endfor %}{% for store, mib in resourceSafety.diskGcStoreCapsMiB.items() %} --store-cap {{ store }}={{ mib }}{% endfor %}{% for root in resourceSafety.diskGcWorktreeRoots %} --worktree-root {{ root }}{% endfor %} --worktree-idle-days {{ gc_worktree_idle_days }}{{ ' --disposable' if disposable else '' }}{% for cache, mib in resourceSafety.diskGcCacheCapsMiB.items() %} --cache-cap {{ cache }}={{ mib }}{% endfor %} --keep-newest /var/cache/personal-fleet={{ resourceSafety.diskGcPackagesKept }}{% for root in resourceSafety.diskGcCheckoutRoots %} --keep-checkouts {{ root }}={{ resourceSafety.diskGcCheckoutsKept }}{% endfor %} --current {{ resourceSafety.diskGcCurrentCheckout }}{% for directory, hours in resourceSafety.diskGcExpireHours.items() %} --expire {{ directory }}={{ hours }}{% endfor %} --report {{ resourceSafety.diskGcReport }} --mise {{ development_home }}/.local/bin/mise --user {{ development_user }}{{ '' if worker_containers_on | default(true) | bool else ' --no-docker' }}
396
396
 
397
397
  StateDirectory=personal-fleet-disk-gc
398
398
  StateDirectoryMode=0755
package/ansible/uv.lock CHANGED
@@ -190,6 +190,24 @@ wheels = [
190
190
  { url = "https://files.pythonhosted.org/packages/f6/b6/a1faf3a27ae9405fb34b1713cc73b2d8a26b04d5c561578fa2e6ef3e5bb9/cryptography-50.0.2-cp39-abi3-win_amd64.whl", hash = "sha256:4e81d95e5bafc2d6e34e4bed780e53e4d5b9a2f928573428aa4d35fbec1eb0de", size = 3854095, upload-time = "2026-09-30T15:29:46.782Z" },
191
191
  ]
192
192
 
193
+ [[package]]
194
+ name = "distro"
195
+ version = "1.9.0"
196
+ source = { registry = "https://pypi.org/simple" }
197
+ sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" }
198
+ wheels = [
199
+ { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" },
200
+ ]
201
+
202
+ [[package]]
203
+ name = "filelock"
204
+ version = "4.3.2"
205
+ source = { registry = "https://pypi.org/simple" }
206
+ sdist = { url = "https://files.pythonhosted.org/packages/b2/de/99f4266dc2b97503fe35af46d4bf54ea4d434bc322992103145c9de7da95/filelock-4.3.2.tar.gz", hash = "sha256:4f0a21c70447782453c06bb20a9863ee385ead1abaef22049af79289496851b3", size = 744182, upload-time = "2026-11-27T22:58:32.45Z" }
207
+ wheels = [
208
+ { url = "https://files.pythonhosted.org/packages/d7/4f/6429bb372197194e65bb33885cd112c7008c2b9cf7496285874aa274e506/filelock-4.3.2-py3-none-any.whl", hash = "sha256:02a8801bc6b2a80921bf3d7895c63084d53bae2a3c86783adce5ae2b89a1825b", size = 244905, upload-time = "2026-11-27T22:58:31.01Z" },
209
+ ]
210
+
193
211
  [[package]]
194
212
  name = "homelab-ansible"
195
213
  version = "0"
@@ -209,24 +227,6 @@ requires-dist = [{ name = "ansible-core", specifier = "==2.22.0" }]
209
227
  [package.metadata.requires-dev]
210
228
  lint = [{ name = "ansible-lint", specifier = "==26.11.1" }]
211
229
 
212
- [[package]]
213
- name = "distro"
214
- version = "1.9.0"
215
- source = { registry = "https://pypi.org/simple" }
216
- sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" }
217
- wheels = [
218
- { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" },
219
- ]
220
-
221
- [[package]]
222
- name = "filelock"
223
- version = "4.3.1"
224
- source = { registry = "https://pypi.org/simple" }
225
- sdist = { url = "https://files.pythonhosted.org/packages/e6/86/a5b9ec254b90efb180e390e31a4fa50a93b714d6e4174fa9a4ee25607159/filelock-4.3.1.tar.gz", hash = "sha256:4c5ee627c401f1863ac6a0de9a14a28d3bb5f8c730b45e2fd6e5dbc79cf34b9e", size = 742330, upload-time = "2026-11-23T18:01:13.656Z" }
226
- wheels = [
227
- { url = "https://files.pythonhosted.org/packages/53/7b/678c8fbd372ff96375ac0bbdd20b78f20ef8ba6ca5966c49548fa5886557/filelock-4.3.1-py3-none-any.whl", hash = "sha256:79e43df8e9fe509cd83a3899a7c186c8077cbbe4d200a1ed3705c2f3bb6bc487", size = 244559, upload-time = "2026-11-23T18:01:12.261Z" },
228
- ]
229
-
230
230
  [[package]]
231
231
  name = "jinja2"
232
232
  version = "3.1.6"
@@ -338,11 +338,11 @@ wheels = [
338
338
 
339
339
  [[package]]
340
340
  name = "platformdirs"
341
- version = "4.14.8"
341
+ version = "4.14.9"
342
342
  source = { registry = "https://pypi.org/simple" }
343
- sdist = { url = "https://files.pythonhosted.org/packages/71/18/0b0d99f5bf164f04a7a9534c3dbdbe4d5fd2b382667685ad40c192c4d3d1/platformdirs-4.14.8.tar.gz", hash = "sha256:96893d686e84e9e6f358a9ea41a8de544df66dbf2ba6cda250e7dc73acf85b9b", size = 87203, upload-time = "2026-11-20T08:14:52.63Z" }
343
+ sdist = { url = "https://files.pythonhosted.org/packages/d6/96/549558270586699a271a18b1111482dc3fc39baa0ef61d183e230d2c961d/platformdirs-4.14.9.tar.gz", hash = "sha256:c6b188e03ffd4dfe1bf8c4bcb47cd94711af244a9852dbff60297bd753684d5d", size = 87729, upload-time = "2026-11-27T20:53:44.721Z" }
344
344
  wheels = [
345
- { url = "https://files.pythonhosted.org/packages/5b/be/373cc7341f53bfd3acba3e5db62433fd960a45fcf73ad64a5f4d27e74910/platformdirs-4.14.8-py3-none-any.whl", hash = "sha256:1e34af590de4d978631b751eb2202f2fee4497537a17c1720b12fcf57b331392", size = 94267, upload-time = "2026-11-20T08:14:51.306Z" },
345
+ { url = "https://files.pythonhosted.org/packages/3b/e7/fc53dfd2f9469cce9be9c58385bdcdb5087e790c135c9dadd4cc8401bb3d/platformdirs-4.14.9-py3-none-any.whl", hash = "sha256:d0d3a23e7ff282cfa94b77f5a22b81030dcb68ba0430f90c74f4bd8d090782ea", size = 94272, upload-time = "2026-11-27T20:53:43.511Z" },
346
346
  ]
347
347
 
348
348
  [[package]]
package/docs/runbooks.md CHANGED
@@ -14,7 +14,7 @@ It reads a code by where it stands, never by the word it ends with. The CLI
14
14
  proxy documents the codes of its own commands in
15
15
  [its README](../cliproxy/README.md); the ones converge reports are here.
16
16
 
17
- There are 495 codes; 105 need a person.
17
+ There are 498 codes; 105 need a person.
18
18
 
19
19
  ## Bootstrap of a new or returning worker
20
20
 
@@ -759,3 +759,14 @@ See the GNOME desktop sharing and manager keychain procedures in
759
759
  ### Directed T3 grants
760
760
 
761
761
  To authorize every enrolled environment's agents to work with full access on every other enrolled environment, set `t3.meshAccess` to `"full-access"` in fleet.json. Preview with `homelab converge --dry-run`. Each `t3:mesh-link` names the source, destination and measured grant. An unreachable environment or changed identity is reported by `t3:mesh-member`. Restore its T3 service and enrolled tailnet connection, then run converge. Sync adopts healthy grants in place and replaces incorrect grants or grants expiring within seven days. Scheduled sync retries outstanding pairs. Use `homelab check` to measure the links from their sources.
762
+
763
+ ## Resource protection coverage and collection
764
+
765
+ - **Meaning:** The manager reports platform coverage separately from disk collection. A finished collector run may still contain failed or refused operations.
766
+ - **Confirm:** Run `homelab check --json` and inspect `manager:resource-coverage`, `manager:legacy-agents` and the disk GC checks. Check the collector's operation failure count and disk target, and its service or LaunchAgent result.
767
+ - **Fix:** Run `homelab converge` to restore user log rotation and retire replaced legacy jobs. Restore free space or credentials before retrying a failed collector operation. The macOS manager's unsupported admission and writer guards require keeping capacity available and placing agent workloads on Ubuntu workers; [the worker contract](worker-contract.md#manager-resource-coverage) states the boundary.
768
+ - **Escalate:** If replaced legacy jobs remain after convergence, or collection repeatedly fails, file an issue with check IDs and failure counts. Never include credentials or raw authentication output.
769
+
770
+ - `DISK_GC_OPERATIONS_FAILED`: one or more collector operations failed, were refused by the reserve, or could not safely inventory open temporary packs. A successful scheduler exit does not establish successful collection.
771
+ - `MANAGER_LEGACY_AGENTS_REMAIN`: an exact historical LaunchAgent label remains installed or loaded. Convergence removes it only after its replacement is loaded, preserving service availability.
772
+ - `MANAGER_RESOURCE_GUARD_UNSUPPORTED`: macOS has no supported fleet CPU/memory/I/O admission, pressure guard or low-disk writer guard. Scheduled collection and background job priority do not provide those guarantees.
@@ -279,3 +279,27 @@ The normal manager apply flow reports configuration application separately
279
279
  from readiness and advances the applied-revision receipt only after required
280
280
  acceptance succeeds. Read the remaining release gates in [ubuntu-sync.md](ubuntu-sync.md)
281
281
  before treating any release as complete fleet certification.
282
+
283
+ ## Manager resource coverage
284
+
285
+ The macOS manager has scheduled disk collection, bounded scheduled-job logs,
286
+ and background CPU and I/O priority for its collection and notification jobs.
287
+ These persist as user LaunchAgents at login. Converge installs and reloads
288
+ the jobs; `manager:job-logs`, `manager:disk-gc` and `manager:legacy-agents`
289
+ measure their configuration and loaded state.
290
+
291
+ macOS does not provide the Ubuntu workers' cgroup CPU/memory/I/O admission,
292
+ pressure guard or low-disk writer guard. `manager:resource-coverage` always
293
+ warns with `MANAGER_RESOURCE_GUARD_UNSUPPORTED` and enumerates those gaps.
294
+ The collector's target is a cleanup goal, not a disk reserve. Check
295
+ `manager:disk` and `manager:disk-gc` for early capacity warnings, retain room
296
+ for the manager's services, and run agent workloads on protected Ubuntu
297
+ workers. A missed target or a failed collection operation remains a warning.
298
+
299
+ On Ubuntu workers the low-disk guard covers user leaf cgroups and the managed
300
+ collector's cgroup, including slow writers and newly appearing groups. It
301
+ does not stop unrelated system services. The collector refuses remote fetches
302
+ below its declared pressure reserve and caps each fetch process’s output file
303
+ size using the policy’s `diskGcFetchMaxMiB`; a failed/refused fetch keeps worktrees.
304
+ Stale unopened Git temporary packs are collected independently of fetching.
305
+ An incomplete open-file inventory keeps all temporary packs.