r/devops7 • u/Alternative_Pin9598 • 8d ago
One script, one chore: before Saturday's orders-db maintenance, who do you tell? grep finds 3 services that call it; a graph walk joined with the owners table finds 9 across 9 teams (real output)
Short one this week: one script, one chore, real output. (This sub is run by the SynapCores team; the script uses our database for the one step that matters.)
The chore
orders-db gets a major-version upgrade Saturday at 02:00, about 20 minutes of downtime. Before you post the maintenance notice: which services break, and which on-call channels need to hear about it?
The usual move is grepping configs for the connection string:
$ grep -l orders-db */config.yaml
fulfillment-worker/config.yaml
invoice-cron/config.yaml
orders-api/config.yamlThree. But checkout calls orders-api, and web and mobile call checkout. They break too, and their teams don't know they depend on orders-db. That is the email you get Saturday at 02:05.
Step 1: the call graph, one line per dependency
deps.txt is "caller callee" (from your catalog or tracing), 18 lines:
web checkout-api
checkout-api orders-api
orders-api orders-db
...The script loads it as a graph in SynapCores with Cypher, same endpoint as SQL:
MERGE (a:Svc {name: "checkout-api"}) MERGE (b:Svc {name: "orders-api"})
MERGE (a)-[:DEPENDS_ON]->(b)Owners go in a plain SQL table next to it:
CREATE TABLE services (name TEXT PRIMARY KEY, team TEXT, tier INTEGER, channel TEXT);
-- ('checkout-api', 'checkout', 1, '#checkout-oncall'), ...Step 2: walk the graph
Everything that reaches orders-db in 1 to 6 hops:
MATCH p = (s:Svc)-[:DEPENDS_ON*1..6]->(t:Svc {name: 'orders-db'})
RETURN s.name AS service, length(p) AS hops, [n IN nodes(p) | n.name] AS via
ORDER BY hops, service
1 hop fulfillment-worker fulfillment-worker > orders-db
1 hop invoice-cron invoice-cron > orders-db
1 hop orders-api orders-api > orders-db
2 hops admin-portal admin-portal > orders-api > orders-db
2 hops checkout-api checkout-api > orders-api > orders-db
2 hops notifications notifications > orders-api > orders-db
2 hops partner-webhooks partner-webhooks > orders-api > orders-db
3 hops mobile-bff mobile-bff > checkout-api > orders-api > orders-db
3 hops web web > checkout-api > orders-api > orders-dbStep 3, the payoff: join the walk with the owners table
The script saves those rows to a blast table; one SQL query turns them into "who to tell":
SELECT s.team, s.channel, MIN(s.tier) AS tier, COUNT(DISTINCT b.service) AS n,
GROUP_CONCAT(DISTINCT b.service) AS services
FROM blast b JOIN services s ON s.name = b.service
WHERE b.target = 'orders-db'
GROUP BY s.team, s.channel
ORDER BY tier, n DESC, s.team;Output of python3 blast.py radius orders-db:
orders-db: 3 direct callers (fulfillment-worker, invoice-cron, orders-api), 9 services affected
tier 1 checkout #checkout-oncall checkout-api
tier 1 mobile #mobile-oncall mobile-bff
tier 1 orders #orders-oncall orders-api
tier 1 storefront #storefront-oncall web
tier 2 integrations #integrations-oncall partner-webhooks
tier 2 messaging #messaging notifications
tier 2 warehouse #warehouse-oncall fulfillment-worker
tier 3 backoffice #backoffice admin-portal
tier 3 finance-eng #finance-eng invoice-crongrep found 3 services; the real blast radius is 9 services and 9 channels, and 4 of them are tier 1. Two of those tier-1 teams (storefront, mobile) are 3 hops away and would never have found orders-db in their own configs.
Why one database? Variable-length paths with the path attached are a painful recursive CTE in plain SQL. A separate graph store walks them easily, but then owners and tiers live elsewhere and you sync two systems. Here the walk and the join hit the same database and endpoint.
Wire blast.py radius <node> into your change-request template and every maintenance ticket lists its blast radius. blast.py (stdlib only) and both sample files are in the first comment.
Free Community Edition: https://synapcores.com/download?utm_source=reddit&utm_medium=owned&utm_campaign=devops7-one-script-6
Where does your dependency map live today: a service catalog, tracing, or "ask in Slack and hope"?
1
u/Alternative_Pin9598 8d ago
blast.py(standard library only; setSC_URLandSC_TOKEN). Run:python3 blast.py load deps.txt services.txt && python3 blast.py radius orders-db. The two sample files are in the reply below.New to graph queries? SQLv2 Lesson 5 explains
*1..3hops,nodes(p)and joining a graph walk with a SQL table, from zero: https://www.reddit.com/r/SQLv2/comments/1xq8g8l/