修复:独立回收中断备份并限制 AI 日志增长
This commit is contained in:
@@ -47,6 +47,7 @@ def snapshot(root, support=SUPPORT, now=None):
|
||||
output_logs = sum(p.stat().st_blocks * 512 for p in logs if p.is_relative_to(root / 'output'))
|
||||
runtime_logs = sum(p.stat().st_blocks * 512 for p in logs if p.is_relative_to(root / '.runtime'))
|
||||
native = allocated(root / '.runtime/nao-users')
|
||||
native_logs = sum(p.stat().st_blocks * 512 for p in logs if p.is_relative_to(root / '.runtime/nao-users'))
|
||||
registered = 0; overdue = 0
|
||||
for p in resources.registry(root).glob('*.json'):
|
||||
value = resources.load(root, p.stem)
|
||||
@@ -61,10 +62,11 @@ def snapshot(root, support=SUPPORT, now=None):
|
||||
if owner.get('kind') == 'private-quality-restore' and owner.get('directory') == str(p): private += allocated(p)
|
||||
# Core service data is the same scope as the earlier 11.86GiB measurement.
|
||||
# Software/build/delivery artifacts are visible separately and included in growth checks.
|
||||
core = max(0, mysql - registered) + archives + backups + log_bytes + native
|
||||
artifacts = max(0, runtime - mysql - private - native - runtime_logs) + max(0, outputs - backups - output_logs)
|
||||
native_data = max(0, native - native_logs)
|
||||
core = max(0, mysql - registered) + archives + backups + log_bytes + native_data
|
||||
artifacts = max(0, runtime - mysql - private - native - (runtime_logs - native_logs)) + max(0, outputs - backups - output_logs)
|
||||
return {'at': now, 'mysqlBytes': mysql, 'archiveBytes': archives, 'backupBytes': backups,
|
||||
'logBytes': log_bytes, 'nativeDataBytes': native, 'registeredTestBytes': registered,
|
||||
'logBytes': log_bytes, 'nativeDataBytes': native_data, 'registeredTestBytes': registered,
|
||||
'privateVerifierBytes': private, 'temporaryBytes': registered + private,
|
||||
'coreBytes': core, 'artifactBytes': artifacts, 'permanentBytes': core + artifacts,
|
||||
'freeBytes': shutil.disk_usage(root).free, 'overdueTestResources': overdue}
|
||||
@@ -143,17 +145,18 @@ def janitor(root, support, policy):
|
||||
if (root / '.runtime/retention/paused').exists(): return {'deferred': 'Maintenance is paused'}
|
||||
try:
|
||||
with br.lock(root, timeout=0):
|
||||
result = br.clean_incomplete(root)
|
||||
db = Database(root)
|
||||
try:
|
||||
config = json.loads((root / '.runtime/retention/config.json').read_text())
|
||||
accepted = br.accepted_backend(root)
|
||||
if config['schemaSignature'] != db.schema_signature or not accepted or config['acceptedJarSha256'] != accepted[1]:
|
||||
return {'deferred': 'Application version changed'}
|
||||
return {**result, 'deferred': 'Application version changed'}
|
||||
db.current()
|
||||
if db.busy(): return {'deferred': 'Application jobs are active'}
|
||||
if db.busy(): return {**result, 'deferred': 'Application jobs are active'}
|
||||
# Use a short-lived CLI connection so no observer holds a test schema open.
|
||||
import backup
|
||||
result = resources.cleanup(root, backup.client)
|
||||
result.update(resources.cleanup(root, backup.client))
|
||||
result['abandonedVerifiersRemoved'] = backup_verifier.clean_abandoned(root)
|
||||
result['mysqlLogsRotated'] = log_retention.rotate_mysql(root, backup.client, br)
|
||||
result.update(log_retention.retain(root, support,
|
||||
|
||||
Reference in New Issue
Block a user