Skip to content

Commit e1fae93

Browse files
authored
chore(go.d): retire legacy Go topology payloads (netdata#22614)
1 parent ea04264 commit e1fae93

59 files changed

Lines changed: 9027 additions & 1549 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/project-create-topology/SKILL.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ developer-facing and must stay in this project skill, not under
4141
## Core Rules
4242

4343
- Production payloads carry canonical topology facts for the aggregator and UI.
44-
- Go producers MUST use `src/go/pkg/topology/v1`. The non-v1
45-
`src/go/pkg/topology` payload model is legacy for new producers.
44+
- Go producers MUST use `src/go/pkg/topology/v1`. The non-v1 root
45+
`src/go/pkg/topology` payload model has been retired and MUST NOT be
46+
reintroduced for production topology payloads.
4647
- Test-only projection code may reconstruct compatibility payload shapes to
4748
prove parity.
4849
- Never add compatibility reconstruction fields, old-schema adapter names, or

‎.agents/skills/project-writing-collectors/SKILL.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,9 @@ Topology is its own data type — directed/undirected graphs of nodes and links.
478478
- **Live socket topology** (`src/collectors/network-viewer.plugin/`) — local L3/L4 sockets and their inferred connections.
479479
- **Streaming graph** (`src/streaming/`) — Netdata parent/child topology.
480480
- **Topology library** at `src/go/pkg/topology/v1` — production Go payload
481-
helpers for new topology producers. The non-v1 `src/go/pkg/topology/` payload
482-
model is legacy and must not be used for new topology work.
481+
helpers for new topology producers. The non-v1 root
482+
`src/go/pkg/topology/` payload model has been retired and must not be
483+
reintroduced for topology work.
483484

484485
Topology is consumed via Functions (`topology:*` family), not via metrics. The cardinality of network edges is too high for time-series storage and the use case is interactive lookup.
485486

‎.codacy.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude_paths:
1515
- src/aclk/mqtt_websockets/**
1616
- TODO-netflow-code-organization.md
1717
- TODO-netflow-plugin-refactor.md
18-
- src/go/pkg/topology/engine/parity/README.md
19-
- src/go/pkg/topology/engine/parity/evidence/**
18+
- src/go/pkg/l2topology/parity/README.md
19+
- src/go/pkg/l2topology/parity/evidence/**
2020
- .agents/**
2121
- docs/netdata-ai/skills/**
Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-3.0-or-later
22

3-
package topology
3+
package l2topology
44

55
import "time"
66

@@ -54,88 +54,6 @@ type Link struct {
5454
Metrics map[string]any `json:"metrics,omitempty"`
5555
}
5656

57-
// Presentation defines how the UI should render this topology.
58-
// Sent in the info response, not in data responses.
59-
60-
type PresentationSummaryField struct {
61-
Key string `json:"key"`
62-
Label string `json:"label"`
63-
Sources []string `json:"sources"`
64-
}
65-
66-
type PresentationTableColumn struct {
67-
Key string `json:"key"`
68-
Label string `json:"label"`
69-
Type string `json:"type,omitempty"`
70-
}
71-
72-
type PresentationTable struct {
73-
Label string `json:"label"`
74-
Source string `json:"source"`
75-
BulletSource bool `json:"bullet_source,omitempty"`
76-
Order int `json:"order,omitempty"`
77-
Columns []PresentationTableColumn `json:"columns"`
78-
}
79-
80-
type PresentationModalTab struct {
81-
ID string `json:"id"`
82-
Label string `json:"label"`
83-
Type string `json:"type,omitempty"`
84-
}
85-
86-
type PresentationActorType struct {
87-
Label string `json:"label"`
88-
ColorSlot string `json:"color_slot"`
89-
Opacity float64 `json:"opacity,omitempty"`
90-
Border bool `json:"border"`
91-
Role string `json:"role,omitempty"`
92-
SizeByLinks bool `json:"size_by_links,omitempty"`
93-
ShowPortBullets bool `json:"show_port_bullets,omitempty"`
94-
IconSVG string `json:"icon_svg,omitempty"`
95-
SummaryFields []PresentationSummaryField `json:"summary_fields"`
96-
Tables map[string]PresentationTable `json:"tables"`
97-
ModalTabs []PresentationModalTab `json:"modal_tabs"`
98-
}
99-
100-
type PresentationLinkType struct {
101-
Label string `json:"label"`
102-
ColorSlot string `json:"color_slot"`
103-
Opacity float64 `json:"opacity,omitempty"`
104-
Width float64 `json:"width,omitempty"`
105-
Dash bool `json:"dash,omitempty"`
106-
}
107-
108-
type PresentationPortType struct {
109-
Label string `json:"label"`
110-
ColorSlot string `json:"color_slot"`
111-
Opacity float64 `json:"opacity,omitempty"`
112-
}
113-
114-
type PresentationPortField struct {
115-
Key string `json:"key"`
116-
Label string `json:"label"`
117-
}
118-
119-
type PresentationLegendEntry struct {
120-
Type string `json:"type"`
121-
Label string `json:"label"`
122-
}
123-
124-
type PresentationLegend struct {
125-
Actors []PresentationLegendEntry `json:"actors"`
126-
Links []PresentationLegendEntry `json:"links"`
127-
Ports []PresentationLegendEntry `json:"ports,omitempty"`
128-
}
129-
130-
type Presentation struct {
131-
ActorTypes map[string]PresentationActorType `json:"actor_types"`
132-
LinkTypes map[string]PresentationLinkType `json:"link_types"`
133-
PortTypes map[string]PresentationPortType `json:"port_types,omitempty"`
134-
PortFields []PresentationPortField `json:"port_fields,omitempty"`
135-
Legend PresentationLegend `json:"legend"`
136-
ActorClickBehavior string `json:"actor_click_behavior"`
137-
}
138-
13957
type FlowExporter struct {
14058
IP string `json:"ip,omitempty"`
14159
Name string `json:"name,omitempty"`
@@ -164,7 +82,7 @@ type IPPolicy struct {
16482
LiveTopN *LiveTopN `json:"live_top_n,omitempty"`
16583
}
16684

167-
type Data struct {
85+
type Graph struct {
16886
SchemaVersion string `json:"schema_version"`
16987
Source string `json:"source,omitempty"`
17088
Layer string `json:"layer,omitempty"`

‎src/go/pkg/l2topology/mac_oui_lookup.go‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"sort"
88
"strings"
99
"sync"
10-
11-
"github.com/netdata/netdata/go/plugins/pkg/topology"
1210
)
1311

1412
//go:embed mac_oui_vendors.tsv
@@ -116,7 +114,7 @@ func lookupTopologyVendorByMACInIndex(index topologyOUIVendorIndex, mac string)
116114
return "", ""
117115
}
118116

119-
func inferTopologyVendorFromMatch(match topology.Match) (vendor string, prefix string) {
117+
func inferTopologyVendorFromMatch(match Match) (vendor string, prefix string) {
120118
candidates := make(map[string]struct{}, len(match.MacAddresses)+len(match.ChassisIDs))
121119
for _, value := range match.MacAddresses {
122120
if mac := normalizeMAC(value); mac != "" {

‎src/go/pkg/l2topology/mac_oui_lookup_test.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
package l2topology
44

55
import (
6+
"github.com/stretchr/testify/require"
67
"strings"
78
"testing"
8-
9-
"github.com/netdata/netdata/go/plugins/pkg/topology"
10-
"github.com/stretchr/testify/require"
119
)
1210

1311
func TestBuildTopologyOUIVendorIndex_IgnoresInvalidLinesAndKeepsFirstDuplicate(t *testing.T) {
@@ -49,7 +47,7 @@ func TestLookupTopologyVendorByMACInIndex_PrefersLongestPrefixAndNormalizesMAC(t
4947
}
5048

5149
func TestInferTopologyVendorFromMatch_UsesDeterministicCandidateOrder(t *testing.T) {
52-
match := topology.Match{
50+
match := Match{
5351
MacAddresses: []string{
5452
"28:6f:b9:00:00:22",
5553
"08:ea:44:11:22:33",

‎src/go/pkg/l2topology/parity/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Scope
44
- Validate topology engine parity against imported Enlinkd fixtures and assertion inventories.
5-
- Evidence files live in `src/go/pkg/topology/engine/parity/evidence`.
5+
- Evidence files live in `src/go/pkg/l2topology/parity/evidence`.
66

77
## Prerequisites
88
- Upstream checkout available at `/tmp/topology-library-repos/enlinkd`.
@@ -54,7 +54,7 @@ Outputs:
5454

5555
## Run Go Test Gates
5656
```bash
57-
go test ./pkg/topology/engine/... ./plugin/go.d/collector/snmp ./tools/topology-parity-evidence -count=1
57+
go test ./pkg/l2topology/... ./plugin/go.d/collector/snmp ./tools/topology-parity-evidence -count=1
5858
```
5959

6060
Expected:
@@ -67,7 +67,7 @@ Expected:
6767
2. `suite` has failed scenarios:
6868
- Open `parity-summary.json`.
6969
- Inspect failing scenario IDs and manifests.
70-
- Re-run targeted tests in `./pkg/topology/engine/parity`.
70+
- Re-run targeted tests in `./pkg/l2topology/parity`.
7171
3. Coverage totals regress:
7272
- Check `assertion-mapping.csv` uniqueness and status values.
7373
- Reconcile `not-applicable-approved.csv` with mapping rows using `not-applicable-approved`.

‎src/go/pkg/l2topology/topology_adapter.go‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ import (
66
"net/netip"
77
"strings"
88
"time"
9-
10-
"github.com/netdata/netdata/go/plugins/pkg/topology"
119
)
1210

13-
// TopologyDataOptions controls conversion from Result to topology.Data.
14-
type TopologyDataOptions struct {
11+
// GraphOptions controls conversion from Result to the internal graph projection.
12+
type GraphOptions struct {
1513
SchemaVersion string
1614
Source string
1715
Layer string
@@ -56,8 +54,8 @@ type endpointActorAccumulator struct {
5654
}
5755

5856
type projectedSegments struct {
59-
actors []topology.Actor
60-
links []topology.Link
57+
actors []Actor
58+
links []Link
6159
linksFdb int
6260
bidirectionalCount int
6361
endpointLinksCandidates int
@@ -221,9 +219,9 @@ func topologyInferenceStrategyConfigFor(strategy string) topologyInferenceStrate
221219
}
222220
}
223221

224-
// ToTopologyData converts an engine result to the shared topology schema.
225-
func ToTopologyData(result Result, opts TopologyDataOptions) topology.Data {
226-
builder := newTopologyDataBuilder(result, opts)
222+
// ToGraph converts an engine result to the internal graph projection.
223+
func ToGraph(result Result, opts GraphOptions) Graph {
224+
builder := newGraphBuilder(result, opts)
227225
builder.prepareIndexes()
228226
builder.collectBridgeTopologyInputs()
229227
builder.buildDeviceActors()
@@ -232,5 +230,5 @@ func ToTopologyData(result Result, opts TopologyDataOptions) topology.Data {
232230
builder.buildSegmentTopology()
233231
builder.finalizeGraph()
234232
builder.buildStats()
235-
return builder.data()
233+
return builder.graph()
236234
}

‎src/go/pkg/l2topology/topology_adapter_actor_collapse.go‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ package l2topology
55
import (
66
"sort"
77
"strings"
8-
9-
"github.com/netdata/netdata/go/plugins/pkg/topology"
108
)
119

12-
func collapseActorsByIP(actors []topology.Actor) []topology.Actor {
10+
func collapseActorsByIP(actors []Actor) []Actor {
1311
if len(actors) <= 1 {
1412
return actors
1513
}
@@ -98,7 +96,7 @@ func collapseActorsByIP(actors []topology.Actor) []topology.Actor {
9896
actors[rep] = merged
9997
}
10098

101-
out := make([]topology.Actor, 0, len(actors))
99+
out := make([]Actor, 0, len(actors))
102100
for idx, actor := range actors {
103101
if !keep[idx] {
104102
continue
@@ -108,12 +106,12 @@ func collapseActorsByIP(actors []topology.Actor) []topology.Actor {
108106
return out
109107
}
110108

111-
func eliminateNonIPInferredActors(actors []topology.Actor, links []topology.Link) ([]topology.Actor, []topology.Link) {
109+
func eliminateNonIPInferredActors(actors []Actor, links []Link) ([]Actor, []Link) {
112110
if len(actors) == 0 {
113111
return actors, links
114112
}
115113
removedIdentityKeys := make(map[string]struct{})
116-
filteredActors := make([]topology.Actor, 0, len(actors))
114+
filteredActors := make([]Actor, 0, len(actors))
117115
for _, actor := range actors {
118116
if topologyActorIsInferred(actor) && len(normalizedTopologyActorIPs(actor)) == 0 {
119117
for _, key := range topologyMatchIdentityKeys(actor.Match) {
@@ -127,7 +125,7 @@ func eliminateNonIPInferredActors(actors []topology.Actor, links []topology.Link
127125
return actors, links
128126
}
129127

130-
filteredLinks := make([]topology.Link, 0, len(links))
128+
filteredLinks := make([]Link, 0, len(links))
131129
for _, link := range links {
132130
srcKeys := topologyMatchIdentityKeys(link.Src.Match)
133131
dstKeys := topologyMatchIdentityKeys(link.Dst.Match)
@@ -154,7 +152,7 @@ func topologyIdentityKeysOverlap(keys []string, set map[string]struct{}) bool {
154152
return false
155153
}
156154

157-
func normalizedTopologyActorIPs(actor topology.Actor) []string {
155+
func normalizedTopologyActorIPs(actor Actor) []string {
158156
if len(actor.Match.IPAddresses) == 0 {
159157
return nil
160158
}
@@ -175,7 +173,7 @@ func normalizedTopologyActorIPs(actor topology.Actor) []string {
175173
return out
176174
}
177175

178-
func compareTopologyActorCollapsePriority(left, right topology.Actor) int {
176+
func compareTopologyActorCollapsePriority(left, right Actor) int {
179177
leftDevice := IsDeviceActorType(left.ActorType)
180178
rightDevice := IsDeviceActorType(right.ActorType)
181179
if leftDevice != rightDevice {
@@ -197,7 +195,7 @@ func compareTopologyActorCollapsePriority(left, right topology.Actor) int {
197195
return strings.Compare(leftKey, rightKey)
198196
}
199197

200-
func mergeTopologyActorMatch(base, other topology.Match) topology.Match {
198+
func mergeTopologyActorMatch(base, other Match) Match {
201199
base.ChassisIDs = mergeTopologyStringLists(base.ChassisIDs, other.ChassisIDs)
202200
base.MacAddresses = mergeTopologyStringLists(base.MacAddresses, other.MacAddresses)
203201
base.IPAddresses = mergeTopologyStringLists(base.IPAddresses, other.IPAddresses)
@@ -274,7 +272,7 @@ func mergeTopologyActorAttributes(base, extra map[string]any) map[string]any {
274272
return base
275273
}
276274

277-
func topologyActorIsInferred(actor topology.Actor) bool {
275+
func topologyActorIsInferred(actor Actor) bool {
278276
if strings.EqualFold(strings.TrimSpace(actor.ActorType), "endpoint") {
279277
return true
280278
}

0 commit comments

Comments
 (0)