Skip to content
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

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

ceclinux
Copy link
Contributor

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.

Signed-off-by: ceclinux [email protected]

@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Merging #4240 (2ea1010) into main (b2ba248) will increase coverage by 2.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
e2e-tests 39.56% <34.09%> (?)
integration-tests 34.52% <ø> (+0.11%) ⬆️
kind-e2e-tests 47.83% <34.09%> (+5.18%) ⬆️
unit-tests 45.13% <84.09%> (+0.09%) ⬆️
Impacted Files Coverage Δ
pkg/agent/stats/collector.go 90.69% <100.00%> (+16.40%) ⬆️
pkg/agent/flowexporter/exporter/exporter.go 71.53% <0.00%> (-10.15%) ⬇️
pkg/controller/ipam/antrea_ipam_controller.go 75.25% <0.00%> (-3.02%) ⬇️
pkg/ipam/ipallocator/allocator.go 88.14% <0.00%> (-1.55%) ⬇️
pkg/ipam/poolallocator/allocator.go 73.57% <0.00%> (-0.24%) ⬇️
pkg/controller/grouping/controller.go 67.10% <0.00%> (ø)
...g/controller/networkpolicy/clusternetworkpolicy.go 74.37% <0.00%> (+0.22%) ⬆️
pkg/agent/secondarynetwork/podwatch/controller.go 74.82% <0.00%> (+0.35%) ⬆️
pkg/controller/ipam/validate.go 80.32% <0.00%> (+0.54%) ⬆️
pkg/agent/openflow/network_policy.go 79.82% <0.00%> (+0.65%) ⬆️
... and 47 more

@ceclinux ceclinux force-pushed the fix-multicastgroups-report branch 6 times, most recently from be19a86 to 2081a30 Compare September 21, 2022 17:59
@ceclinux
Copy link
Contributor Author

Update: Made a minor refactor based on yesterday's discussion @wenyingd

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (m *Collector) calculateStats(curStatsCollection *statsCollection) (npStats, acnpStats, anpStats []cpv1beta.NetworkPolicyStats) {
func (m *Collector) calculateNPStats(curStatsCollection *statsCollection) (npStats, acnpStats, anpStats []cpv1beta.NetworkPolicyStats) {

Copy link
Contributor Author

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 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

wenyingd
wenyingd previously approved these changes Oct 10, 2022
Copy link
Contributor

@wenyingd wenyingd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tnqn tnqn added this to the Antrea v1.9 release milestone Oct 12, 2022
tnqn
tnqn previously approved these changes Oct 12, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tnqn tnqn added action/backport Indicates a PR that requires backports. action/release-note Indicates a PR that should be included in release notes. labels Oct 12, 2022
@tnqn
Copy link
Member

tnqn commented Oct 12, 2022

I assume the issue is that user will see empty/incomplete multicast group members wrongly in some cases?
For future PRs, please create an issue or describe the consequence in the PR so others can better understand the problem and can point to the fix when same issue is encountered.

@tnqn
Copy link
Member

tnqn commented Oct 12, 2022

If my understanding is correct, I think the patch should be backported.

@tnqn
Copy link
Member

tnqn commented Oct 12, 2022

DCO check failed.
So do codecov/patch. Since you refactored the code, they will be counted as new code, you need to add unit test for them.

@ceclinux
Copy link
Contributor Author

ceclinux commented Oct 13, 2022

DCO check failed. So do codecov/patch. Since you refactored the code, they will be counted as new code, you need to add unit test for them.

@tnqn Your understanding is correct. I will add more tests later to cover the refactored code later in this PR. Thanks.

@ceclinux ceclinux dismissed stale reviews from tnqn and wenyingd via 7c983d6 October 15, 2022 19:59
@ceclinux ceclinux force-pushed the fix-multicastgroups-report branch 3 times, most recently from fd79c92 to eea7dcd Compare October 16, 2022 10:48
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]>
@ceclinux
Copy link
Contributor Author

/test-all

@ceclinux
Copy link
Contributor Author

/test-multicast-e2e

@ceclinux
Copy link
Contributor Author

DCO check failed. So do codecov/patch. Since you refactored the code, they will be counted as new code, you need to add unit test for them.

Tests added. DCO and codecov passed. @tnqn

@ceclinux ceclinux requested a review from tnqn October 17, 2022 03:45
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tnqn tnqn merged commit 03b2948 into antrea-io:main Oct 17, 2022
heanlan pushed a commit to heanlan/antrea that referenced this pull request Mar 29, 2023
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/backport Indicates a PR that requires backports. action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants