Реализовать лабораторную 7: mTLS, OpenBao и защита worker
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
: "${TARGET_INSTANCE_ID:?Required API hostname from X-Instance-Id}"
|
||||
for id in $(scripts/compose.sh ps -q api); do
|
||||
hostname=$(docker exec "$id" python -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:8080/health/live').headers['X-Instance-Id'])")
|
||||
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
||||
docker stop --time 3 "$id" >/dev/null
|
||||
python3 - "$id" "$TARGET_INSTANCE_ID" <<'PYLOG'
|
||||
import json,sys,time,subprocess
|
||||
from pathlib import Path
|
||||
with Path('evidence/failover-actions.jsonl').open('a') as f:
|
||||
f.write(json.dumps({'container_id':sys.argv[1],'container_name':subprocess.check_output(['docker','inspect','--format','{{.Name}}',sys.argv[1]],text=True).strip(),'instance_alias':sys.argv[2],'stopped_at_unix':time.time()})+'\n')
|
||||
PYLOG
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
printf '%s\n' 'Target is not a running API replica' >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user