@crvouga/homelab 0.23.2 → 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]]
@@ -66,7 +66,7 @@ On the manager the installer runs as the logged-in user (never sudo). It links t
66
66
  | `dev.homelab.cliproxy-fleet` | `cliproxy-fleet.service` | at load/login; retried on error |
67
67
  | `dev.homelab.cliproxy-monitor` | `cliproxy-monitor.timer` | every 5 minutes |
68
68
  | `dev.homelab.cliproxy-vault-renew` | `cliproxy-vault-renew.timer` | at load, then every 15 minutes |
69
- | `dev.homelab.cliproxy-backup` | `cliproxy-backup.timer` | minutes 0, 15, 30, 45 |
69
+ | `dev.homelab.cliproxy-backup` | `cliproxy-backup.timer` | hourly, minute 0 |
70
70
  | `dev.homelab.cliproxy-backup-check` | `cliproxy-backup-check.timer` | Sunday 05:00 |
71
71
  | `dev.homelab.cliproxy-gc` | `cliproxy-gc.timer` | Sunday 04:00 |
72
72
 
@@ -185,7 +185,7 @@ homelab proxy check-full
185
185
 
186
186
  Vault login is interactive with hidden input; its token is restricted locally and renewed every 15 minutes where permitted. Maximum token lifetime still applies; re-login when renewal is no longer allowed. The Restic password has an independent existing copy at `CLIPROXY_FLEET_RESTIC_PASSWORD`. Secret creation/rotation goes through the platform's `bun run vault:edit`/OpenTofu workflow, not runtime helpers.
187
187
 
188
- Encrypted cloud checkpoints run every 15 minutes (legacy systemd adds up to 30 seconds jitter). A checkpoint never stops, pauses or restarts the stack: agents use the proxy around the clock, and a stopped connector fails every request. The capture copies the live state and keeps the copy only if no state file changed while it was taken (retrying a few times); a stack that never holds still fails that backup. A failed capture, restart, upload or retention operation records failure and never advances the success marker. Retention keeps the latest 96 snapshots plus 7 daily, 5 weekly and 12 monthly. Weekly integrity checks read 10% of stored data; `check-full` reads all data. Monitoring fails when the last successful checkpoint is older than 45 minutes. Failures are visible in `cliproxy status` (and `launchctl print gui/$UID/LABEL` or systemd); off-machine checks also run through the CLI proxy health workflow described below.
188
+ Encrypted cloud checkpoints run every hour (legacy systemd adds up to 30 seconds jitter). A checkpoint never stops, pauses or restarts the stack: agents use the proxy around the clock, and a stopped connector fails every request. The capture copies the live state and keeps the copy only if no state file changed while it was taken (retrying a few times); a stack that never holds still fails that backup. A failed capture, restart, upload or retention operation records failure and never advances the success marker. Retention keeps the latest 96 snapshots plus 7 daily, 5 weekly and 12 monthly. Weekly integrity checks read 10% of stored data; `check-full` reads all data. Monitoring fails when the last successful checkpoint is older than 45 minutes. Failures are visible in `cliproxy status` (and `launchctl print gui/$UID/LABEL` or systemd); off-machine checks also run through the CLI proxy health workflow described below.
189
189
 
190
190
  R2 checkpoints are the durable recovery source for config, provider OAuth/account state and the dedicated Tailscale identity. Local state is a working cache with asynchronous durability: normally up to approximately 15 minutes plus upload duration can be lost, and an outage can extend that indefinitely. Run a successful manual checkpoint after important login/config changes or before moving machines. Provider refresh-token invalidation can still require a fresh provider login after recovering an older checkpoint. Each checkpoint records a digest of every refresh token, so `restore-verify RESTORED --newest NEWEST` names exactly the accounts that need one. This is a single-writer deployment, with operator fencing of the previous node; there is no distributed lease or active-active support.
191
191
 
@@ -53,7 +53,7 @@
53
53
  <text x="435" y="720" text-anchor="middle" class="label">Working cache</text>
54
54
  <text x="435" y="746" text-anchor="middle" class="detail">OAuth + config</text>
55
55
  <path d="M 550 728 H 516" class="storage" marker-start="url(#arrow)"/>
56
- <text x="356" y="818" class="detail">Health monitoring · Vault renewal · cloud checkpoint every 15 minutes</text>
56
+ <text x="356" y="818" class="detail">Health monitoring · Vault renewal · cloud checkpoint every hour</text>
57
57
 
58
58
  <rect x="1140" y="686" width="246" height="104" rx="15" class="box"/>
59
59
  <text x="1263" y="719" text-anchor="middle" class="label">AI provider</text>
@@ -29,18 +29,6 @@
29
29
  <key>Minute</key>
30
30
  <integer>0</integer>
31
31
  </dict>
32
- <dict>
33
- <key>Minute</key>
34
- <integer>15</integer>
35
- </dict>
36
- <dict>
37
- <key>Minute</key>
38
- <integer>30</integer>
39
- </dict>
40
- <dict>
41
- <key>Minute</key>
42
- <integer>45</integer>
43
- </dict>
44
32
  </array>
45
33
  <key>LowPriorityIO</key>
46
34
  <true/>