Page MenuHomePhabricator
Paste P67401

really gross hacks -- k8s pod IPs for T370304
ActivePublic

Authored by CDanis on Aug 20 2024, 9:16 PM.
Project Tags
None
Referenced Files
F57283123: really gross hacks -- k8s pod IPs for T370304
Aug 20 2024, 9:17 PM
F57283122: really gross hacks -- k8s pod IPs for T370304
Aug 20 2024, 9:16 PM
Subscribers
None
#################
# On deploy1003:
# kubectl watching a history of pod IPs & an awk one-liner to get the last seen pod name for every IP
#################
๐Ÿ’™root@deploy1003.eqiad.wmnet ~ ๐Ÿ•”๐Ÿ™ƒ pwd
/home/cdanis
๐Ÿ’™root@deploy1003.eqiad.wmnet ~ ๐Ÿ•”๐Ÿ™ƒ cat latest-pod-ips.sh
#!/bin/bash
<pods.tsv grep -Fv '<none>' | awk '{lastseen[$4]= $5} END {for (p in lastseen) print p,lastseen[p]}' | sort
๐Ÿ’™root@deploy1003.eqiad.wmnet ~ ๐Ÿ•”๐Ÿ™ƒ while sleep 5s; do kubectl get pods -o custom-columns=IP:.status.podIP,NAME:.metadata.name --no-headers --all-namespaces -w | grep -Fv '<none>' | ts "%b %d %H:%M:%S"$'\t' | tee -a pods.tsv ; done
#################
# On cumin1002:
# Sync the map of pod IPs from deploy1003 to the s4 master to use it in small tools there
#################
๐Ÿ’™root@cumin1002.eqiad.wmnet ~ ๐Ÿ•ž๐Ÿ™ƒ export SSH_AUTH_SOCK=/run/keyholder/proxy.sock # lol dont do this at home kids
๐Ÿ’™root@cumin1002.eqiad.wmnet ~ ๐Ÿ•ž๐Ÿ™ƒ while sleep 1m; do ssh deploy1003 'cd /home/cdanis ; ./latest-pod-ips.sh' | ssh db1160 'sort -k1b,1 > /home/cdanis/latest-pods.txt' ; done
#################
# On db1160:
# Poll the number of inuse sockets (cheap signal that correlates with and/or causes the outage).
# When it exceeds a threshold, do some more expensive data-gathering:
# * Grab a processlist from mariadbd and also join the client IP addresses against k8s pod IPs
# * Grab a few-seconds packet dump of mysql traffic, decode and print incoming queries,
# truncate them to a limited length, include timing data + join the client IPs against k8s pod IPs
#################
๐Ÿ’™cdanis@db1160.eqiad.wmnet ~/processlist ๐Ÿ•”โ˜• cat watch.sh
#!/bin/bash
INTERVAL="15s"
THRESH=200
set -eu
while sleep "$INTERVAL"; do
if (( $(ss -t | wc -l |awk '{print $1}') >= $THRESH )); then
OUT=$(date -Isecond).txt
time (echo show full processlist | mariadb > $OUT)
join -a2 ../latest-pods.txt <( awk <$OUT -v"OFS=\t" '{split($3, hostport, ":"); print hostport[1], $0}' | sort -k1b,1) > joined/$OUT
fi
done
๐Ÿ’™cdanis@db1160.eqiad.wmnet ~/pcaps ๐Ÿ•”โ˜• cat watch.sh
#!/bin/bash
INTERVAL="5"
THRESH=200
set -eu
while sleep "$INTERVAL"; do
if (( $(ss -t | wc -l |awk '{print $1}') >= $THRESH )); then
OUT=$(date -Isecond).txt
join -a2 ../latest-pods.txt >$OUT <( sudo tshark -i eno1 -aduration:3 -d tcp.port==3306,mysql -T fields -e ip.src -e frame.time -e mysql.query -Y mysql.query 'port 3306' | cut -c1-220 | sort -k1b,1 )
zstd --rm $OUT &
fi
done
๐Ÿ’™cdanis@db1160.eqiad.wmnet ~/processlist ๐Ÿ•”โ˜• sudo bash -x watch.sh|& ts | tee -a watch.out

Event Timeline

CDanis edited the content of this paste. (Show Details)