From 8cd44d69d493758b46c74c0ba7916da9d0bb758d Mon Sep 17 00:00:00 2001 From: andrewwhitecdw Date: Thu, 13 Aug 2026 18:39:34 -0500 Subject: [PATCH] fix: remove dead HostIndex field and unreachable nil branch Signed-off-by: andrewwhitecdw --- pkg/networkoperatorplugin/spectrumx/addressing.go | 7 +------ pkg/networkoperatorplugin/spectrumx/addressing_test.go | 4 ++-- pkg/networkoperatorplugin/spectrumx/air_topology.go | 3 +-- pkg/networkoperatorplugin/spectrumx/air_topology_test.go | 4 ---- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/pkg/networkoperatorplugin/spectrumx/addressing.go b/pkg/networkoperatorplugin/spectrumx/addressing.go index a335cf58..fceae8eb 100644 --- a/pkg/networkoperatorplugin/spectrumx/addressing.go +++ b/pkg/networkoperatorplugin/spectrumx/addressing.go @@ -86,7 +86,6 @@ type topologyEndpoint struct { Node string `json:"node"` Interface string `json:"interface"` Attrs topologyAttributes `json:"attributes"` - HostIndex *int `json:"-"` } type topologyAttributes struct { @@ -279,11 +278,7 @@ func hostLinks(topology *topologyFile, spcx *config.ProfileSpectrumX) ([]hostLin key := hostIndexKey(host.Attrs) index, ok := hostIndexes[key+"|"+host.Node] if !ok { - if host.HostIndex != nil { - index = *host.HostIndex - } else { - index = countHostIndex(hostIndexes, key) - } + index = countHostIndex(hostIndexes, key) hostIndexes[key+"|"+host.Node] = index } addressPlane := leaf.Attrs.Plane diff --git a/pkg/networkoperatorplugin/spectrumx/addressing_test.go b/pkg/networkoperatorplugin/spectrumx/addressing_test.go index 159c8de6..ba68eccd 100644 --- a/pkg/networkoperatorplugin/spectrumx/addressing_test.go +++ b/pkg/networkoperatorplugin/spectrumx/addressing_test.go @@ -252,9 +252,9 @@ func TestBuildCIDRPoolsFromAIR3Tier(t *testing.T) { PerNodeExclusions: []PerNodeExclusion{{StartIndex: 1, EndIndex: 1}}, Routes: []string{"10.8.0.0/13", "10.0.0.0/10"}, StaticAllocations: []StaticAllocation{{ - Gateway: "10.8.66.7", + Gateway: "10.8.66.1", NodeName: "worker-pod02-su03-h04", - Prefix: "10.8.66.6/31", + Prefix: "10.8.66.0/31", }}, }}, pools) } diff --git a/pkg/networkoperatorplugin/spectrumx/air_topology.go b/pkg/networkoperatorplugin/spectrumx/air_topology.go index be20932e..0b5898b0 100644 --- a/pkg/networkoperatorplugin/spectrumx/air_topology.go +++ b/pkg/networkoperatorplugin/spectrumx/air_topology.go @@ -305,7 +305,6 @@ func normalizeAIRHostLink( } hostPositions[position] = host.Node - explicitHostIndex := hostIndex hostAttrs := topologyAttributes{ Role: "host", Pod: hostPod, @@ -327,7 +326,7 @@ func normalizeAIRHostLink( HasRail: true, } return topologyLink{ - {Node: host.Node, Interface: host.Interface, Attrs: hostAttrs, HostIndex: &explicitHostIndex}, + {Node: host.Node, Interface: host.Interface, Attrs: hostAttrs}, {Node: leaf.Node, Interface: leaf.Interface, Attrs: leafAttrs}, }, nil } diff --git a/pkg/networkoperatorplugin/spectrumx/air_topology_test.go b/pkg/networkoperatorplugin/spectrumx/air_topology_test.go index 9e1e6750..8adb3f92 100644 --- a/pkg/networkoperatorplugin/spectrumx/air_topology_test.go +++ b/pkg/networkoperatorplugin/spectrumx/air_topology_test.go @@ -86,14 +86,11 @@ func TestParseAIRTopologyNormalizesOneBasedNamingContract(t *testing.T) { require.Equal(t, "host", host.Attrs.Role) require.Equal(t, 0, host.Attrs.Rail) require.Equal(t, 0, host.Attrs.SU) - require.NotNil(t, host.HostIndex) - require.Equal(t, 0, *host.HostIndex) require.Equal(t, "leaf", leaf.Attrs.Role) require.Equal(t, 0, leaf.Attrs.Plane) require.Equal(t, 0, leaf.Attrs.Rail) require.Equal(t, 0, leaf.Attrs.SU) require.Equal(t, 3, topology.Links[3][1].Attrs.Plane) - require.Equal(t, 1, *topology.Links[4][0].HostIndex) } func TestParseAIRTopologyNormalizes3TierNamingContract(t *testing.T) { @@ -128,7 +125,6 @@ func TestParseAIRTopologyNormalizes3TierNamingContract(t *testing.T) { require.True(t, host.Attrs.HasPod) require.Equal(t, 2, host.Attrs.SU) require.Equal(t, 1, host.Attrs.Rail) - require.Equal(t, 3, *host.HostIndex) require.Equal(t, 1, leaf.Attrs.Pod) require.Equal(t, 0, leaf.Attrs.Plane) }