-
Notifications
You must be signed in to change notification settings - Fork 377
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
Fix unexpected reporting of empty MulticastGroupInfo #4240
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4240 +/- ##
==========================================
+ Coverage 61.30% 63.32% +2.02%
==========================================
Files 388 388
Lines 55145 55154 +9
==========================================
+ Hits 33806 34929 +1123
+ Misses 18799 17671 -1128
- Partials 2540 2554 +14
|
be19a86
to
2081a30
Compare
2081a30
to
1dd5a3c
Compare
Update: Made a minor refactor based on yesterday's discussion @wenyingd |
pkg/agent/stats/collector.go
Outdated
npStats := calculateDiff(curStatsCollection.networkPolicyStats, m.lastStatsCollection.networkPolicyStats) | ||
acnpStats := calculateRuleDiff(curStatsCollection.antreaClusterNetworkPolicyStats, m.lastStatsCollection.antreaClusterNetworkPolicyStats) | ||
anpStats := calculateRuleDiff(curStatsCollection.antreaNetworkPolicyStats, m.lastStatsCollection.antreaNetworkPolicyStats) | ||
func (m *Collector) calculateStats(curStatsCollection *statsCollection) (npStats, acnpStats, anpStats []cpv1beta.NetworkPolicyStats) { |
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.
func (m *Collector) calculateStats(curStatsCollection *statsCollection) (npStats, acnpStats, anpStats []cpv1beta.NetworkPolicyStats) { | |
func (m *Collector) calculateNPStats(curStatsCollection *statsCollection) (npStats, acnpStats, anpStats []cpv1beta.NetworkPolicyStats) { |
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.
updated
var multicastGroups []cpv1beta.MulticastGroupInfo | ||
multicastGroupsUpdated := false | ||
npStats, acnpStats, anpStats := m.calculateStats(curStatsCollection) | ||
if m.multicastEnabled { |
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.
Still feel better to use a flag multicastGroupsUpdated
and set its value with function isIdenticalMulticastGroupMap
inside "if m.multicastEnabled", and then consume the flag in line 222
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.
updated
1dd5a3c
to
95d0aaa
Compare
95d0aaa
to
a928e26
Compare
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
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
I assume the issue is that user will see empty/incomplete multicast group members wrongly in some cases? |
If my understanding is correct, I think the patch should be backported. |
DCO check failed. |
@tnqn Your understanding is correct. I will add more tests later to cover the refactored code later in this PR. Thanks. |
fd79c92
to
eea7dcd
Compare
eea7dcd
to
7a1d29b
Compare
The empty MulticastGroupInfo will be reported unexpectedly during a single report session when: 1. Statistics of NP, ANP, or ANCP are getting updated. 2. MulticastGroupInfo is not refreshed. Fix: Always report updated MulticastGroupInfo when reporting is necessary. Also, add a minor refactor for the collector report function. Signed-off-by: ceclinux <[email protected]>
7a1d29b
to
2ea1010
Compare
/test-all |
/test-multicast-e2e |
Tests added. DCO and codecov passed. @tnqn |
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
The empty MulticastGroupInfo will be reported unexpectedly during a single report session when: 1. Statistics of NP, ANP, or ANCP are getting updated. 2. MulticastGroupInfo is not refreshed. Fix: Always report updated MulticastGroupInfo when reporting is necessary. Also, add a minor refactor for the collector report function. Signed-off-by: ceclinux <[email protected]>
The empty MulticastGroupInfo will be reported unexpectedly during a single report session when:
Signed-off-by: ceclinux [email protected]