Skip to content

Commit

Permalink
fix: fix unexcepted lookup.
Browse files Browse the repository at this point in the history
Signed-off-by: Asklv <boironic@gmail.com>
  • Loading branch information
IRONICBo authored and cpunion committed Jun 15, 2024
1 parent 5f10d53 commit 541b728
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pkg/agent/monitortool/latency_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (l *LatencyStore) ConvertList(currentNodeName string) []statsv1alpha1.PeerN

// PeerNodeLatencyStats should be a list of size N-1, where N is the number of Nodes in the cluster.
// TargetIPLatencyStats will be a list of size 1 (single-stack case) or 2 (dual-stack case).
peerNodeLatencyStatsList := make([]statsv1alpha1.PeerNodeLatencyStats, 0, len(l.nodeIPLatencyMap)-1)
peerNodeLatencyStatsList := make([]statsv1alpha1.PeerNodeLatencyStats, 0, len(l.nodeIPLatencyMap))
for nodeName, nodeIPs := range l.nodeTargetIPsMap {
// Even though the current Node should already be excluded from the map, we add an extra check as an additional guarantee.
if nodeName == currentNodeName {
Expand All @@ -269,11 +269,12 @@ func (l *LatencyStore) ConvertList(currentNodeName string) []statsv1alpha1.PeerN
targetIPLatencyStats := make([]statsv1alpha1.TargetIPLatencyStats, 0, len(nodeIPs))
for _, nodeIP := range nodeIPs {
nodeIPStr := nodeIP.String()
latencyEntry := l.nodeIPLatencyMap[nodeIPStr]
entry := statsv1alpha1.TargetIPLatencyStats{
TargetIP: nodeIPStr,
LastSendTime: metav1.NewTime(l.nodeIPLatencyMap[nodeIPStr].LastSendTime),
LastRecvTime: metav1.NewTime(l.nodeIPLatencyMap[nodeIPStr].LastRecvTime),
LastMeasuredRTTNanoseconds: l.nodeIPLatencyMap[nodeIPStr].LastMeasuredRTT.Nanoseconds(),
LastSendTime: metav1.NewTime(latencyEntry.LastSendTime),
LastRecvTime: metav1.NewTime(latencyEntry.LastRecvTime),
LastMeasuredRTTNanoseconds: latencyEntry.LastMeasuredRTT.Nanoseconds(),
}
targetIPLatencyStats = append(targetIPLatencyStats, entry)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/stats/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/stats/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ type RuleTrafficStats struct {
// +genclient:onlyVerbs=create,delete,get,list,watch
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NodeLatencyStats contains the latency stat of a Node.
// NodeLatencyStats contains all the latency measurements collected by the Agent from a specific Node.
type NodeLatencyStats struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/apiserver/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 541b728

Please sign in to comment.