New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flow Aggregator] Fix throughput calculation in Logstash #2432
Conversation
| if newConn.StartTime.IsZero() { | ||
| newConn.StartTime = time.Now() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every time we poll, we change the start time. This is not correct. We should set it the first time we see the connection. It is different from StopTime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Then there is possibility that startTime is later than stopTime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes if the connection is only polled once.
To resolve this, let's re-update the stopTime again after updating startTime when the connection is added to the map for the first time.
This should be done only for cases when there is zero startTime.
| @@ -278,7 +278,8 @@ func flowStringToAntreaConnection(flow string, zoneFilter uint16) (*flowexporter | |||
| return nil, nil | |||
| } | |||
|
|
|||
| // Add current time as stop time. | |||
| // Add current time as start and stop time. | |||
| conn.StartTime = time.Now() | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Codecov Report
@@ Coverage Diff @@
## main #2432 +/- ##
==========================================
+ Coverage 59.63% 59.82% +0.18%
==========================================
Files 284 284
Lines 22178 22171 -7
==========================================
+ Hits 13226 13263 +37
+ Misses 7527 7486 -41
+ Partials 1425 1422 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: zyiou <zyiou@vmware.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please mention in the description what is the effect of this bug, i.e., we are missing some flow records on Kibana.
|
You may want to cherry-pick this to release-1.2 as well |
|
/skip-all |
This PR fixes throughput divided by 0 issue happened in Logstash.
Since we introduce
conn.StartTime.IsZero()check and update StartTime totime.Now()in previous fix #2308, there are chances thatStartTimewill be equal or later thanStopTime, which may cause incorrect throughput calculation or exception (divided by 0) in Logstash. And we will miss some flow records on Kibana due to this exception when the flow duration is quite short (less than 1 second)