Skip to content

Commit 87b51c9

Browse files
committed
Replace NodeID field access with ID()
1 parent 7cf0f35 commit 87b51c9

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

pkg/models/node_info.go

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ func (n NoopNodeInfoDecorator) DecorateNodeInfo(ctx context.Context, nodeInfo No
9090
// to further its view of the networks conditions. ComputeNodeInfo is non-nil iff the NodeType is NodeTypeCompute.
9191
// TODO(walid): add Validate() method to NodeInfo and make sure it is called in all the places where it is initialized
9292
type NodeInfo struct {
93-
// TODO replace all access on this field with the `ID()` method
9493
NodeID string `json:"NodeID"`
9594
NodeType NodeType `json:"NodeType"`
9695
Labels map[string]string `json:"Labels"`

pkg/nats/proxy/management_proxy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (p *ManagementProxy) Register(ctx context.Context,
5252
var asyncRes *concurrency.AsyncResult[legacy.RegisterResponse]
5353

5454
asyncRes, err = send[legacy.RegisterRequest, legacy.RegisterResponse](
55-
ctx, p.conn, request.Info.NodeID, request, RegisterNode)
55+
ctx, p.conn, request.Info.ID(), request, RegisterNode)
5656

5757
if err != nil {
5858
return nil, errors.Wrap(err, "failed to send response to registration request")

pkg/orchestrator/selection/ranking/available_capacity.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ func (s *AvailableCapacityNodeRanker) calculateWeightedCapacities(nodes []models
103103
weightedAvailableCapacity := weightedCapacity(node.ComputeNodeInfo.AvailableCapacity, weights)
104104
weightedQueueUsedCapacity := weightedCapacity(node.ComputeNodeInfo.QueueUsedCapacity, weights)
105105

106-
weightedAvailableCapacities[node.NodeID] = weightedAvailableCapacity
107-
weightedQueueCapacities[node.NodeID] = weightedQueueUsedCapacity
106+
weightedAvailableCapacities[node.ID()] = weightedAvailableCapacity
107+
weightedQueueCapacities[node.ID()] = weightedQueueUsedCapacity
108108

109109
if weightedAvailableCapacity > maxWeightedAvailableCapacity {
110110
maxWeightedAvailableCapacity = weightedAvailableCapacity
@@ -124,8 +124,8 @@ func (s *AvailableCapacityNodeRanker) rankNodesBasedOnCapacities(ctx context.Con
124124
ranks := make([]orchestrator.NodeRank, len(nodes))
125125

126126
for i, node := range nodes {
127-
weightedAvailableCapacity := wAvailableCapacities[node.NodeID]
128-
weightedQueueUsedCapacity := wQueueCapacities[node.NodeID]
127+
weightedAvailableCapacity := wAvailableCapacities[node.ID()]
128+
weightedQueueUsedCapacity := wQueueCapacities[node.ID()]
129129

130130
// Calculate the ratios of available and queue capacities
131131
availableRatio := 0.0

pkg/transport/bprotocol/orchestrator/heartbeat_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (s *HeartbeatTestSuite) TestHeartbeatScenarios() {
224224

225225
s.clock.Add(tc.waitUntil)
226226

227-
nodeState, err := s.nodeManager.Get(ctx, nodeInfo.NodeID)
227+
nodeState, err := s.nodeManager.Get(ctx, nodeInfo.ID())
228228
if tc.handshake {
229229
s.Require().NoError(err)
230230
s.Require().Equal(tc.expectedState, nodeState.ConnectionState.Status, fmt.Sprintf("incorrect state in %s", tc.name))

pkg/transport/nclprotocol/compute/controlplane.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (cp *ControlPlane) heartbeat(ctx context.Context) error {
139139
cp.latestNodeInfo = nodeInfo
140140

141141
msg := envelope.NewMessage(messages.HeartbeatRequest{
142-
NodeID: cp.latestNodeInfo.NodeID,
142+
NodeID: cp.latestNodeInfo.ID(),
143143
AvailableCapacity: nodeInfo.ComputeNodeInfo.AvailableCapacity,
144144
QueueUsedCapacity: nodeInfo.ComputeNodeInfo.QueueUsedCapacity,
145145
LastOrchestratorSeqNum: cp.incomingSeqTracker.GetLastSeqNum(),

pkg/transport/nclprotocol/compute/controlplane_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (s *ControlPlaneTestSuite) TestHeartbeat() {
158158

159159
nodeInfo := s.nodeInfoProvider.GetNodeInfo(s.ctx)
160160
heartbeatMsg := envelope.NewMessage(messages.HeartbeatRequest{
161-
NodeID: nodeInfo.NodeID,
161+
NodeID: nodeInfo.ID(),
162162
AvailableCapacity: nodeInfo.ComputeNodeInfo.AvailableCapacity,
163163
QueueUsedCapacity: nodeInfo.ComputeNodeInfo.QueueUsedCapacity,
164164
LastOrchestratorSeqNum: s.seqTracker.GetLastSeqNum(),

pkg/transport/nclprotocol/compute/manager_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (s *ConnectionManagerTestSuite) TestSuccessfulConnection() {
159159
heartbeats := s.mockResponder.GetHeartbeats()
160160
s.Require().Len(heartbeats, 1)
161161
s.Require().Equal(messages.HeartbeatRequest{
162-
NodeID: nodeInfo.NodeID,
162+
NodeID: nodeInfo.ID(),
163163
AvailableCapacity: nodeInfo.ComputeNodeInfo.AvailableCapacity,
164164
QueueUsedCapacity: nodeInfo.ComputeNodeInfo.QueueUsedCapacity,
165165
LastOrchestratorSeqNum: handshakeSeqNum, // Should use sequence number from handshake response
@@ -178,7 +178,7 @@ func (s *ConnectionManagerTestSuite) TestSuccessfulConnection() {
178178
s.Require().Eventually(func() bool {
179179
lastHeartbeat := s.mockResponder.GetHeartbeats()[len(s.mockResponder.GetHeartbeats())-1]
180180
return reflect.DeepEqual(lastHeartbeat, messages.HeartbeatRequest{
181-
NodeID: nodeInfo.NodeID,
181+
NodeID: nodeInfo.ID(),
182182
AvailableCapacity: nodeInfo.ComputeNodeInfo.AvailableCapacity,
183183
QueueUsedCapacity: nodeInfo.ComputeNodeInfo.QueueUsedCapacity,
184184
LastOrchestratorSeqNum: handshakeSeqNum, // Should continue using sequence number from handshake

0 commit comments

Comments
 (0)