Skip to content

Commit

Permalink
fix: remove duplicate imports in latency.go (microsoft#445)
Browse files Browse the repository at this point in the history
# Description

As title. Close microsoft#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.
  • Loading branch information
nddq authored and Carpe-Wang committed Jun 11, 2024
1 parent c134138 commit d3689f4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/module/metrics/latency.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit d3689f4

Please sign in to comment.