Skip to content

[Task]: Replace flat l2topology.Graph maps with a typed L2 graph model #22619

@ilyam8

Description

@ilyam8

Problem / root cause

#22605 removes the legacy root topology payload package from production paths, but the internal l2topology.Graph still preserves the old flat graph shape with string-keyed maps.

Evidence:

  • src/go/pkg/l2topology/topology_adapter.go:223 returns l2topology.Graph.
  • src/go/pkg/l2topology/graph_types.go:31 keeps actor Attributes map[string]any.
  • src/go/pkg/l2topology/graph_types.go:54 keeps link Metrics map[string]any.
  • src/go/pkg/l2topology/graph_types.go:96 keeps graph Stats map[string]any.
  • src/go/plugin/go.d/collector/snmp_topology/func_topology_v1.go:783 through nearby lines read core actor fields by string keys.
  • src/go/plugin/go.d/collector/snmp_topology/func_topology_v1.go:918 through :941 read endpoint attributes and link metrics by string keys.

Clean end state

  • l2topology.Graph is a typed internal L2 graph model, not a relocated legacy payload shape.
  • Device, endpoint, segment, link evidence, endpoint metadata, port status, and stats needed by SNMP v1 conversion are typed.
  • Required production semantics are not hidden in map[string]any.
  • Any remaining maps are limited to deliberate extension/debug data.

Acceptance criteria

  • SNMP v1 conversion no longer depends on string-keyed maps for core actor/link semantics.
  • l2topology graph construction tests are updated around typed fields.
  • Existing SNMP topology behavior is preserved or intentional changes are documented.
  • Parity/golden tests remain meaningful after the type migration.
  • Tests pass: go test -count=1 ./pkg/l2topology ./pkg/l2topology/parity ./plugin/go.d/collector/snmp_topology.

Category

refactor

Scope boundaries

In scope: src/go/pkg/l2topology, SNMP topology projection, tests/fixtures.

Out of scope: vSphere overlays, Cloud/UI aggregation changes, unrelated topology producers.

Related context

Follow-up from #22605 and the legacy Go topology payload retirement PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions