From d3689f46ff53446976ccb4457330e533a09c43db Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 6 Jun 2024 12:03:30 -0700 Subject: [PATCH] fix: remove duplicate imports in latency.go (#445) # Description As title. Close https://github.com/microsoft/retina/issues/98 ## Related Issue If this pull request is related to any issue, please mention it here. Additionally, make sure that the issue is assigned to you before submitting this pull request. ## Checklist - [x] I have read the [contributing documentation](https://retina.sh/docs/contributing). - [x] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [x] I have correctly attributed the author(s) of the code. - [x] I have tested the changes locally. - [x] I have followed the project's style guidelines. - [x] I have updated the documentation, if necessary. - [x] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed Please add any relevant screenshots or GIFs to showcase the changes made. ## Additional Notes Add any additional notes or context about the pull request here. --- Please refer to the [CONTRIBUTING.md](../CONTRIBUTING.md) file for more information on how to contribute to this project. --- pkg/module/metrics/latency.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/module/metrics/latency.go b/pkg/module/metrics/latency.go index 8a49276aa45..7a0bab9b7bf 100644 --- a/pkg/module/metrics/latency.go +++ b/pkg/module/metrics/latency.go @@ -12,7 +12,6 @@ import ( "time" "github.com/cilium/cilium/api/v1/flow" - v1 "github.com/cilium/cilium/api/v1/flow" ttlcache "github.com/jellydator/ttlcache/v3" api "github.com/microsoft/retina/crd/api/v1alpha1" "github.com/microsoft/retina/pkg/common" @@ -178,7 +177,7 @@ func (lm *LatencyMetrics) Clean() { } } -func (lm *LatencyMetrics) ProcessFlow(f *v1.Flow) { +func (lm *LatencyMetrics) ProcessFlow(f *flow.Flow) { if f == nil || f.GetL4() == nil || f.GetL4().GetTCP() == nil || utils.GetTCPID(f) == 0 || f.GetIP() == nil { return } @@ -255,12 +254,12 @@ func (lm *LatencyMetrics) ProcessFlow(f *v1.Flow) { | | +-------------------------------------------------+ */ -func (lm *LatencyMetrics) calculateLatency(f *v1.Flow) { +func (lm *LatencyMetrics) calculateLatency(f *flow.Flow) { // Ignore all packets observed at endpoint. // We only care about node-apiserver packets observed at eth0. // TO_NETWORK: Packets leaving node via eth0. // FROM_NETWORK: Packets entering node via eth0. - if f.TraceObservationPoint == v1.TraceObservationPoint_TO_NETWORK { + if f.GetTraceObservationPoint() == flow.TraceObservationPoint_TO_NETWORK { k := key{ srcIP: f.IP.Source, dstIP: f.IP.Destination, @@ -275,7 +274,7 @@ func (lm *LatencyMetrics) calculateLatency(f *v1.Flow) { flags: f.GetL4().GetTCP().GetFlags(), }, TTL) } - } else if f.TraceObservationPoint == v1.TraceObservationPoint_FROM_NETWORK { + } else if f.GetTraceObservationPoint() == flow.TraceObservationPoint_FROM_NETWORK { k := key{ srcIP: f.IP.Destination, dstIP: f.IP.Source,