Skip to content

fix: remove dead HostIndex field and unreachable nil branch - #197

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/addressing-remove-dead-hostindex-field-and
Open

fix: remove dead HostIndex field and unreachable nil branch#197
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/addressing-remove-dead-hostindex-field-and

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Aug 17, 2026

Copy link
Copy Markdown

This PR removes the dead HostIndex field from topologyEndpoint and the unreachable nil branch that used it.

Changes

  • pkg/networkoperatorplugin/spectrumx/addressing.go: remove the HostIndex field from topologyEndpoint and always derive host indices with countHostIndex.
  • pkg/networkoperatorplugin/spectrumx/air_topology.go: remove the now-removed HostIndex initialization in normalizeAIRHostLink.
  • pkg/networkoperatorplugin/spectrumx/air_topology_test.go: remove assertions on the removed HostIndex field.
  • pkg/networkoperatorplugin/spectrumx/addressing_test.go: update the 3-tier AIR topology expectation to reflect count-based host indexing (the single host in the test now receives index 0 instead of the parsed hostname index 3).

Details

addressing.go

 type topologyEndpoint struct {
 	Node      string             `json:"node"`
 	Interface string             `json:"interface"`
 	Attrs     topologyAttributes `json:"attributes"`
-	HostIndex *int               `json:"-"`
 }
 		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
 		}

air_topology.go

-	explicitHostIndex := hostIndex
 	hostAttrs := topologyAttributes{
 		Role:    "host",
 		...
 	}
 	...
 	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

Testing

  • go test ./pkg/networkoperatorplugin/spectrumx/... — pass
  • go build ./... — pass
  • go test ./... — pass

@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown

Greptile Summary

This PR completes removal of the obsolete Spectrum-X HostIndex endpoint field and its explicit AIR-topology propagation, resolving the previously reported build failure.

  • Removes the remaining HostIndex initializer and test references.
  • Uses count-based host indexing consistently and updates the AIR allocation expectation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
pkg/networkoperatorplugin/spectrumx/addressing.go Removes the obsolete endpoint field and unreachable explicit-index branch without leaving unresolved references.
pkg/networkoperatorplugin/spectrumx/addressing_test.go Updates the AIR three-tier allocation expectation for count-based host indexing.
pkg/networkoperatorplugin/spectrumx/air_topology.go Removes the remaining initialization of the deleted endpoint field.
pkg/networkoperatorplugin/spectrumx/air_topology_test.go Removes assertions tied to the deleted endpoint field.

Reviews (2): Last reviewed commit: "fix: remove dead HostIndex field and unr..." | Re-trigger Greptile

Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
@andrewwhitecdw
andrewwhitecdw force-pushed the codequality/addressing-remove-dead-hostindex-field-and branch from 7364c0c to 8cd44d6 Compare August 17, 2026 22:08
@andrewwhitecdw

Copy link
Copy Markdown
Author

@greptile-apps thanks for the catch. The remaining HostIndex references have been removed:

  • pkg/networkoperatorplugin/spectrumx/air_topology.go: dropped the explicitHostIndex variable and the HostIndex field initialization in normalizeAIRHostLink.
  • pkg/networkoperatorplugin/spectrumx/air_topology_test.go: removed assertions on the removed HostIndex field.
  • pkg/networkoperatorplugin/spectrumx/addressing_test.go: updated the 3-tier AIR topology expectation to match the new count-based host indexing behavior.

Verification:

  • go test ./pkg/networkoperatorplugin/spectrumx/... — pass
  • go build ./... — pass
  • go test ./... — pass

The branch has been force-pushed; please re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant