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 race condition in EgressController and unit tests #2307

Merged
merged 1 commit into from
Jun 25, 2021

Conversation

tnqn
Copy link
Member

@tnqn tnqn commented Jun 24, 2021

ipAllocatorMap was read without holding the mutex in syncEgressIP. This
patch fixes it and stabilizes the unit tests by waiting for cache sync
before starting creating objects. This is because resource creation
events will be missing if the resources are created in-between list and
watch call of an fake informer.

Signed-off-by: Quan Tian [email protected]

ipAllocatorMap was read without holding the mutex in syncEgressIP. This
patch fixes it and stabilizes the unit tests by waiting for cache sync
before starting creating objects. This is because resource creation
events will be missing if the resources are created in-between list and
watch call of an fake informer.

Signed-off-by: Quan Tian <[email protected]>
@tnqn tnqn requested a review from antoninbas June 24, 2021 15:46
@tnqn
Copy link
Member Author

tnqn commented Jun 24, 2021

/test-all

@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2021

Codecov Report

Merging #2307 (07f3c22) into main (ef14ad1) will increase coverage by 3.91%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2307      +/-   ##
==========================================
+ Coverage   62.05%   65.96%   +3.91%     
==========================================
  Files         277      280       +3     
  Lines       21588    22417     +829     
==========================================
+ Hits        13396    14788    +1392     
+ Misses       6792     6157     -635     
- Partials     1400     1472      +72     
Flag Coverage Δ
e2e-tests 56.79% <0.00%> (?)
kind-e2e-tests 52.41% <0.00%> (+0.06%) ⬆️
unit-tests 41.86% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/egress/controller.go 87.20% <100.00%> (ø)
pkg/agent/openflow/meters_linux.go 36.36% <0.00%> (ø)
pkg/ovs/openflow/ofctrl_meter.go 0.00% <0.00%> (ø)
pkg/util/runtime/runtime_linux.go 55.55% <0.00%> (ø)
pkg/agent/openflow/network_policy.go 76.41% <0.00%> (+0.59%) ⬆️
pkg/agent/cniserver/pod_configuration.go 54.68% <0.00%> (+0.78%) ⬆️
pkg/agent/flowexporter/exporter/exporter.go 79.58% <0.00%> (+0.91%) ⬆️
pkg/support/dump.go 66.27% <0.00%> (+1.16%) ⬆️
pkg/controller/egress/store/egressgroup.go 1.38% <0.00%> (+1.38%) ⬆️
pkg/ovs/openflow/ofctrl_flow.go 47.36% <0.00%> (+1.75%) ⬆️
... and 45 more

@antoninbas
Copy link
Contributor

/test-all

@antoninbas
Copy link
Contributor

/test-e2e

@tnqn
Copy link
Member Author

tnqn commented Jun 25, 2021

/test-e2e

@tnqn
Copy link
Member Author

tnqn commented Jun 25, 2021

/skip-e2e

The only failure is not related to this PR and has been tracked in #2283. Merging this PR to stabilize unit tests in main branch.

--- FAIL: TestFlowAggregator (236.62s)
    --- FAIL: TestFlowAggregator/IPv4 (93.33s)
        --- PASS: TestFlowAggregator/IPv4/IntraNodeFlows (13.49s)
        --- PASS: TestFlowAggregator/IPv4/IntraNodeDenyConnIngressANP (3.38s)
        --- PASS: TestFlowAggregator/IPv4/IntraNodeDenyConnEgressANP (3.41s)
        --- PASS: TestFlowAggregator/IPv4/IntraNodeDenyConnNP (4.52s)
        --- PASS: TestFlowAggregator/IPv4/InterNodeFlows (13.51s)
        --- PASS: TestFlowAggregator/IPv4/InterNodeDenyConnIngressANP (3.40s)
        --- PASS: TestFlowAggregator/IPv4/InterNodeDenyConnEgressANP (2.61s)
        --- PASS: TestFlowAggregator/IPv4/InterNodeDenyConnNP (8.83s)
        --- PASS: TestFlowAggregator/IPv4/ToExternalFlows (10.26s)
        --- FAIL: TestFlowAggregator/IPv4/LocalServiceAccess (13.43s)
        --- PASS: TestFlowAggregator/IPv4/RemoteServiceAccess (13.40s)

@tnqn tnqn merged commit 2d19196 into antrea-io:main Jun 25, 2021
@tnqn tnqn deleted the fix-egress-unittest branch June 25, 2021 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants