forked from mtusi2026/mtusi2026lab7
Майорова Софья, БВТ2301, на 5. Трек1. HTTPS/TLS/ACL,18 API tests,13 pipeline groups,3 compromise runs,clean clone,persistence. Original tests/API contract preserved; residual CVE triage in REPORT/security.
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
"""Reproducible explicit operator bring-up; no automatic unseal inside the Bao container."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import time
|
|
from bootstrap import main as bootstrap
|
|
from bao_operator import configure,call
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
def dc(*args):subprocess.run(['docker','compose',*args],cwd=ROOT,check=True)
|
|
bootstrap()
|
|
dc('build','api')
|
|
dc('up','-d','postgres','bao','s3-raw','broker-raw','redis-raw','otel-collector-raw','prometheus-raw','loki-raw','tempo-raw','grafana')
|
|
for _ in range(90):
|
|
try:call('sys/init');break
|
|
except Exception:time.sleep(1)
|
|
else:raise SystemExit('OpenBao TLS startup timeout')
|
|
configure()
|
|
# Filer bootstrap is asynchronous; do not mistake initial socket creation for ready S3.
|
|
for _ in range(60):
|
|
result=subprocess.run(['docker','compose','run','--rm','--no-deps','bucket-bootstrap'],cwd=ROOT,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
|
if result.returncode==0:break
|
|
time.sleep(1)
|
|
else:raise SystemExit('Authenticated S3 bootstrap timeout')
|
|
dc('up','-d','migrate')
|
|
dc('up','-d','api','lb','worker','dispatcher')
|
|
print('Lab7 processes started; waiting for verified HTTPS readiness.')
|
|
import ssl,urllib.request
|
|
url=os.environ.get('BASE_URL','https://localhost:'+os.environ.get('APP_PORT','18443'))
|
|
context=ssl.create_default_context(cafile=str(ROOT/'pki/lb/ca.crt'))
|
|
for _ in range(120):
|
|
try:
|
|
with urllib.request.urlopen(url+'/health/ready',context=context,timeout=2) as r:
|
|
if r.status==200:break
|
|
except OSError:pass
|
|
time.sleep(.5)
|
|
else:raise SystemExit('HTTPS readiness timeout')
|
|
print('Lab7 ready over trusted HTTPS; operator secrets stay local.')
|