Commit 7a6dee0
authored
feat(epp): add topology-extractor datalayer plugin (#1678)
* feat(epp): add topology-extractor datalayer plugin
Introduces a topology-extractor endpoint extractor that stamps each
endpoint with a Topology attribute (hostname) at creation time.
The hostname is resolved once when the endpoint is created:
- Default: the Pod hostname field (EndpointMetadata.PodName).
- With hostnameLabel configured: the value of the named pod label.
If the label is absent, the attribute is not set.
Works for both k8s-discovered and file-based endpoints. The attribute
is a static Cloneable value stored in the endpoint's AttributeMap.
The extractor self-registers with the endpoint-notification-source,
creating a default source if none is configured.
Planned scorer (not implemented): topology-locality-scorer would
score 1.0 for endpoints whose Topology.Hostname matches a key set
on the request attribute store, and 0.0 otherwise. The request key
would be published by a DataProducer reading a request header
(e.g. x-topology-key) or from EPP node metadata. When no key is
present on the request, all endpoints score 0.0.
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
* feat(epp): register topology-extractor for both Pod and Endpoint notifications
- Remove auto-generated release note fragment (generated by CI action)
- Register for both the endpoint notification source and a Pod k8s
notification source via RegisterDependencies
- With hostnameLabel configured: endpoint handler extracts the label
value and stamps the Topology attribute; Pod handler is a no-op
- Without hostnameLabel: endpoint handler tracks the live Endpoint in
an internal map; Pod notification handler reads spec.hostname from the
Pod object and stamps the matching endpoint
- Maintain the endpoint map under a RWMutex; remove entries on delete
The prior implementation only handled endpoint events, which do not
carry the full Pod object. Pod notifications provide spec.hostname for
the no-label path.
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
* fix(epp): handle multi-port and pod-before-endpoint ordering in topology-extractor
The prior implementation keyed endpoint lookup by endpoint NamespacedName
(e.g. worker-1-rank-0), which never matches the pod notification key
(worker-1). Also, pod notifications fire before endpoints are created, so
the attribute was never stamped.
Fix:
- Key both internal maps by pod identity {PodName, Namespace}.
- endpoints map holds a []Endpoint per pod to cover all rank entries.
- hostnames map caches spec.hostname from pod notifications; whichever
event fires first, the attribute is written once both have been seen.
- Only cache hostnames for ready pods; evict on not-ready or pod delete.
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
* docs/test: update README and fix lint in topology-extractor
README: remove stale 'at endpoint creation' phrasing; clarify that
Hostname is sourced from spec.hostname or a configured pod label.
Tests: drop always-constant parameters from helper functions (unparam);
introduce constants for repeated string literals (goconst).
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
* feat(epp): extend topology-extractor with zone and region
Add zone and region fields to the Topology attribute and the params
struct. Each param names the pod label to read; defaults are the
standard Kubernetes topology labels (corev1.LabelHostname,
LabelTopologyZone, LabelTopologyRegion).
The hostname label falling back to spec.hostname is preserved: when
the hostname label is absent the endpoint is tracked and stamped once
the Pod notification fires. Zone and region have no fallback.
Zone and region values are not read from Node objects -- that would
require RBAC for Node GET/LIST. They are populated when the pod itself
carries the corresponding labels.
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
* fix(topology-extractor): idempotent endpoint tracking and README wording
Change endpoints map inner type from []Endpoint to
map[NamespacedName]Endpoint. EventAddOrUpdate re-fires on
endpoint updates, so the previous append caused duplicate
entries for the same endpoint. Map assignment is idempotent.
Remove the now-unused slices import.
Fix README wording: "pod label" -> "endpoint label".
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
* feat(epp): add Rack attribute to topology-extractor
Adds a Rack locality field between Hostname and Zone on the Topology
attribute. Sourced from topology.kubernetes.io/rack by default,
configurable via the params.rack plugin parameter.
Mirrors the existing Hostname handling for the no-fallback path:
on subsequent pod notifications the previously stamped Rack value
from the endpoint event is preserved alongside Zone and Region.
Signed-off-by: Etai Lev Ran <elevran@gmail.com>
---------
Signed-off-by: Etai Lev Ran <elevran@gmail.com>1 parent 04d683f commit 7a6dee0
5 files changed
Lines changed: 1030 additions & 0 deletions
File tree
- cmd/epp/runner
- pkg/epp/framework/plugins/datalayer
- attribute/topology
- extractor/topology
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
566 | 568 | | |
567 | 569 | | |
568 | 570 | | |
| 571 | + | |
569 | 572 | | |
570 | 573 | | |
571 | 574 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments