Ownership & the Catalog Graph
Each catalog-info.yaml is small, but together they form a graph: components depend on resources and APIs, belong to systems and domains, and are owned by groups that sit in an organisation tree. Backstage computes relations from the spec fields (ownedBy/ownerOf, dependsOn/dependencyOf, partOf/hasPart, providesApi/apiProvidedBy, consumesApi/apiConsumedBy, parentOf/childOf) and stores both directions, so "what does linkly depend on?" and "what depends on linkly's database?" are equally cheap to answer. The catalog graph plugin draws it.
This lesson models that graph in Python to answer the questions a platform team actually asks: who owns this?, what breaks if this goes down?, and what is nobody looking after?
Building relations from entities
ENTITIES = [
{"kind": "Group", "name": "engineering", "spec": {"type": "department"}},
{"kind": "Group", "name": "team-links", "spec": {"type": "team", "parent": "engineering"}},
{"kind": "Group", "name": "team-growth", "spec": {"type": "team", "parent": "engineering"}},
{"kind": "System", "name": "links", "spec": {"owner": "team-links"}},
{"kind": "Component", "name": "linkly", "spec": {"owner": "team-links", "system": "links",
"providesApis": ["linkly-api"], "dependsOn": ["resource:linkly-db", "resource:linkly-cache"]}},
{"kind": "Component", "name": "redirector", "spec": {"owner": "team-links", "system": "links",
"consumesApis": ["linkly-api"], "dependsOn": ["resource:linkly-cache"]}},
{"kind": "Component", "name": "analytics", "spec": {"owner": "team-growth",
"dependsOn": ["resource:linkly-db"]}},
{"kind": "Component", "name": "qr-codes", "spec": {"owner": "team-qr", "consumesApis": ["linkly-api"]}},
{"kind": "API", "name": "linkly-api", "spec": {"owner": "team-links", "system": "links"}},
{"kind": "Resource", "name": "linkly-db", "spec": {"owner": "team-links", "system": "links"}},
{"kind": "Resource", "name": "linkly-cache", "spec": {"owner": "team-links", "system": "links"}},
]
def ref(target, default_kind):
kind, _, name = target.rpartition(":")
return f"{(kind or default_kind).lower()}:default/{name}"
def relations(entities):
rels = set()
def add(src, typ, inverse, dst):
rels.add((src, typ, dst)); rels.add((dst, inverse, src))
for e in entities:
me = f"{e['kind'].lower()}:default/{e['name']}"
s = e["spec"]
if "owner" in s: add(me, "ownedBy", "ownerOf", ref(s["owner"], "group"))
if "system" in s: add(me, "partOf", "hasPart", ref(s["system"], "system"))
if "parent" in s: add(me, "childOf", "parentOf", ref(s["parent"], "group"))
for t in s.get("dependsOn", []): add(me, "dependsOn", "dependencyOf", ref(t, "component"))
for t in s.get("providesApis", []): add(me, "providesApi", "apiProvidedBy", ref(t, "api"))
for t in s.get("consumesApis", []): add(me, "consumesApi", "apiConsumedBy", ref(t, "api"))
return rels
RELS = relations(ENTITIES)
print(len(ENTITIES), "entities,", len(RELS), "relations")
for src, typ, dst in sorted(RELS):
if src == "resource:default/linkly-db":
print(f" {src} --{typ}--> {dst}")11 entities, 44 relations
resource:default/linkly-db --dependencyOf--> component:default/analytics
resource:default/linkly-db --dependencyOf--> component:default/linkly
resource:default/linkly-db --ownedBy--> group:default/team-links
resource:default/linkly-db --partOf--> system:default/links
Every relation is stored twice, once from each end. That's how Backstage shows "Depended on by: analytics, linkly" on the database's page without scanning all entities.
Blast radius: what breaks if this fails?
Follow dependencyOf and apiProvidedBy → apiConsumedBy edges outward from a failing entity, breadth-first. The result is the list of services to warn during an incident, and their owners are the people to page:
from collections import deque
# compact copy of the previous example's graph: edges "X is needed by Y"
NEEDED_BY = {
"resource:linkly-db": ["component:linkly", "component:analytics"],
"resource:linkly-cache": ["component:linkly", "component:redirector"],
"component:linkly": ["api:linkly-api"],
"api:linkly-api": ["component:redirector", "component:qr-codes"],
}
OWNER = {"component:linkly": "team-links", "component:redirector": "team-links",
"component:analytics": "team-growth", "component:qr-codes": "team-qr",
"api:linkly-api": "team-links"}
def blast_radius(start):
seen, order, queue = {start}, [], deque([(start, 0)])
while queue:
node, depth = queue.popleft()
for nxt in NEEDED_BY.get(node, []):
if nxt not in seen:
seen.add(nxt); order.append((nxt, depth + 1)); queue.append((nxt, depth + 1))
return order
for failing in ["resource:linkly-db", "resource:linkly-cache"]:
hit = blast_radius(failing)
print(f"{failing} down ->")
for node, depth in hit:
print(f" hop {depth}: {node} (owner {OWNER[node]})")
teams = sorted({OWNER[n] for n, _ in hit})
print(" page:", ", ".join(teams))resource:linkly-db down ->
hop 1: component:linkly (owner team-links)
hop 1: component:analytics (owner team-growth)
hop 2: api:linkly-api (owner team-links)
hop 3: component:redirector (owner team-links)
hop 3: component:qr-codes (owner team-qr)
page: team-growth, team-links, team-qr
resource:linkly-cache down ->
hop 1: component:linkly (owner team-links)
hop 1: component:redirector (owner team-links)
hop 2: api:linkly-api (owner team-links)
hop 3: component:qr-codes (owner team-qr)
page: team-links, team-qr
The database's failure reaches qr-codes, a service owned by a team that has never heard of linkly-db, through the API. That indirect path is the kind of thing nobody remembers at 3 a.m., and the catalog remembers for you, if dependsOn and consumesApis are kept honest. Keeping them honest is easier when they're generated or checked: compare declared dependencies with what tracing actually sees (service graphs from Tempo or Jaeger, see Observability: Jaeger & Tempo).
Orphans and ownership rot
The catalog's most valuable fact is the owner, and it decays: teams are renamed, merged and dissolved. A weekly check finds:
GROUPS = {"engineering": None, "team-links": "engineering", "team-growth": "engineering"}
COMPONENTS = {
"linkly": {"owner": "team-links", "lifecycle": "production"},
"redirector": {"owner": "team-links", "lifecycle": "production"},
"analytics": {"owner": "team-growth", "lifecycle": "experimental"},
"qr-codes": {"owner": "team-qr", "lifecycle": "production"}, # team-qr was dissolved
"old-admin": {"owner": "ada", "lifecycle": "production"}, # a person, who left
"url-checker": {"owner": "grace", "lifecycle": "experimental"}, # a person, still here
}
USERS = {"grace": "team-links", "alan": "team-growth"} # current users -> their team
for name, c in sorted(COMPONENTS.items()):
owner = c["owner"]
if owner in GROUPS:
chain, g = [], owner
while g:
chain.append(g); g = GROUPS[g]
status = "ok (" + " < ".join(chain) + ")"
elif owner in USERS:
status = f"owned by a person; move to {USERS[owner]}"
else:
status = "ORPHAN: owner does not exist"
print(f"{name:12} {c['lifecycle']:12} {status}")
per_team = {}
for c in COMPONENTS.values():
if c["owner"] in GROUPS:
per_team[c["owner"]] = per_team.get(c["owner"], 0) + 1
print("components per team:", dict(sorted(per_team.items())))analytics experimental ok (team-growth < engineering)
linkly production ok (team-links < engineering)
old-admin production ORPHAN: owner does not exist
qr-codes production ORPHAN: owner does not exist
redirector production ok (team-links < engineering)
url-checker experimental owned by a person; move to team-links
components per team: {'team-growth': 1, 'team-links': 2}
Rules that keep ownership healthy:
- Owners are groups, not people. People leave; teams get renamed but are imported from the identity provider, so the rename shows up as a broken reference you can detect.
- Every production component has an existing owner. Check it in CI (next lesson) and weekly against the whole catalog.
- Re-organisations include a catalog migration: when a team dissolves, its components are reassigned before the group disappears.
Test yourself
Why does Backstage store every relation in both directions?
- For backups
- So both 'what does X depend on' and 'what depends on X' are direct lookups
- YAML requires it
- To double-check owners
In the blast-radius model, why is qr-codes affected by a database failure?
- It uses the database directly
- It consumes linkly's API, and linkly depends on the database
- It is owned by team-links
- It is in the links system
Why should components be owned by groups rather than users?
- Backstage forbids users
- People change teams and leave; groups persist and are synced from the identity provider
- Users can't be paged
- Groups are cheaper