Завершить трек 1: исследовать масштабирование, сохранить графики и фактический отчёт
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Сохранить версии, лимиты и хеши исходников без секретных значений."""
|
||||
from datetime import datetime, timezone
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def run(*args):
|
||||
return subprocess.check_output(args,cwd=root,text=True,encoding='utf-8').strip()
|
||||
|
||||
|
||||
containers=[]
|
||||
for cid in run('docker','compose','ps','-q').splitlines():
|
||||
obj=json.loads(run('docker','inspect',cid))[0]
|
||||
containers.append({'id':obj['Id'],'name':obj['Name'],'image_id':obj['Image'],
|
||||
'image_tag':obj['Config']['Image'],'started_at':obj['State']['StartedAt'],
|
||||
'nano_cpus':obj['HostConfig']['NanoCpus'],'memory_bytes':obj['HostConfig']['Memory'],
|
||||
'published_ports':obj['HostConfig']['PortBindings'],
|
||||
'mounts':[{'type':m['Type'],'destination':m['Destination'],'rw':m['RW']} for m in obj['Mounts']]})
|
||||
files=[*root.glob('src/**/*.py'),*root.glob('migrations/*.sql'),*root.glob('scripts/*.py'),*root.glob('student-tests/*.py'),root/'Dockerfile',root/'compose.yaml',root/'infra/haproxy.cfg']
|
||||
result={'captured_utc':datetime.now(timezone.utc).isoformat(),'git_head_before_final_report':run('git','rev-parse','HEAD'),
|
||||
'docker_version':json.loads(run('docker','version','--format','{{json .}}')),
|
||||
'compose_version':run('docker','compose','version'),'containers':containers,
|
||||
'source_sha256':{str(p.relative_to(root)):hashlib.sha256(p.read_bytes()).hexdigest() for p in files}}
|
||||
(root/'evidence/environment.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
||||
print('Сохранены версии и лимиты без окружения контейнеров и секретов.')
|
||||
Reference in New Issue
Block a user